drivers/vfio/pci/vfio_pci.c
Source file repositories/reference/linux-study-clean/drivers/vfio/pci/vfio_pci.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/vfio/pci/vfio_pci.c- Extension
.c- Size
- 8139 bytes
- Lines
- 290
- Domain
- Driver Families
- Bucket
- drivers/vfio
- 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/device.hlinux/eventfd.hlinux/file.hlinux/interrupt.hlinux/iommu.hlinux/module.hlinux/mutex.hlinux/notifier.hlinux/pm_runtime.hlinux/slab.hlinux/types.hlinux/uaccess.hvfio_pci_priv.h
Detected Declarations
function vfio_pci_dev_in_denylistfunction vfio_pci_is_denylistedfunction vfio_pci_open_devicefunction vfio_pci_probefunction vfio_pci_removefunction vfio_pci_sriov_configurefunction vfio_pci_fill_idsfunction vfio_pci_initfunction vfio_pci_cleanupmodule init vfio_pci_init
Annotated Snippet
static struct pci_driver vfio_pci_driver = {
.name = "vfio-pci",
.id_table = vfio_pci_table,
.probe = vfio_pci_probe,
.remove = vfio_pci_remove,
.sriov_configure = vfio_pci_sriov_configure,
.err_handler = &vfio_pci_core_err_handlers,
.driver_managed_dma = true,
};
static void __init vfio_pci_fill_ids(void)
{
char *p, *id;
int rc;
/* no ids passed actually */
if (ids[0] == '\0')
return;
/* add ids specified in the module parameter */
p = ids;
while ((id = strsep(&p, ","))) {
unsigned int vendor, device, subvendor = PCI_ANY_ID,
subdevice = PCI_ANY_ID, class = 0, class_mask = 0;
int fields;
if (!strlen(id))
continue;
fields = sscanf(id, "%x:%x:%x:%x:%x:%x",
&vendor, &device, &subvendor, &subdevice,
&class, &class_mask);
if (fields < 2) {
pr_warn("invalid id string \"%s\"\n", id);
continue;
}
rc = pci_add_dynid(&vfio_pci_driver, vendor, device,
subvendor, subdevice, class, class_mask, 0);
if (rc)
pr_warn("failed to add dynamic id [%04x:%04x[%04x:%04x]] class %#08x/%08x (%d)\n",
vendor, device, subvendor, subdevice,
class, class_mask, rc);
else
pr_info("add [%04x:%04x[%04x:%04x]] class %#08x/%08x\n",
vendor, device, subvendor, subdevice,
class, class_mask);
}
}
static int __init vfio_pci_init(void)
{
int ret;
bool is_disable_vga = true;
#ifdef CONFIG_VFIO_PCI_VGA
is_disable_vga = disable_vga;
#endif
vfio_pci_core_set_params(nointxmask, is_disable_vga, disable_idle_d3);
/* Register and scan for devices */
ret = pci_register_driver(&vfio_pci_driver);
if (ret)
return ret;
vfio_pci_fill_ids();
if (disable_denylist)
pr_warn("device denylist disabled.\n");
return 0;
}
module_init(vfio_pci_init);
static void __exit vfio_pci_cleanup(void)
{
pci_unregister_driver(&vfio_pci_driver);
}
module_exit(vfio_pci_cleanup);
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
Annotation
- Immediate include surface: `linux/device.h`, `linux/eventfd.h`, `linux/file.h`, `linux/interrupt.h`, `linux/iommu.h`, `linux/module.h`, `linux/mutex.h`, `linux/notifier.h`.
- Detected declarations: `function vfio_pci_dev_in_denylist`, `function vfio_pci_is_denylisted`, `function vfio_pci_open_device`, `function vfio_pci_probe`, `function vfio_pci_remove`, `function vfio_pci_sriov_configure`, `function vfio_pci_fill_ids`, `function vfio_pci_init`, `function vfio_pci_cleanup`, `module init vfio_pci_init`.
- Atlas domain: Driver Families / drivers/vfio.
- 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.