drivers/pci/vgaarb.c
Source file repositories/reference/linux-study-clean/drivers/pci/vgaarb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/vgaarb.c- Extension
.c- Size
- 42050 bytes
- Lines
- 1546
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/module.hlinux/kernel.hlinux/pci.hlinux/errno.hlinux/init.hlinux/list.hlinux/sched/signal.hlinux/wait.hlinux/spinlock.hlinux/poll.hlinux/miscdevice.hlinux/slab.hlinux/sysfb.hlinux/vt.hlinux/console.hlinux/acpi.hlinux/uaccess.hlinux/vgaarb.h
Detected Declarations
struct vga_devicestruct vga_arb_user_cardstruct vga_arb_privatefunction vga_str_to_iostatefunction vga_set_default_devicefunction vga_remove_vgaconfunction vga_remove_vgaconfunction vga_remove_vgaconfunction vga_check_first_usefunction __vga_putfunction cardfunction vga_getfunction vga_getfunction vga_is_firmware_defaultfunction vga_arb_integrated_gpufunction vga_is_boot_devicefunction vga_arbiter_check_bridge_sharingfunction list_for_each_entryfunction vga_arbiter_add_pci_devicefunction vga_arbiter_del_pci_devicefunction vga_update_device_decodesfunction __vga_set_legacy_decodingfunction processfunction vga_client_registerfunction vga_pci_str_to_varsfunction vga_arb_readfunction vga_arb_writefunction vga_arb_fpollfunction vga_arb_openfunction vga_arb_releasefunction vga_arbiter_notify_clientsfunction pci_notifyfunction vga_arb_device_initfunction pci_get_subsysexport vga_default_deviceexport vga_remove_vgaconexport vga_getexport vga_putexport vga_set_legacy_decodingexport vga_client_register
Annotated Snippet
static const struct file_operations vga_arb_device_fops = {
.read = vga_arb_read,
.write = vga_arb_write,
.poll = vga_arb_fpoll,
.open = vga_arb_open,
.release = vga_arb_release,
.llseek = noop_llseek,
};
static struct miscdevice vga_arb_device = {
MISC_DYNAMIC_MINOR, "vga_arbiter", &vga_arb_device_fops
};
static int __init vga_arb_device_init(void)
{
int rc;
struct pci_dev *pdev;
rc = misc_register(&vga_arb_device);
if (rc < 0)
pr_err("error %d registering device\n", rc);
bus_register_notifier(&pci_bus_type, &pci_notifier);
/* Add all VGA class PCI devices by default */
pdev = NULL;
while ((pdev =
pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
PCI_ANY_ID, pdev)) != NULL) {
if (pci_is_vga(pdev))
vga_arbiter_add_pci_device(pdev);
}
pr_info("loaded\n");
return rc;
}
subsys_initcall_sync(vga_arb_device_init);
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/pci.h`, `linux/errno.h`, `linux/init.h`, `linux/list.h`, `linux/sched/signal.h`, `linux/wait.h`.
- Detected declarations: `struct vga_device`, `struct vga_arb_user_card`, `struct vga_arb_private`, `function vga_str_to_iostate`, `function vga_set_default_device`, `function vga_remove_vgacon`, `function vga_remove_vgacon`, `function vga_remove_vgacon`, `function vga_check_first_use`, `function __vga_put`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.