drivers/pci/hotplug/cpqphp_ctrl.c
Source file repositories/reference/linux-study-clean/drivers/pci/hotplug/cpqphp_ctrl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/hotplug/cpqphp_ctrl.c- Extension
.c- Size
- 74941 bytes
- Lines
- 2912
- 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.
- 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/types.hlinux/slab.hlinux/workqueue.hlinux/interrupt.hlinux/delay.hlinux/wait.hlinux/pci.hlinux/pci_hotplug.hlinux/kthread.hcpqphp.h
Detected Declarations
function long_delayfunction handle_switch_changefunction handle_presence_changefunction handle_power_faultfunction sort_by_sizefunction sort_by_max_sizefunction cpqhp_resource_sort_and_combinefunction cpqhp_ctrl_intrfunction slot_removefunction bridge_slot_removefunction is_bridgefunction set_controller_speedfunction board_replacedfunction board_addedfunction remove_boardfunction pushbutton_helper_threadfunction event_threadfunction cpqhp_event_start_threadfunction cpqhp_event_stop_threadfunction interrupt_event_handlerfunction cpqhp_pushbutton_threadfunction cpqhp_process_SIfunction cpqhp_process_SSfunction switch_ledsfunction cpqhp_hardware_testfunction configure_new_devicefunction configure_new_function
Annotated Snippet
if (change & (0x1L << hp_slot)) {
/*
* this one changed.
*/
func = cpqhp_slot_find(ctrl->bus,
(hp_slot + ctrl->slot_device_offset), 0);
/* this is the structure that tells the worker thread
* what to do
*/
taskInfo = &(ctrl->event_queue[ctrl->next_event]);
ctrl->next_event = (ctrl->next_event + 1) % 10;
taskInfo->hp_slot = hp_slot;
rc++;
temp_word = ctrl->ctrl_int_comp >> 16;
func->presence_save = (temp_word >> hp_slot) & 0x01;
func->presence_save |= (temp_word >> (hp_slot + 7)) & 0x02;
if (ctrl->ctrl_int_comp & (0x1L << hp_slot)) {
/*
* Switch opened
*/
func->switch_save = 0;
taskInfo->event_type = INT_SWITCH_OPEN;
} else {
/*
* Switch closed
*/
func->switch_save = 0x10;
taskInfo->event_type = INT_SWITCH_CLOSE;
}
}
}
return rc;
}
/**
* cpqhp_find_slot - find the struct slot of given device
* @ctrl: scan lots of this controller
* @device: the device id to find
*/
static struct slot *cpqhp_find_slot(struct controller *ctrl, u8 device)
{
struct slot *slot = ctrl->slot;
while (slot && (slot->device != device))
slot = slot->next;
return slot;
}
static u8 handle_presence_change(u16 change, struct controller *ctrl)
{
int hp_slot;
u8 rc = 0;
u8 temp_byte;
u16 temp_word;
struct pci_func *func;
struct event_info *taskInfo;
struct slot *p_slot;
if (!change)
return 0;
/*
* Presence Change
*/
dbg("cpqsbd: Presence/Notify input change.\n");
dbg(" Changed bits are 0x%4.4x\n", change);
for (hp_slot = 0; hp_slot < 6; hp_slot++) {
if (change & (0x0101 << hp_slot)) {
/*
* this one changed.
*/
func = cpqhp_slot_find(ctrl->bus,
(hp_slot + ctrl->slot_device_offset), 0);
taskInfo = &(ctrl->event_queue[ctrl->next_event]);
ctrl->next_event = (ctrl->next_event + 1) % 10;
taskInfo->hp_slot = hp_slot;
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/types.h`, `linux/slab.h`, `linux/workqueue.h`, `linux/interrupt.h`, `linux/delay.h`, `linux/wait.h`.
- Detected declarations: `function long_delay`, `function handle_switch_change`, `function handle_presence_change`, `function handle_power_fault`, `function sort_by_size`, `function sort_by_max_size`, `function cpqhp_resource_sort_and_combine`, `function cpqhp_ctrl_intr`, `function slot_remove`, `function bridge_slot_remove`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: source 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.