drivers/gpu/drm/xe/xe_pci_sriov.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_pci_sriov.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_pci_sriov.c- Extension
.c- Size
- 6897 bytes
- Lines
- 265
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitops.hlinux/pci.hregs/xe_bars.hxe_assert.hxe_device.hxe_gt_sriov_pf_config.hxe_gt_sriov_pf_control.hxe_gt_sriov_printk.hxe_guc_engine_activity.hxe_pci_sriov.hxe_pm.hxe_sriov.hxe_sriov_pf.hxe_sriov_pf_control.hxe_sriov_pf_helpers.hxe_sriov_pf_provision.hxe_sriov_pf_sysfs.hxe_sriov_printk.h
Detected Declarations
function pf_reset_vfsfunction pf_link_vfsfunction pf_engine_activity_statsfunction for_each_gtfunction resize_vf_vram_barfunction pf_prepare_vfs_enablingfunction pf_finish_vfs_enablingfunction pf_enable_vfsfunction pf_disable_vfsfunction Functionsfunction xe_pci_sriov_get_vf_pdev
Annotated Snippet
* This is the Xe implementation of struct pci_driver.sriov_configure callback.
*
* This callback will be called by the PCI subsystem to enable or disable SR-IOV
* Virtual Functions (VFs) as requested by the used via the PCI sysfs interface.
*
* Return: number of configured VFs or a negative error code on failure.
*/
int xe_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)
{
struct xe_device *xe = pdev_to_xe_device(pdev);
if (!IS_SRIOV_PF(xe))
return -ENODEV;
if (num_vfs < 0)
return -EINVAL;
if (num_vfs > xe_sriov_pf_get_totalvfs(xe))
return -ERANGE;
if (num_vfs && pci_num_vf(pdev))
return -EBUSY;
guard(xe_pm_runtime)(xe);
if (num_vfs > 0)
return pf_enable_vfs(xe, num_vfs);
else
return pf_disable_vfs(xe);
}
/**
* xe_pci_sriov_get_vf_pdev() - Lookup the VF's PCI device using the VF identifier.
* @pdev: the PF's &pci_dev
* @vfid: VF identifier (1-based)
*
* The caller must decrement the reference count by calling pci_dev_put().
*
* Return: the VF's &pci_dev or NULL if the VF device was not found.
*/
struct pci_dev *xe_pci_sriov_get_vf_pdev(struct pci_dev *pdev, unsigned int vfid)
{
struct xe_device *xe = pdev_to_xe_device(pdev);
xe_assert(xe, dev_is_pf(&pdev->dev));
xe_assert(xe, vfid);
xe_assert(xe, vfid <= pci_sriov_get_totalvfs(pdev));
return pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
pdev->bus->number,
pci_iov_virtfn_devfn(pdev, vfid - 1));
}
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/pci.h`, `regs/xe_bars.h`, `xe_assert.h`, `xe_device.h`, `xe_gt_sriov_pf_config.h`, `xe_gt_sriov_pf_control.h`, `xe_gt_sriov_printk.h`.
- Detected declarations: `function pf_reset_vfs`, `function pf_link_vfs`, `function pf_engine_activity_stats`, `function for_each_gt`, `function resize_vf_vram_bar`, `function pf_prepare_vfs_enabling`, `function pf_finish_vfs_enabling`, `function pf_enable_vfs`, `function pf_disable_vfs`, `function Functions`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: pattern 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.