aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2015-06-14 22:35:13 -0400
committerBjorn Helgaas <bhelgaas@google.com>2015-06-18 17:14:49 -0400
commit4f092fec67191f899fa111a4eeffdf4368494c77 (patch)
tree6b449fd8ccd7cafefc0019748881abf875693c63
parentd49eccb3c1a41b847380279d7f88a88421783f37 (diff)
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 <bhelgaas@google.com> Reviewed-by: Rajat Jain <rajatja@google.com> Acked-by: Yinghai Lu <yinghai@kernel.org>
-rw-r--r--drivers/pci/hotplug/pciehp.h6
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c105
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c39
3 files changed, 32 insertions, 118 deletions
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index ce4d12c4eff4..57cd1327346f 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -132,11 +132,7 @@ struct controller {
132 132
133int pciehp_sysfs_enable_slot(struct slot *slot); 133int pciehp_sysfs_enable_slot(struct slot *slot);
134int pciehp_sysfs_disable_slot(struct slot *slot); 134int pciehp_sysfs_disable_slot(struct slot *slot);
135u8 pciehp_handle_attention_button(struct slot *p_slot); 135void pciehp_queue_interrupt_event(struct slot *slot, u32 event_type);
136u8 pciehp_handle_switch_change(struct slot *p_slot);
137u8 pciehp_handle_presence_change(struct slot *p_slot);
138u8 pciehp_handle_power_fault(struct slot *p_slot);
139void pciehp_handle_linkstate_change(struct slot *p_slot);
140int pciehp_configure_device(struct slot *p_slot); 136int pciehp_configure_device(struct slot *p_slot);
141int pciehp_unconfigure_device(struct slot *p_slot); 137int pciehp_unconfigure_device(struct slot *p_slot);
142void pciehp_queue_pushbutton_work(struct work_struct *work); 138void pciehp_queue_pushbutton_work(struct work_struct *work);
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index 7ed37dc4879a..f3796124ad7c 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -37,7 +37,7 @@
37 37
38static void interrupt_event_handler(struct work_struct *work); 38static void interrupt_event_handler(struct work_struct *work);
39 39
40static void pciehp_queue_interrupt_event(struct slot *p_slot, u32 event_type) 40void pciehp_queue_interrupt_event(struct slot *p_slot, u32 event_type)
41{ 41{
42 struct event_info *info; 42 struct event_info *info;
43 43
@@ -53,109 +53,6 @@ static void pciehp_queue_interrupt_event(struct slot *p_slot, u32 event_type)
53 queue_work(p_slot->wq, &info->work); 53 queue_work(p_slot->wq, &info->work);
54} 54}
55 55
56u8 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
72u8 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
98u8 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
128u8 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
141void 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
159/* The following routines constitute the bulk of the 56/* The following routines constitute the bulk of the
160 hotplug controller logic 57 hotplug controller logic
161 */ 58 */
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index e9daaa370047..2913f7e68a10 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -535,6 +535,8 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
535 struct pci_dev *dev; 535 struct pci_dev *dev;
536 struct slot *slot = ctrl->slot; 536 struct slot *slot = ctrl->slot;
537 u16 detected, intr_loc; 537 u16 detected, intr_loc;
538 u8 open, present;
539 bool link;
538 540
539 /* 541 /*
540 * In order to guarantee that all interrupt events are 542 * In order to guarantee that all interrupt events are
@@ -580,25 +582,44 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
580 return IRQ_HANDLED; 582 return IRQ_HANDLED;
581 583
582 /* Check MRL Sensor Changed */ 584 /* Check MRL Sensor Changed */
583 if (intr_loc & PCI_EXP_SLTSTA_MRLSC) 585 if (intr_loc & PCI_EXP_SLTSTA_MRLSC) {
584 pciehp_handle_switch_change(slot); 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 }
585 592
586 /* Check Attention Button Pressed */ 593 /* Check Attention Button Pressed */
587 if (intr_loc & PCI_EXP_SLTSTA_ABP) 594 if (intr_loc & PCI_EXP_SLTSTA_ABP) {
588 pciehp_handle_attention_button(slot); 595 ctrl_info(ctrl, "Button pressed on Slot(%s)\n",
596 slot_name(slot));
597 pciehp_queue_interrupt_event(slot, INT_BUTTON_PRESS);
598 }
589 599
590 /* Check Presence Detect Changed */ 600 /* Check Presence Detect Changed */
591 if (intr_loc & PCI_EXP_SLTSTA_PDC) 601 if (intr_loc & PCI_EXP_SLTSTA_PDC) {
592 pciehp_handle_presence_change(slot); 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 }
593 608
594 /* Check Power Fault Detected */ 609 /* Check Power Fault Detected */
595 if ((intr_loc & PCI_EXP_SLTSTA_PFD) && !ctrl->power_fault_detected) { 610 if ((intr_loc & PCI_EXP_SLTSTA_PFD) && !ctrl->power_fault_detected) {
596 ctrl->power_fault_detected = 1; 611 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);
598 } 614 }
599 615
600 if (intr_loc & PCI_EXP_SLTSTA_DLLSC) 616 if (intr_loc & PCI_EXP_SLTSTA_DLLSC) {
601 pciehp_handle_linkstate_change(slot); 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 }
602 623
603 return IRQ_HANDLED; 624 return IRQ_HANDLED;
604} 625}