Skip to content

Commit 4f092fe

Browse files
committed
PCI: pciehp: Inline the "handle event" functions into the ISR
The pciehp_handle_*() functions (pciehp_handle_attention_button(), etc.) only contain a line or two of useful code, so it's clumsy to put them in separate functions. All they so is add an event to a work queue, and it's clearer to see that directly in the ISR. Inline them directly into pcie_isr(). No functional change. Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Rajat Jain <[email protected]> Acked-by: Yinghai Lu <[email protected]>
1 parent d49eccb commit 4f092fe

File tree

3 files changed

+32
-118
lines changed

3 files changed

+32
-118
lines changed

drivers/pci/hotplug/pciehp.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,7 @@ struct controller {
132132

133133
int pciehp_sysfs_enable_slot(struct slot *slot);
134134
int pciehp_sysfs_disable_slot(struct slot *slot);
135-
u8 pciehp_handle_attention_button(struct slot *p_slot);
136-
u8 pciehp_handle_switch_change(struct slot *p_slot);
137-
u8 pciehp_handle_presence_change(struct slot *p_slot);
138-
u8 pciehp_handle_power_fault(struct slot *p_slot);
139-
void pciehp_handle_linkstate_change(struct slot *p_slot);
135+
void pciehp_queue_interrupt_event(struct slot *slot, u32 event_type);
140136
int pciehp_configure_device(struct slot *p_slot);
141137
int pciehp_unconfigure_device(struct slot *p_slot);
142138
void pciehp_queue_pushbutton_work(struct work_struct *work);

drivers/pci/hotplug/pciehp_ctrl.c

Lines changed: 1 addition & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
static void interrupt_event_handler(struct work_struct *work);
3939

40-
static void pciehp_queue_interrupt_event(struct slot *p_slot, u32 event_type)
40+
void pciehp_queue_interrupt_event(struct slot *p_slot, u32 event_type)
4141
{
4242
struct event_info *info;
4343

@@ -53,109 +53,6 @@ static void pciehp_queue_interrupt_event(struct slot *p_slot, u32 event_type)
5353
queue_work(p_slot->wq, &info->work);
5454
}
5555

56-
u8 pciehp_handle_attention_button(struct slot *p_slot)
57-
{
58-
u32 event_type;
59-
struct controller *ctrl = p_slot->ctrl;
60-
61-
/*
62-
* Button pressed - See if need to TAKE ACTION!!!
63-
*/
64-
ctrl_info(ctrl, "Button pressed on Slot(%s)\n", slot_name(p_slot));
65-
event_type = INT_BUTTON_PRESS;
66-
67-
pciehp_queue_interrupt_event(p_slot, event_type);
68-
69-
return 0;
70-
}
71-
72-
u8 pciehp_handle_switch_change(struct slot *p_slot)
73-
{
74-
u8 getstatus;
75-
u32 event_type;
76-
struct controller *ctrl = p_slot->ctrl;
77-
78-
pciehp_get_latch_status(p_slot, &getstatus);
79-
if (getstatus) {
80-
/*
81-
* Switch opened
82-
*/
83-
ctrl_info(ctrl, "Latch open on Slot(%s)\n", slot_name(p_slot));
84-
event_type = INT_SWITCH_OPEN;
85-
} else {
86-
/*
87-
* Switch closed
88-
*/
89-
ctrl_info(ctrl, "Latch close on Slot(%s)\n", slot_name(p_slot));
90-
event_type = INT_SWITCH_CLOSE;
91-
}
92-
93-
pciehp_queue_interrupt_event(p_slot, event_type);
94-
95-
return 1;
96-
}
97-
98-
u8 pciehp_handle_presence_change(struct slot *p_slot)
99-
{
100-
u32 event_type;
101-
u8 presence_save;
102-
struct controller *ctrl = p_slot->ctrl;
103-
104-
/* Switch is open, assume a presence change
105-
* Save the presence state
106-
*/
107-
pciehp_get_adapter_status(p_slot, &presence_save);
108-
if (presence_save) {
109-
/*
110-
* Card Present
111-
*/
112-
ctrl_info(ctrl, "Card present on Slot(%s)\n", slot_name(p_slot));
113-
event_type = INT_PRESENCE_ON;
114-
} else {
115-
/*
116-
* Not Present
117-
*/
118-
ctrl_info(ctrl, "Card not present on Slot(%s)\n",
119-
slot_name(p_slot));
120-
event_type = INT_PRESENCE_OFF;
121-
}
122-
123-
pciehp_queue_interrupt_event(p_slot, event_type);
124-
125-
return 1;
126-
}
127-
128-
u8 pciehp_handle_power_fault(struct slot *p_slot)
129-
{
130-
u32 event_type;
131-
struct controller *ctrl = p_slot->ctrl;
132-
133-
ctrl_err(ctrl, "Power fault on slot %s\n", slot_name(p_slot));
134-
event_type = INT_POWER_FAULT;
135-
ctrl_info(ctrl, "Power fault bit %x set\n", 0);
136-
pciehp_queue_interrupt_event(p_slot, event_type);
137-
138-
return 1;
139-
}
140-
141-
void pciehp_handle_linkstate_change(struct slot *p_slot)
142-
{
143-
u32 event_type;
144-
struct controller *ctrl = p_slot->ctrl;
145-
146-
if (pciehp_check_link_active(ctrl)) {
147-
ctrl_info(ctrl, "slot(%s): Link Up event\n",
148-
slot_name(p_slot));
149-
event_type = INT_LINK_UP;
150-
} else {
151-
ctrl_info(ctrl, "slot(%s): Link Down event\n",
152-
slot_name(p_slot));
153-
event_type = INT_LINK_DOWN;
154-
}
155-
156-
pciehp_queue_interrupt_event(p_slot, event_type);
157-
}
158-
15956
/* The following routines constitute the bulk of the
16057
hotplug controller logic
16158
*/

drivers/pci/hotplug/pciehp_hpc.c

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,8 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
535535
struct pci_dev *dev;
536536
struct slot *slot = ctrl->slot;
537537
u16 detected, intr_loc;
538+
u8 open, present;
539+
bool link;
538540

539541
/*
540542
* In order to guarantee that all interrupt events are
@@ -580,25 +582,44 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
580582
return IRQ_HANDLED;
581583

582584
/* Check MRL Sensor Changed */
583-
if (intr_loc & PCI_EXP_SLTSTA_MRLSC)
584-
pciehp_handle_switch_change(slot);
585+
if (intr_loc & PCI_EXP_SLTSTA_MRLSC) {
586+
pciehp_get_latch_status(slot, &open);
587+
ctrl_info(ctrl, "Latch %s on Slot(%s)\n",
588+
open ? "open" : "close", slot_name(slot));
589+
pciehp_queue_interrupt_event(slot, open ? INT_SWITCH_OPEN :
590+
INT_SWITCH_CLOSE);
591+
}
585592

586593
/* Check Attention Button Pressed */
587-
if (intr_loc & PCI_EXP_SLTSTA_ABP)
588-
pciehp_handle_attention_button(slot);
594+
if (intr_loc & PCI_EXP_SLTSTA_ABP) {
595+
ctrl_info(ctrl, "Button pressed on Slot(%s)\n",
596+
slot_name(slot));
597+
pciehp_queue_interrupt_event(slot, INT_BUTTON_PRESS);
598+
}
589599

590600
/* Check Presence Detect Changed */
591-
if (intr_loc & PCI_EXP_SLTSTA_PDC)
592-
pciehp_handle_presence_change(slot);
601+
if (intr_loc & PCI_EXP_SLTSTA_PDC) {
602+
pciehp_get_adapter_status(slot, &present);
603+
ctrl_info(ctrl, "Card %spresent on Slot(%s)\n",
604+
present ? "" : "not ", slot_name(slot));
605+
pciehp_queue_interrupt_event(slot, present ? INT_PRESENCE_ON :
606+
INT_PRESENCE_OFF);
607+
}
593608

594609
/* Check Power Fault Detected */
595610
if ((intr_loc & PCI_EXP_SLTSTA_PFD) && !ctrl->power_fault_detected) {
596611
ctrl->power_fault_detected = 1;
597-
pciehp_handle_power_fault(slot);
612+
ctrl_err(ctrl, "Power fault on slot %s\n", slot_name(slot));
613+
pciehp_queue_interrupt_event(slot, INT_POWER_FAULT);
598614
}
599615

600-
if (intr_loc & PCI_EXP_SLTSTA_DLLSC)
601-
pciehp_handle_linkstate_change(slot);
616+
if (intr_loc & PCI_EXP_SLTSTA_DLLSC) {
617+
link = pciehp_check_link_active(ctrl);
618+
ctrl_info(ctrl, "slot(%s): Link %s event\n",
619+
slot_name(slot), link ? "Up" : "Down");
620+
pciehp_queue_interrupt_event(slot, link ? INT_LINK_UP :
621+
INT_LINK_DOWN);
622+
}
602623

603624
return IRQ_HANDLED;
604625
}

0 commit comments

Comments
 (0)