On this page
PCIe and USB Driver Model
Coverage: PCIe enumeration (BAR/MMIO/MSI) → pci_driver → USB protocol stack (URB/endpoint) → usb_driver → hotplug → power management Kernel version: 2.6 ~ 6.x
PCIe
Bus Enumeration
pci_dev
// include/linux/pci.h
;
pci_driver
;
// Registration: pci_register_driver(&mydrv)
// Binding: PCI bus enumeration → match vendor:device → probe()
MSI/MSI-X
// Message-based interrupts replacing INTx line interrupts:
// MSI: Single vector or a small number of vectors
// MSI-X: Up to 2048 independent vectors
// Allocation:
int nvec = ;
// → 16 MSI-X vectors → pci_irq_vector(pdev, i) to get Linux IRQ number
// Each vector has independent affinity → can be bound to different CPUs
// NVMe: One MSI-X per IO queue → parallel interrupt processing
USB
USB Protocol Stack
// drivers/usb/core/
// Layered architecture:
// USB Core (usbcore): Protocol implementation, URB management
// Host Controller Driver (HCD): xHCI, EHCI, OHCI
// Device Driver: usb_driver (e.g., usb-storage, usbhid)
// Descriptor hierarchy for USB devices:
// Device Descriptor → Config Descriptor → Interface Descriptor → Endpoint Descriptor
// One USB device: 1 device, N configs, M interfaces, K endpoints
// Endpoint types:
// Control: setup packet (configuration commands)
// Bulk: Large data transfers (storage, printers)
// Interrupt: Periodic polling (HID: keyboard/mouse)
// Isochronous: Real-time streaming (audio/video, no retransmission)
URB (USB Request Block)
// include/linux/usb.h
;
usb_driver
;
Key: The object passed to probe is usb_interface, not usb_device—because a USB device can have multiple interfaces (e.g., webcam: video interface + audio interface), and different interfaces can bind to different drivers.
Hotplug
References
- Source Code:
drivers/pci/,drivers/usb/core/,include/linux/pci.h,include/linux/usb.h - Kernel Documentation:
Documentation/PCI/,Documentation/driver-api/usb/ - LWN: "The PCI subsystem", "USB in the Linux kernel"
Keywords: PCIe, BAR, MSI-X, pci_driver, USB, URB, endpoint, usb_driver, hotplug, udev