drivers/gpu/drm/xe/xe_gt_sriov_pf.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_gt_sriov_pf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_gt_sriov_pf.c- Extension
.c- Size
- 7131 bytes
- Lines
- 305
- 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.hregs/xe_guc_regs.hregs/xe_regs.hxe_gt.hxe_gt_sriov_pf.hxe_gt_sriov_pf_config.hxe_gt_sriov_pf_control.hxe_gt_sriov_pf_helpers.hxe_gt_sriov_pf_migration.hxe_gt_sriov_pf_policy.hxe_gt_sriov_pf_service.hxe_gt_sriov_printk.hxe_guc_submit.hxe_mmio.hxe_pm.h
Detected Declarations
function pf_alloc_metadatafunction pf_init_workersfunction pf_fini_workersfunction xe_gt_sriov_pf_init_earlyfunction pf_fini_actionfunction pf_init_latefunction xe_gt_sriov_pf_initfunction pf_needs_enable_ggtt_guest_updatefunction pf_enable_ggtt_guest_updatefunction xe_gt_sriov_pf_init_hwfunction pf_clear_vf_scratch_regsfunction xe_gt_sriov_pf_sanitize_hwfunction pf_cancel_restartfunction xe_gt_sriov_pf_stop_preparefunction pf_restartfunction pf_worker_restart_funcfunction pf_queue_restartfunction xe_gt_sriov_pf_restartfunction pf_flush_restartfunction xe_gt_sriov_pf_wait_readyfunction xe_gt_sriov_pf_sched_groups_enabled
Annotated Snippet
// SPDX-License-Identifier: MIT
/*
* Copyright © 2023-2024 Intel Corporation
*/
#include <drm/drm_managed.h>
#include "regs/xe_guc_regs.h"
#include "regs/xe_regs.h"
#include "xe_gt.h"
#include "xe_gt_sriov_pf.h"
#include "xe_gt_sriov_pf_config.h"
#include "xe_gt_sriov_pf_control.h"
#include "xe_gt_sriov_pf_helpers.h"
#include "xe_gt_sriov_pf_migration.h"
#include "xe_gt_sriov_pf_policy.h"
#include "xe_gt_sriov_pf_service.h"
#include "xe_gt_sriov_printk.h"
#include "xe_guc_submit.h"
#include "xe_mmio.h"
#include "xe_pm.h"
static void pf_worker_restart_func(struct work_struct *w);
/*
* VF's metadata is maintained in the flexible array where:
* - entry [0] contains metadata for the PF (only if applicable),
* - entries [1..n] contain metadata for VF1..VFn::
*
* <--------------------------- 1 + total_vfs ----------->
* +-------+-------+-------+-----------------------+-------+
* | 0 | 1 | 2 | | n |
* +-------+-------+-------+-----------------------+-------+
* | PF | VF1 | VF2 | ... ... | VFn |
* +-------+-------+-------+-----------------------+-------+
*/
static int pf_alloc_metadata(struct xe_gt *gt)
{
unsigned int num_vfs = xe_gt_sriov_pf_get_totalvfs(gt);
gt->sriov.pf.vfs = drmm_kcalloc(>_to_xe(gt)->drm, 1 + num_vfs,
sizeof(*gt->sriov.pf.vfs), GFP_KERNEL);
if (!gt->sriov.pf.vfs)
return -ENOMEM;
return 0;
}
static void pf_init_workers(struct xe_gt *gt)
{
xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
INIT_WORK(>->sriov.pf.workers.restart, pf_worker_restart_func);
}
static void pf_fini_workers(struct xe_gt *gt)
{
xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt)));
if (disable_work_sync(>->sriov.pf.workers.restart)) {
xe_gt_sriov_dbg_verbose(gt, "pending restart disabled!\n");
/* release an rpm reference taken on the worker's behalf */
xe_pm_runtime_put(gt_to_xe(gt));
}
}
/**
* xe_gt_sriov_pf_init_early - Prepare SR-IOV PF data structures on PF.
* @gt: the &xe_gt to initialize
*
* Early initialization of the PF data.
*
* Return: 0 on success or a negative error code on failure.
*/
int xe_gt_sriov_pf_init_early(struct xe_gt *gt)
{
int err;
err = pf_alloc_metadata(gt);
if (err)
return err;
err = xe_gt_sriov_pf_service_init(gt);
if (err)
return err;
err = xe_gt_sriov_pf_control_init(gt);
if (err)
return err;
Annotation
- Immediate include surface: `drm/drm_managed.h`, `regs/xe_guc_regs.h`, `regs/xe_regs.h`, `xe_gt.h`, `xe_gt_sriov_pf.h`, `xe_gt_sriov_pf_config.h`, `xe_gt_sriov_pf_control.h`, `xe_gt_sriov_pf_helpers.h`.
- Detected declarations: `function pf_alloc_metadata`, `function pf_init_workers`, `function pf_fini_workers`, `function xe_gt_sriov_pf_init_early`, `function pf_fini_action`, `function pf_init_late`, `function xe_gt_sriov_pf_init`, `function pf_needs_enable_ggtt_guest_update`, `function pf_enable_ggtt_guest_update`, `function xe_gt_sriov_pf_init_hw`.
- 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.