drivers/gpu/drm/xe/xe_configfs.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_configfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_configfs.c- Extension
.c- Size
- 35549 bytes
- Lines
- 1354
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
linux/bitops.hlinux/ctype.hlinux/configfs.hlinux/cleanup.hlinux/find.hlinux/init.hlinux/module.hlinux/pci.hlinux/string.hinstructions/xe_mi_commands.hxe_configfs.hxe_defaults.hxe_gt_types.hxe_hw_engine_types.hxe_module.hxe_pci_types.hxe_sriov_types.h
Detected Declarations
struct wa_bbstruct xe_config_group_devicestruct xe_config_devicestruct engine_infofunction set_device_defaultsfunction is_boundfunction survivability_mode_showfunction survivability_mode_storefunction gt_types_allowed_showfunction gt_types_allowed_storefunction engines_allowed_showfunction parse_enginefunction engines_allowed_storefunction enable_psmi_showfunction enable_psmi_storefunction wa_bb_read_advancefunction wa_bb_showfunction ctx_restore_mid_bb_showfunction ctx_restore_post_bb_showfunction wa_bb_appendfunction parse_hexfunction parse_wa_bb_linesfunction wa_bb_storefunction ctx_restore_mid_bb_storefunction ctx_restore_post_bb_storefunction xe_config_device_releasefunction xe_config_device_is_visiblefunction sriov_max_vfs_showfunction sriov_max_vfs_storefunction sriov_admin_only_pf_showfunction sriov_admin_only_pf_storefunction xe_config_sriov_is_visiblefunction dump_custom_dev_configfunction xe_configfs_check_devicefunction xe_configfs_get_survivability_modefunction get_gt_types_allowedfunction xe_configfs_primary_gt_allowedfunction xe_configfs_media_gt_allowedfunction xe_configfs_get_engines_allowedfunction xe_configfs_get_psmi_enabledfunction xe_configfs_get_ctx_restore_mid_bbfunction xe_configfs_get_ctx_restore_post_bbfunction xe_configfs_admin_only_pffunction xe_configfs_get_max_vfsfunction xe_configfs_initfunction xe_configfs_exit
Annotated Snippet
struct device_driver *driver = driver_find("xe", &pci_bus_type);
struct pci_driver *drv = to_pci_driver(driver);
const struct pci_device_id *ids = drv ? drv->id_table : NULL;
const struct pci_device_id *found = pci_match_id(ids, pdev);
return found ? (const void *)found->driver_data : NULL;
}
static struct pci_dev *get_physfn_instead(struct pci_dev *virtfn)
{
struct pci_dev *physfn = pci_physfn(virtfn);
pci_dev_get(physfn);
pci_dev_put(virtfn);
return physfn;
}
static struct config_group *xe_config_make_device_group(struct config_group *group,
const char *name)
{
unsigned int domain, bus, slot, function;
struct xe_config_group_device *dev;
const struct xe_device_desc *match;
enum xe_sriov_mode mode;
struct pci_dev *pdev;
char canonical[16];
int vfnumber = 0;
int ret;
ret = sscanf(name, "%x:%x:%x.%x", &domain, &bus, &slot, &function);
if (ret != 4)
return ERR_PTR(-EINVAL);
ret = scnprintf(canonical, sizeof(canonical), "%04x:%02x:%02x.%d", domain, bus,
PCI_SLOT(PCI_DEVFN(slot, function)),
PCI_FUNC(PCI_DEVFN(slot, function)));
if (ret != 12 || strcmp(name, canonical))
return ERR_PTR(-EINVAL);
pdev = pci_get_domain_bus_and_slot(domain, bus, PCI_DEVFN(slot, function));
mode = pdev ? dev_is_pf(&pdev->dev) ?
XE_SRIOV_MODE_PF : XE_SRIOV_MODE_NONE : XE_SRIOV_MODE_VF;
if (!pdev && function)
pdev = pci_get_domain_bus_and_slot(domain, bus, PCI_DEVFN(slot, 0));
if (!pdev && slot)
pdev = pci_get_domain_bus_and_slot(domain, bus, PCI_DEVFN(0, 0));
if (!pdev)
return ERR_PTR(-ENODEV);
if (PCI_DEVFN(slot, function) != pdev->devfn) {
pdev = get_physfn_instead(pdev);
vfnumber = PCI_DEVFN(slot, function) - pdev->devfn;
if (!dev_is_pf(&pdev->dev) || vfnumber > pci_sriov_get_totalvfs(pdev)) {
pci_dev_put(pdev);
return ERR_PTR(-ENODEV);
}
}
match = xe_match_desc(pdev);
if (match && vfnumber && !match->has_sriov) {
pci_info(pdev, "xe driver does not support VFs on this device\n");
match = NULL;
} else if (!match) {
pci_info(pdev, "xe driver does not support configuration of this device\n");
}
pci_dev_put(pdev);
if (!match)
return ERR_PTR(-ENOENT);
dev = kzalloc_obj(*dev);
if (!dev)
return ERR_PTR(-ENOMEM);
dev->desc = match;
dev->mode = match->has_sriov ? mode : XE_SRIOV_MODE_NONE;
set_device_defaults(&dev->config);
config_group_init_type_name(&dev->group, name, &xe_config_device_type);
if (dev->mode != XE_SRIOV_MODE_NONE) {
config_group_init_type_name(&dev->sriov, "sriov", &xe_config_sriov_type);
configfs_add_default_group(&dev->sriov, &dev->group);
}
mutex_init(&dev->lock);
return &dev->group;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/ctype.h`, `linux/configfs.h`, `linux/cleanup.h`, `linux/find.h`, `linux/init.h`, `linux/module.h`, `linux/pci.h`.
- Detected declarations: `struct wa_bb`, `struct xe_config_group_device`, `struct xe_config_device`, `struct engine_info`, `function set_device_defaults`, `function is_bound`, `function survivability_mode_show`, `function survivability_mode_store`, `function gt_types_allowed_show`, `function gt_types_allowed_store`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.