drivers/pci/hotplug/cpqphp_pci.c
Source file repositories/reference/linux-study-clean/drivers/pci/hotplug/cpqphp_pci.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/hotplug/cpqphp_pci.c- Extension
.c- Size
- 38706 bytes
- Lines
- 1548
- 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/kernel.hlinux/printk.hlinux/types.hlinux/slab.hlinux/workqueue.hlinux/proc_fs.hlinux/pci.hlinux/pci_hotplug.h../pci.hcpqphp.hcpqphp_nvram.h
Detected Declarations
function cpqhp_configure_devicefunction cpqhp_unconfigure_devicefunction cpqhp_set_irqfunction PCI_ScanBusForNonBridgefunction PCI_GetBusDevHelperfunction cpqhp_get_bus_devfunction cpqhp_save_configfunction cpqhp_save_slot_configfunction cpqhp_save_base_addr_lengthfunction cpqhp_save_used_resourcesfunction cpqhp_configure_boardfunction cpqhp_valid_replacefunction cpqhp_find_available_resourcesfunction cpqhp_return_board_resourcesfunction cpqhp_destroy_resource_listfunction cpqhp_destroy_board_resources
Annotated Snippet
if (func->pci_dev == NULL) {
dbg("ERROR: pci_dev still null\n");
goto out;
}
}
if (func->pci_dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
pci_hp_add_bridge(func->pci_dev);
child = func->pci_dev->subordinate;
if (child)
pci_bus_add_devices(child);
}
pci_dev_put(func->pci_dev);
out:
pci_unlock_rescan_remove();
return 0;
}
int cpqhp_unconfigure_device(struct pci_func *func)
{
int j;
dbg("%s: bus/dev/func = %x/%x/%x\n", __func__, func->bus, func->device, func->function);
pci_lock_rescan_remove();
for (j = 0; j < 8 ; j++) {
struct pci_dev *temp = pci_get_domain_bus_and_slot(0,
func->bus,
PCI_DEVFN(func->device,
j));
if (temp) {
pci_dev_put(temp);
pci_stop_and_remove_bus_device(temp);
}
}
pci_unlock_rescan_remove();
return 0;
}
/*
* cpqhp_set_irq
*
* @bus_num: bus number of PCI device
* @dev_num: device number of PCI device
* @slot: pointer to u8 where slot number will be returned
*/
int cpqhp_set_irq(u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num)
{
int rc = 0;
if (cpqhp_legacy_mode) {
struct pci_dev *fakedev;
struct pci_bus *fakebus;
u16 temp_word;
fakedev = kmalloc_obj(*fakedev);
fakebus = kmalloc_obj(*fakebus);
if (!fakedev || !fakebus) {
kfree(fakedev);
kfree(fakebus);
return -ENOMEM;
}
fakedev->devfn = dev_num << 3;
fakedev->bus = fakebus;
fakebus->number = bus_num;
dbg("%s: dev %d, bus %d, pin %d, num %d\n",
__func__, dev_num, bus_num, int_pin, irq_num);
rc = pcibios_set_irq_routing(fakedev, int_pin - 1, irq_num);
kfree(fakedev);
kfree(fakebus);
dbg("%s: rc %d\n", __func__, rc);
if (!rc)
return !rc;
/* set the Edge Level Control Register (ELCR) */
temp_word = inb(0x4d0);
temp_word |= inb(0x4d1) << 8;
temp_word |= 0x01 << irq_num;
/* This should only be for x86 as it sets the Edge Level
* Control Register
*/
outb((u8)(temp_word & 0xFF), 0x4d0);
outb((u8)((temp_word & 0xFF00) >> 8), 0x4d1);
rc = 0;
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/printk.h`, `linux/types.h`, `linux/slab.h`, `linux/workqueue.h`, `linux/proc_fs.h`, `linux/pci.h`.
- Detected declarations: `function cpqhp_configure_device`, `function cpqhp_unconfigure_device`, `function cpqhp_set_irq`, `function PCI_ScanBusForNonBridge`, `function PCI_GetBusDevHelper`, `function cpqhp_get_bus_dev`, `function cpqhp_save_config`, `function cpqhp_save_slot_config`, `function cpqhp_save_base_addr_length`, `function cpqhp_save_used_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.