drivers/pci/search.c
Source file repositories/reference/linux-study-clean/drivers/pci/search.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/search.c- Extension
.c- Size
- 14864 bytes
- Lines
- 472
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/pci.hlinux/slab.hlinux/module.hlinux/interrupt.hpci.h
Detected Declarations
enum pci_search_directionfunction pci_for_each_dma_aliasfunction for_each_set_bitfunction numberfunction list_for_each_entryfunction pci_dev_putfunction list_for_each_entryfunction pci_dev_putfunction for_each_pci_devfunction match_pci_dev_by_idfunction pci_get_devicefunction pci_dev_presentexport pci_find_busexport pci_find_next_busexport pci_get_slotexport pci_get_domain_bus_and_slotexport pci_get_subsysexport pci_get_deviceexport pci_get_device_reverseexport pci_get_classexport pci_get_base_classexport pci_dev_present
Annotated Snippet
for_each_set_bit(devfn, pdev->dma_alias_mask, MAX_NR_DEVFNS) {
ret = fn(pdev, PCI_DEVID(pdev->bus->number, devfn),
data);
if (ret)
return ret;
}
}
for (bus = pdev->bus; !pci_is_root_bus(bus); bus = bus->parent) {
struct pci_dev *tmp;
/* Skip virtual buses */
if (!bus->self)
continue;
tmp = bus->self;
/* stop at bridge where translation unit is associated */
if (tmp->dev_flags & PCI_DEV_FLAGS_BRIDGE_XLATE_ROOT)
return ret;
/*
* PCIe-to-PCI/X bridges alias transactions from downstream
* devices using the subordinate bus number (PCI Express to
* PCI/PCI-X Bridge Spec, rev 1.0, sec 2.3). For all cases
* where the upstream bus is PCI/X we alias to the bridge
* (there are various conditions in the previous reference
* where the bridge may take ownership of transactions, even
* when the secondary interface is PCI-X).
*/
if (pci_is_pcie(tmp)) {
switch (pci_pcie_type(tmp)) {
case PCI_EXP_TYPE_ROOT_PORT:
case PCI_EXP_TYPE_UPSTREAM:
case PCI_EXP_TYPE_DOWNSTREAM:
continue;
case PCI_EXP_TYPE_PCI_BRIDGE:
if (tmp->dev_flags & PCI_DEV_FLAGS_PCI_BRIDGE_NO_ALIAS)
continue;
ret = fn(tmp,
PCI_DEVID(tmp->subordinate->number,
PCI_DEVFN(0, 0)), data);
if (ret)
return ret;
continue;
case PCI_EXP_TYPE_PCIE_BRIDGE:
ret = fn(tmp, pci_dev_id(tmp), data);
if (ret)
return ret;
continue;
}
} else {
if (tmp->dev_flags & PCI_DEV_FLAG_PCIE_BRIDGE_ALIAS)
ret = fn(tmp,
PCI_DEVID(tmp->subordinate->number,
PCI_DEVFN(0, 0)), data);
else
ret = fn(tmp, pci_dev_id(tmp), data);
if (ret)
return ret;
}
}
return ret;
}
static struct pci_bus *pci_do_find_bus(struct pci_bus *bus, unsigned char busnr)
{
struct pci_bus *child;
struct pci_bus *tmp;
if (bus->number == busnr)
return bus;
list_for_each_entry(tmp, &bus->children, node) {
child = pci_do_find_bus(tmp, busnr);
if (child)
return child;
}
return NULL;
}
/**
* pci_find_bus - locate PCI bus from a given domain and bus number
* @domain: number of PCI domain to search
* @busnr: number of desired PCI bus
*
* Given a PCI bus number and domain number, the desired PCI bus is located
* in the global list of PCI buses. If the bus is found, a pointer to its
* data structure is returned. If no bus is found, %NULL is returned.
Annotation
- Immediate include surface: `linux/pci.h`, `linux/slab.h`, `linux/module.h`, `linux/interrupt.h`, `pci.h`.
- Detected declarations: `enum pci_search_direction`, `function pci_for_each_dma_alias`, `function for_each_set_bit`, `function number`, `function list_for_each_entry`, `function pci_dev_put`, `function list_for_each_entry`, `function pci_dev_put`, `function for_each_pci_dev`, `function match_pci_dev_by_id`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: integration 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.