drivers/pci/hotplug/cpci_hotplug_core.c
Source file repositories/reference/linux-study-clean/drivers/pci/hotplug/cpci_hotplug_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/hotplug/cpci_hotplug_core.c- Extension
.c- Size
- 14249 bytes
- Lines
- 632
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/module.hlinux/kernel.hlinux/sched/signal.hlinux/slab.hlinux/pci.hlinux/pci_hotplug.hlinux/init.hlinux/interrupt.hlinux/atomic.hlinux/delay.hlinux/kthread.hcpci_hotplug.h
Detected Declarations
function enable_slotfunction disable_slotfunction cpci_get_power_statusfunction get_power_statusfunction get_attention_statusfunction set_attention_statusfunction get_adapter_statusfunction get_latch_statusfunction release_slotfunction cpci_hp_register_busfunction cpci_hp_unregister_busfunction cpci_hp_intrfunction init_slotsfunction check_slotsfunction event_threadfunction poll_threadfunction cpci_start_threadfunction cpci_stop_threadfunction cpci_hp_register_controllerfunction cleanup_slotsfunction cpci_hp_unregister_controllerfunction cpci_hp_startfunction cpci_hp_stopfunction cpci_hotplug_initexport cpci_hp_register_busexport cpci_hp_unregister_busexport cpci_hp_register_controllerexport cpci_hp_unregister_controllerexport cpci_hp_startexport cpci_hp_stop
Annotated Snippet
if (!slot) {
status = -ENOMEM;
goto error;
}
slot->bus = bus;
slot->number = i;
slot->devfn = PCI_DEVFN(i, 0);
snprintf(name, SLOT_NAME_SIZE, "%02x:%02x", bus->number, i);
slot->hotplug_slot.ops = &cpci_hotplug_slot_ops;
dbg("registering slot %s", name);
status = pci_hp_register(&slot->hotplug_slot, bus, i, name);
if (status) {
err("pci_hp_register failed with error %d", status);
goto error_slot;
}
dbg("slot registered with name: %s", slot_name(slot));
/* Add slot to our internal list */
down_write(&list_rwsem);
list_add(&slot->slot_list, &slot_list);
slots++;
up_write(&list_rwsem);
}
return 0;
error_slot:
kfree(slot);
error:
return status;
}
EXPORT_SYMBOL_GPL(cpci_hp_register_bus);
int
cpci_hp_unregister_bus(struct pci_bus *bus)
{
struct slot *slot;
struct slot *tmp;
int status = 0;
down_write(&list_rwsem);
if (!slots) {
up_write(&list_rwsem);
return -1;
}
list_for_each_entry_safe(slot, tmp, &slot_list, slot_list) {
if (slot->bus == bus) {
list_del(&slot->slot_list);
slots--;
dbg("deregistering slot %s", slot_name(slot));
pci_hp_deregister(&slot->hotplug_slot);
release_slot(slot);
}
}
up_write(&list_rwsem);
return status;
}
EXPORT_SYMBOL_GPL(cpci_hp_unregister_bus);
/* This is the interrupt mode interrupt handler */
static irqreturn_t
cpci_hp_intr(int irq, void *data)
{
dbg("entered cpci_hp_intr");
/* Check to see if it was our interrupt */
if ((controller->irq_flags & IRQF_SHARED) &&
!controller->ops->check_irq(controller->dev_id)) {
dbg("exited cpci_hp_intr, not our interrupt");
return IRQ_NONE;
}
/* Disable ENUM interrupt */
controller->ops->disable_irq();
/* Trigger processing by the event thread */
wake_up_process(cpci_thread);
return IRQ_HANDLED;
}
/*
* According to PICMG 2.1 R2.0, section 6.3.2, upon
* initialization, the system driver shall clear the
* INS bits of the cold-inserted devices.
*/
static int
init_slots(int clear_ins)
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/sched/signal.h`, `linux/slab.h`, `linux/pci.h`, `linux/pci_hotplug.h`, `linux/init.h`, `linux/interrupt.h`.
- Detected declarations: `function enable_slot`, `function disable_slot`, `function cpci_get_power_status`, `function get_power_status`, `function get_attention_status`, `function set_attention_status`, `function get_adapter_status`, `function get_latch_status`, `function release_slot`, `function cpci_hp_register_bus`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.