drivers/pci/setup-bus.c
Source file repositories/reference/linux-study-clean/drivers/pci/setup-bus.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/setup-bus.c- Extension
.c- Size
- 64269 bytes
- Lines
- 2480
- 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.
- 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/align.hlinux/bitops.hlinux/bug.hlinux/init.hlinux/kernel.hlinux/minmax.hlinux/module.hlinux/pci.hlinux/errno.hlinux/ioport.hlinux/cache.hlinux/limits.hlinux/sizes.hlinux/slab.hlinux/acpi.hpci.h
Detected Declarations
struct pci_dev_resourceenum release_typeenum enable_typefunction pci_dev_res_free_listfunction list_for_each_entry_safefunction pci_dev_res_add_to_listfunction pci_dev_res_remove_from_listfunction list_for_each_entry_safefunction list_for_each_entryfunction get_res_add_sizefunction pci_dev_res_restorefunction pci_bus_for_each_resourcefunction pdev_resources_assignablefunction pdev_resource_assignablefunction pdev_resource_should_fitfunction pdev_sort_resourcesfunction pci_dev_for_each_resourcefunction list_for_each_entryfunction pci_resource_is_optionalfunction reset_resourcefunction reassign_resources_sortedfunction list_for_each_entry_safefunction assign_requested_resources_sortedfunction list_for_each_entryfunction pci_fail_res_type_maskfunction pci_need_to_releasefunction pci_required_resource_failedfunction list_for_each_entryfunction __assign_resources_sortedfunction list_for_each_entryfunction list_emptyfunction pdev_assign_resources_sortedfunction pbus_assign_resources_sortedfunction addressfunction pci_setup_bridge_mmiofunction pci_setup_bridge_mmio_preffunction __pci_setup_bridgefunction pci_setup_one_bridge_windowfunction pcibios_setup_bridgefunction pci_claim_bridge_resourcefunction pci_bridge_check_rangesfunction calculate_iosizefunction calculate_memsizefunction pcibios_window_alignmentfunction pci_min_window_alignmentfunction pbus_size_iofunction pci_dev_for_each_resourcefunction calculate_mem_align
Annotated Snippet
struct pci_dev_resource {
struct list_head list;
struct resource *res;
struct pci_dev *dev;
resource_size_t start;
resource_size_t end;
resource_size_t add_size;
resource_size_t min_align;
unsigned long flags;
};
static void pci_dev_res_free_list(struct list_head *head)
{
struct pci_dev_resource *dev_res, *tmp;
list_for_each_entry_safe(dev_res, tmp, head, list) {
list_del(&dev_res->list);
kfree(dev_res);
}
}
/**
* pci_dev_res_add_to_list() - Add a new resource tracker to the list
* @head: Head of the list
* @dev: Device to which the resource belongs
* @res: Resource to be tracked
* @add_size: Additional size to be optionally added to the resource
* @min_align: Minimum memory window alignment
*/
int pci_dev_res_add_to_list(struct list_head *head, struct pci_dev *dev,
struct resource *res, resource_size_t add_size,
resource_size_t min_align)
{
struct pci_dev_resource *tmp;
tmp = kzalloc_obj(*tmp);
if (!tmp)
return -ENOMEM;
tmp->res = res;
tmp->dev = dev;
tmp->start = res->start;
tmp->end = res->end;
tmp->flags = res->flags;
tmp->add_size = add_size;
tmp->min_align = min_align;
list_add(&tmp->list, head);
return 0;
}
static void pci_dev_res_remove_from_list(struct list_head *head,
struct resource *res)
{
struct pci_dev_resource *dev_res, *tmp;
list_for_each_entry_safe(dev_res, tmp, head, list) {
if (dev_res->res == res) {
list_del(&dev_res->list);
kfree(dev_res);
break;
}
}
}
static struct pci_dev_resource *res_to_dev_res(struct list_head *head,
struct resource *res)
{
struct pci_dev_resource *dev_res;
list_for_each_entry(dev_res, head, list) {
if (dev_res->res == res)
return dev_res;
}
return NULL;
}
static resource_size_t get_res_add_size(struct list_head *head,
struct resource *res)
{
struct pci_dev_resource *dev_res;
dev_res = res_to_dev_res(head, res);
return dev_res ? dev_res->add_size : 0;
}
static void pci_dev_res_restore(struct pci_dev_resource *dev_res)
{
Annotation
- Immediate include surface: `linux/align.h`, `linux/bitops.h`, `linux/bug.h`, `linux/init.h`, `linux/kernel.h`, `linux/minmax.h`, `linux/module.h`, `linux/pci.h`.
- Detected declarations: `struct pci_dev_resource`, `enum release_type`, `enum enable_type`, `function pci_dev_res_free_list`, `function list_for_each_entry_safe`, `function pci_dev_res_add_to_list`, `function pci_dev_res_remove_from_list`, `function list_for_each_entry_safe`, `function list_for_each_entry`, `function get_res_add_size`.
- 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.