drivers/pci/hotplug/ibmphp_res.c
Source file repositories/reference/linux-study-clean/drivers/pci/hotplug/ibmphp_res.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/hotplug/ibmphp_res.c- Extension
.c- Size
- 57597 bytes
- Lines
- 2119
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: implementation source
- Status
- source 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.
- 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/slab.hlinux/pci.hlinux/list.hlinux/init.hibmphp.h
Detected Declarations
function alloc_error_busfunction alloc_resourcesfunction alloc_bus_rangefunction etcfunction list_for_each_entryfunction list_for_each_entryfunction add_bus_rangefunction update_resourcesfunction fix_mefunction fix_resourcesfunction ibmphp_add_resourcefunction ibmphp_remove_resourcefunction ibmphp_check_resourcefunction ibmphp_remove_busfunction remove_rangesfunction ibmphp_find_resourcefunction ibmphp_free_resourcesfunction list_for_each_entry_safefunction once_overfunction list_for_each_entryfunction ibmphp_add_pfmem_from_memfunction list_for_each_entryfunction ibmphp_print_testfunction list_for_each_entryfunction range_exists_alreadyfunction update_bridge_ranges
Annotated Snippet
switch (flag) {
case MEM:
num_ranges = newbus->noMemRanges;
break;
case PFMEM:
num_ranges = newbus->noPFMemRanges;
break;
case IO:
num_ranges = newbus->noIORanges;
break;
}
}
newrange = kzalloc_obj(struct range_node);
if (!newrange) {
if (first_bus)
kfree(newbus);
return -ENOMEM;
}
newrange->start = curr->start_addr;
newrange->end = curr->end_addr;
if (first_bus || (!num_ranges))
newrange->rangeno = 1;
else {
/* need to insert our range */
add_bus_range(flag, newrange, newbus);
debug("%d resource Primary Bus inserted on bus %x [%x - %x]\n", flag, newbus->busno, newrange->start, newrange->end);
}
switch (flag) {
case MEM:
newbus->rangeMem = newrange;
if (first_bus)
newbus->noMemRanges = 1;
else {
debug("First Memory Primary on bus %x, [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
++newbus->noMemRanges;
fix_resources(newbus);
}
break;
case IO:
newbus->rangeIO = newrange;
if (first_bus)
newbus->noIORanges = 1;
else {
debug("First IO Primary on bus %x, [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
++newbus->noIORanges;
fix_resources(newbus);
}
break;
case PFMEM:
newbus->rangePFMem = newrange;
if (first_bus)
newbus->noPFMemRanges = 1;
else {
debug("1st PFMemory Primary on Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
++newbus->noPFMemRanges;
fix_resources(newbus);
}
break;
}
*new_bus = newbus;
*new_range = newrange;
return 0;
}
/* Notes:
* 1. The ranges are ordered. The buses are not ordered. (First come)
*
* 2. If cannot allocate out of PFMem range, allocate from Mem ranges. PFmemFromMem
* are not sorted. (no need since use mem node). To not change the entire code, we
* also add mem node whenever this case happens so as not to change
* ibmphp_check_mem_resource etc(and since it really is taking Mem resource)
*/
/*****************************************************************************
* This is the Resource Management initialization function. It will go through
* the Resource list taken from EBDA and fill in this module's data structures
*
* THIS IS NOT TAKING INTO CONSIDERATION IO RESTRICTIONS OF PRIMARY BUSES,
* SINCE WE'RE GOING TO ASSUME FOR NOW WE DON'T HAVE THOSE ON OUR BUSES FOR NOW
*
* Input: ptr to the head of the resource list from EBDA
* Output: 0, -1 or error codes
***************************************************************************/
int __init ibmphp_rsrc_init(void)
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/pci.h`, `linux/list.h`, `linux/init.h`, `ibmphp.h`.
- Detected declarations: `function alloc_error_bus`, `function alloc_resources`, `function alloc_bus_range`, `function etc`, `function list_for_each_entry`, `function list_for_each_entry`, `function add_bus_range`, `function update_resources`, `function fix_me`, `function fix_resources`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: source 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.