drivers/gpu/drm/xe/xe_gt_sriov_pf_service.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_gt_sriov_pf_service.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_gt_sriov_pf_service.c- Extension
.c- Size
- 13268 bytes
- Lines
- 427
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
drm/drm_managed.habi/guc_relay_actions_abi.hregs/xe_gt_regs.hregs/xe_guc_regs.hxe_assert.hxe_mmio.hxe_gt_sriov_printk.hxe_gt_sriov_pf_service.hxe_gt_sriov_pf_service_types.hxe_guc_ct.hxe_guc_hxg_helpers.hxe_sriov.hxe_sriov_pf_service.h
Detected Declarations
struct reg_datafunction pf_alloc_runtime_infofunction read_manyfunction pf_prepare_runtime_infofunction xe_gt_sriov_pf_service_initfunction xe_gt_sriov_pf_service_updatefunction pf_process_handshake_msgfunction pf_service_runtime_queryfunction pf_process_runtime_query_msgfunction xe_gt_sriov_pf_service_process_requestfunction xe_gt_sriov_pf_service_print_runtime
Annotated Snippet
struct reg_data {
u32 offset;
u32 value;
} __packed;
static_assert(hxg_sizeof(struct reg_data) == 2);
/* Return: number of entries copied or negative error code on failure. */
static int pf_service_runtime_query(struct xe_gt *gt, u32 start, u32 limit,
struct reg_data *data, u32 *remaining)
{
struct xe_gt_sriov_pf_service_runtime_regs *runtime;
unsigned int count, i;
u32 addr;
xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
runtime = >->sriov.pf.service.runtime;
if (start > runtime->size)
return -ERANGE;
count = min_t(u32, runtime->size - start, limit);
for (i = 0; i < count; ++i, ++data) {
addr = runtime->regs[start + i].addr;
data->offset = xe_mmio_adjusted_addr(>->mmio, addr);
data->value = runtime->values[start + i];
}
*remaining = runtime->size - start - count;
return count;
}
/* Return: length of the response message or a negative error code on failure. */
static int pf_process_runtime_query_msg(struct xe_gt *gt, u32 origin,
const u32 *msg, u32 msg_len, u32 *response, u32 resp_size)
{
const u32 chunk_size = hxg_sizeof(struct reg_data);
struct reg_data *reg_data_buf;
u32 limit, start, max_chunks;
u32 remaining = 0;
int ret;
/* this action is available from ABI 1.0 */
if (!xe_sriov_pf_service_is_negotiated(gt_to_xe(gt), origin, 1, 0))
return -EACCES;
if (unlikely(msg_len > VF2PF_QUERY_RUNTIME_REQUEST_MSG_LEN))
return -EMSGSIZE;
if (unlikely(msg_len < VF2PF_QUERY_RUNTIME_REQUEST_MSG_LEN))
return -EPROTO;
if (unlikely(resp_size < VF2PF_QUERY_RUNTIME_RESPONSE_MSG_MIN_LEN))
return -EINVAL;
limit = FIELD_GET(VF2PF_QUERY_RUNTIME_REQUEST_MSG_0_LIMIT, msg[0]);
start = FIELD_GET(VF2PF_QUERY_RUNTIME_REQUEST_MSG_1_START, msg[1]);
resp_size = min_t(u32, resp_size, VF2PF_QUERY_RUNTIME_RESPONSE_MSG_MAX_LEN);
max_chunks = (resp_size - VF2PF_QUERY_RUNTIME_RESPONSE_MSG_MIN_LEN) / chunk_size;
limit = limit == VF2PF_QUERY_RUNTIME_NO_LIMIT ? max_chunks : min_t(u32, max_chunks, limit);
reg_data_buf = (void *)(response + VF2PF_QUERY_RUNTIME_RESPONSE_MSG_MIN_LEN);
ret = pf_service_runtime_query(gt, start, limit, reg_data_buf, &remaining);
if (ret < 0)
return ret;
response[0] = FIELD_PREP(GUC_HXG_MSG_0_ORIGIN, GUC_HXG_ORIGIN_HOST) |
FIELD_PREP(GUC_HXG_MSG_0_TYPE, GUC_HXG_TYPE_RESPONSE_SUCCESS) |
FIELD_PREP(VF2PF_QUERY_RUNTIME_RESPONSE_MSG_0_COUNT, ret);
response[1] = FIELD_PREP(VF2PF_QUERY_RUNTIME_RESPONSE_MSG_1_REMAINING, remaining);
return VF2PF_QUERY_RUNTIME_RESPONSE_MSG_MIN_LEN + ret * hxg_sizeof(struct reg_data);
}
/**
* xe_gt_sriov_pf_service_process_request - Service GT level SR-IOV request message from the VF.
* @gt: the &xe_gt that provides the service
* @origin: VF number that is requesting the service
* @msg: request message
* @msg_len: length of the request message (in dwords)
* @response: placeholder for the response message
* @resp_size: length of the response message buffer (in dwords)
*
* This function processes `Relay Message`_ request from the VF.
*
* Return: length of the response message or a negative error code on failure.
*/
int xe_gt_sriov_pf_service_process_request(struct xe_gt *gt, u32 origin,
const u32 *msg, u32 msg_len,
u32 *response, u32 resp_size)
Annotation
- Immediate include surface: `drm/drm_managed.h`, `abi/guc_relay_actions_abi.h`, `regs/xe_gt_regs.h`, `regs/xe_guc_regs.h`, `xe_assert.h`, `xe_mmio.h`, `xe_gt_sriov_printk.h`, `xe_gt_sriov_pf_service.h`.
- Detected declarations: `struct reg_data`, `function pf_alloc_runtime_info`, `function read_many`, `function pf_prepare_runtime_info`, `function xe_gt_sriov_pf_service_init`, `function xe_gt_sriov_pf_service_update`, `function pf_process_handshake_msg`, `function pf_service_runtime_query`, `function pf_process_runtime_query_msg`, `function xe_gt_sriov_pf_service_process_request`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.