drivers/gpu/drm/xe/xe_sriov_packet.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_sriov_packet.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_sriov_packet.c- Extension
.c- Size
- 12468 bytes
- Lines
- 522
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
xe_bo.hxe_device.hxe_guc_klv_helpers.hxe_sriov_packet.hxe_sriov_packet_types.hxe_sriov_pf_helpers.hxe_sriov_pf_migration.hxe_sriov_printk.h
Detected Declarations
function pf_pick_descriptorfunction pkt_needs_bofunction xe_sriov_packet_allocfunction xe_sriov_packet_freefunction pkt_initfunction xe_sriov_packet_initfunction xe_sriov_packet_init_from_hdrfunction pkt_hdr_readfunction pkt_data_readfunction pkt_read_singlefunction xe_sriov_packet_read_singlefunction pkt_hdr_writefunction pkt_data_writefunction xe_sriov_packet_write_singlefunction pf_descriptor_initfunction xe_sriov_packet_process_descriptorfunction pf_pending_initfunction pf_trailer_initfunction xe_sriov_packet_save_initfunction scoped_cond_guard
Annotated Snippet
if (ret) {
xe_sriov_packet_free(*data);
*data = NULL;
return ret;
}
*data = NULL;
}
return copied;
}
#define MIGRATION_KLV_DEVICE_DEVID_KEY 0xf001u
#define MIGRATION_KLV_DEVICE_DEVID_LEN 1u
#define MIGRATION_KLV_DEVICE_REVID_KEY 0xf002u
#define MIGRATION_KLV_DEVICE_REVID_LEN 1u
#define MIGRATION_DESCRIPTOR_DWORDS (GUC_KLV_LEN_MIN + MIGRATION_KLV_DEVICE_DEVID_LEN + \
GUC_KLV_LEN_MIN + MIGRATION_KLV_DEVICE_REVID_LEN)
static int pf_descriptor_init(struct xe_device *xe, unsigned int vfid)
{
struct xe_sriov_packet **desc = pf_pick_descriptor(xe, vfid);
struct xe_sriov_packet *data;
unsigned int len = 0;
u32 *klvs;
int ret;
data = xe_sriov_packet_alloc(xe);
if (!data)
return -ENOMEM;
ret = xe_sriov_packet_init(data, 0, 0, XE_SRIOV_PACKET_TYPE_DESCRIPTOR,
0, MIGRATION_DESCRIPTOR_DWORDS * sizeof(u32));
if (ret) {
xe_sriov_packet_free(data);
return ret;
}
klvs = data->vaddr;
klvs[len++] = PREP_GUC_KLV_CONST(MIGRATION_KLV_DEVICE_DEVID_KEY,
MIGRATION_KLV_DEVICE_DEVID_LEN);
klvs[len++] = xe->info.devid;
klvs[len++] = PREP_GUC_KLV_CONST(MIGRATION_KLV_DEVICE_REVID_KEY,
MIGRATION_KLV_DEVICE_REVID_LEN);
klvs[len++] = xe->info.revid;
xe_assert(xe, len == MIGRATION_DESCRIPTOR_DWORDS);
*desc = data;
return 0;
}
/**
* xe_sriov_packet_process_descriptor() - Process migration data descriptor packet.
* @xe: the &xe_device
* @vfid: the VF identifier
* @data: the &xe_sriov_packet containing the descriptor
*
* The descriptor uses the same KLV format as GuC, and contains metadata used for
* checking migration data compatibility.
*
* Return: 0 on success, -errno on failure.
*/
int xe_sriov_packet_process_descriptor(struct xe_device *xe, unsigned int vfid,
struct xe_sriov_packet *data)
{
u32 num_dwords = data->hdr.size / sizeof(u32);
u32 *klvs = data->vaddr;
xe_assert(xe, data->hdr.type == XE_SRIOV_PACKET_TYPE_DESCRIPTOR);
if (data->hdr.size % sizeof(u32)) {
xe_sriov_warn(xe, "Aborting migration, descriptor not in KLV format (size=%llu)\n",
data->hdr.size);
return -EINVAL;
}
while (num_dwords >= GUC_KLV_LEN_MIN) {
u32 key = FIELD_GET(GUC_KLV_0_KEY, klvs[0]);
u32 len = FIELD_GET(GUC_KLV_0_LEN, klvs[0]);
klvs += GUC_KLV_LEN_MIN;
num_dwords -= GUC_KLV_LEN_MIN;
if (len > num_dwords) {
xe_sriov_warn(xe, "Aborting migration, truncated KLV %#x, len %u\n",
key, len);
return -EINVAL;
Annotation
- Immediate include surface: `xe_bo.h`, `xe_device.h`, `xe_guc_klv_helpers.h`, `xe_sriov_packet.h`, `xe_sriov_packet_types.h`, `xe_sriov_pf_helpers.h`, `xe_sriov_pf_migration.h`, `xe_sriov_printk.h`.
- Detected declarations: `function pf_pick_descriptor`, `function pkt_needs_bo`, `function xe_sriov_packet_alloc`, `function xe_sriov_packet_free`, `function pkt_init`, `function xe_sriov_packet_init`, `function xe_sriov_packet_init_from_hdr`, `function pkt_hdr_read`, `function pkt_data_read`, `function pkt_read_single`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.