drivers/pci/pcie/portdrv.c
Source file repositories/reference/linux-study-clean/drivers/pci/pcie/portdrv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/pcie/portdrv.c- Extension
.c- Size
- 23066 bytes
- Lines
- 850
- 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 IRQ or DMA behavior; this matters for the representative real-device path.
- 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/bitfield.hlinux/dmi.hlinux/init.hlinux/module.hlinux/pci.hlinux/kernel.hlinux/errno.hlinux/pm.hlinux/pm_runtime.hlinux/string.hlinux/slab.hlinux/aer.h../pci.hportdrv.h
Detected Declarations
struct portdrv_service_datafunction device_unregisterfunction pcie_message_numbersfunction pcie_port_enable_irq_vecfunction pci_irq_vectorfunction pcie_init_service_irqsfunction get_port_device_capabilityfunction pci_pcie_typefunction pci_pcie_typefunction pcie_device_initfunction pcie_port_device_registerfunction pcie_port_device_iterfunction pcie_port_device_suspendfunction pcie_port_device_resume_noirqfunction pcie_port_device_resumefunction pcie_port_device_runtime_suspendfunction pcie_port_device_runtime_resumefunction remove_iterfunction find_service_iterfunction pcie_port_device_removefunction pcie_port_bus_matchfunction pcie_port_service_registerfunction pcie_port_service_registerfunction pcie_port_service_registerfunction pcie_port_service_unregisterfunction pcie_port_setupfunction pcie_port_runtime_suspendfunction pcie_port_runtime_idlefunction pcie_port_device_registerfunction pcie_portdrv_removefunction pcie_portdrv_shutdownfunction pcie_portdrv_error_detectedfunction pcie_portdrv_slot_resetfunction pcie_portdrv_mmio_enabledfunction dmi_pcie_pme_disable_msifunction pcie_init_servicesfunction pcie_portdrv_initmodule init pcie_portdrv_initexport pcie_port_find_device
Annotated Snippet
static int pcie_port_bus_match(struct device *dev, const struct device_driver *drv)
{
struct pcie_device *pciedev = to_pcie_device(dev);
const struct pcie_port_service_driver *driver = to_service_driver(drv);
if (driver->service != pciedev->service)
return 0;
if (driver->port_type != PCIE_ANY_PORT &&
driver->port_type != pci_pcie_type(pciedev->port))
return 0;
return 1;
}
/**
* pcie_port_bus_probe - probe driver for given PCI Express port service
* @dev: PCI Express port service device to probe against
*
* If PCI Express port service driver is registered with
* pcie_port_service_register(), this function will be called by the driver core
* whenever match is found between the driver and a port service device.
*/
static int pcie_port_bus_probe(struct device *dev)
{
struct pcie_device *pciedev;
struct pcie_port_service_driver *driver;
int status;
driver = to_service_driver(dev->driver);
if (!driver || !driver->probe)
return -ENODEV;
pciedev = to_pcie_device(dev);
status = driver->probe(pciedev);
if (status)
return status;
get_device(dev);
return 0;
}
/**
* pcie_port_bus_remove - detach driver from given PCI Express port service
* @dev: PCI Express port service device to handle
*
* If PCI Express port service driver is registered with
* pcie_port_service_register(), this function will be called by the driver core
* when device_unregister() is called for the port service device associated
* with the driver.
*/
static void pcie_port_bus_remove(struct device *dev)
{
struct pcie_device *pciedev;
struct pcie_port_service_driver *driver;
pciedev = to_pcie_device(dev);
driver = to_service_driver(dev->driver);
if (driver && driver->remove)
driver->remove(pciedev);
put_device(dev);
}
const struct bus_type pcie_port_bus_type = {
.name = "pci_express",
.match = pcie_port_bus_match,
.probe = pcie_port_bus_probe,
.remove = pcie_port_bus_remove,
};
/**
* pcie_port_service_register - register PCI Express port service driver
* @new: PCI Express port service driver to register
*/
int pcie_port_service_register(struct pcie_port_service_driver *new)
{
if (pcie_ports_disabled)
return -ENODEV;
new->driver.name = new->name;
new->driver.bus = &pcie_port_bus_type;
return driver_register(&new->driver);
}
/**
* pcie_port_service_unregister - unregister PCI Express port service driver
* @drv: PCI Express port service driver to unregister
*/
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/dmi.h`, `linux/init.h`, `linux/module.h`, `linux/pci.h`, `linux/kernel.h`, `linux/errno.h`, `linux/pm.h`.
- Detected declarations: `struct portdrv_service_data`, `function device_unregister`, `function pcie_message_numbers`, `function pcie_port_enable_irq_vec`, `function pci_irq_vector`, `function pcie_init_service_irqs`, `function get_port_device_capability`, `function pci_pcie_type`, `function pci_pcie_type`, `function pcie_device_init`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: pattern implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.