drivers/gpu/drm/xe/xe_sriov_pf.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_sriov_pf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_sriov_pf.c- Extension
.c- Size
- 7160 bytes
- Lines
- 284
- 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
linux/debugfs.hdrm/drm_debugfs.hdrm/drm_managed.hxe_assert.hxe_configfs.hxe_device.hxe_gt_sriov_pf.hxe_module.hxe_sriov.hxe_sriov_pf.hxe_sriov_pf_helpers.hxe_sriov_pf_migration.hxe_sriov_pf_service.hxe_sriov_pf_sysfs.hxe_sriov_printk.h
Detected Declarations
function wanted_max_vfsfunction pf_reduce_totalvfsfunction pf_continue_as_nativefunction xe_sriov_pf_readinessfunction xe_sriov_pf_init_earlyfunction xe_sriov_pf_init_latefunction for_each_gtfunction xe_sriov_pf_wait_readyfunction for_each_gtfunction xe_sriov_pf_arm_guardfunction xe_sriov_pf_disarm_guardfunction xe_sriov_pf_lockdownfunction xe_sriov_pf_end_lockdownfunction xe_sriov_pf_print_vfs_summary
Annotated Snippet
// SPDX-License-Identifier: MIT
/*
* Copyright © 2023-2024 Intel Corporation
*/
#include <linux/debugfs.h>
#include <drm/drm_debugfs.h>
#include <drm/drm_managed.h>
#include "xe_assert.h"
#include "xe_configfs.h"
#include "xe_device.h"
#include "xe_gt_sriov_pf.h"
#include "xe_module.h"
#include "xe_sriov.h"
#include "xe_sriov_pf.h"
#include "xe_sriov_pf_helpers.h"
#include "xe_sriov_pf_migration.h"
#include "xe_sriov_pf_service.h"
#include "xe_sriov_pf_sysfs.h"
#include "xe_sriov_printk.h"
static unsigned int wanted_max_vfs(struct xe_device *xe)
{
return xe_configfs_get_max_vfs(to_pci_dev(xe->drm.dev));
}
static int pf_reduce_totalvfs(struct xe_device *xe, int limit)
{
struct device *dev = xe->drm.dev;
struct pci_dev *pdev = to_pci_dev(dev);
int err;
err = pci_sriov_set_totalvfs(pdev, limit);
if (err)
xe_sriov_notice(xe, "Failed to set number of VFs to %d (%pe)\n",
limit, ERR_PTR(err));
return err;
}
static bool pf_continue_as_native(struct xe_device *xe, const char *why)
{
xe_sriov_dbg(xe, "%s, continuing as native\n", why);
pf_reduce_totalvfs(xe, 0);
return false;
}
/**
* xe_sriov_pf_readiness - Check if PF functionality can be enabled.
* @xe: the &xe_device to check
*
* This function is called as part of the SR-IOV probe to validate if all
* PF prerequisites are satisfied and we can continue with enabling PF mode.
*
* Return: true if the PF mode can be turned on.
*/
bool xe_sriov_pf_readiness(struct xe_device *xe)
{
struct device *dev = xe->drm.dev;
struct pci_dev *pdev = to_pci_dev(dev);
int totalvfs = pci_sriov_get_totalvfs(pdev);
int newlimit = min_t(u16, wanted_max_vfs(xe), totalvfs);
xe_assert(xe, totalvfs <= U16_MAX);
if (!dev_is_pf(dev))
return false;
if (!xe_device_uc_enabled(xe))
return pf_continue_as_native(xe, "Guc submission disabled");
if (!newlimit)
return pf_continue_as_native(xe, "all VFs disabled");
pf_reduce_totalvfs(xe, newlimit);
xe->sriov.pf.device_total_vfs = totalvfs;
xe->sriov.pf.driver_max_vfs = newlimit;
return true;
}
/**
* xe_sriov_pf_init_early - Initialize SR-IOV PF specific data.
* @xe: the &xe_device to initialize
*
* Return: 0 on success or a negative error code on failure.
*/
int xe_sriov_pf_init_early(struct xe_device *xe)
{
Annotation
- Immediate include surface: `linux/debugfs.h`, `drm/drm_debugfs.h`, `drm/drm_managed.h`, `xe_assert.h`, `xe_configfs.h`, `xe_device.h`, `xe_gt_sriov_pf.h`, `xe_module.h`.
- Detected declarations: `function wanted_max_vfs`, `function pf_reduce_totalvfs`, `function pf_continue_as_native`, `function xe_sriov_pf_readiness`, `function xe_sriov_pf_init_early`, `function xe_sriov_pf_init_late`, `function for_each_gt`, `function xe_sriov_pf_wait_ready`, `function for_each_gt`, `function xe_sriov_pf_arm_guard`.
- 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.