Skip to contentSkip to conversation

pciehp: Use link change notifications for hot-plug and removal

PATCH In review Rajat Jain 1 participant 1 message Dec 17, 2013 PCI

lore
Share & tools
lore

Rajat Jain

author
#0 lore raw

PATCH v3 2/8 pciehp: Use link change notifications for hot-plug and removal

A lot of systems do not have the fancy buttons and LEDs, and instead want to rely only on the Link state change events to drive the hotplug and removal state machinery.
(http://www.spinics.net/lists/hotplug/msg05802.html)

This patch adds support for that functionality. Here are the details about the patch itself:

* Define and use interrupt events for linkup / linkdown.

* Make the pcie_isr() also look at link events, and direct control to corresponding (new) link state change handler function.

* Introduce the functions to handle link-up and link-down events and queue the add / removal work in the slot->wq to be processed by pciehp_power_thread()

As a side note, this patch also fixes the bug
https://bugzilla.kernel.org/show_bug.cgi?id=65521

---
v3: * Split up the patch into other patches, thus smaller patch.
* Combined handler for link up & down into handle_link_event() (Yijing Wang's comment)
v2: Same as v1, dropped the "RFC" from subject, added Guenter's signature
v1: Initial patch.

 drivers/pci/hotplug/pciehp.h      |    3 ++
 drivers/pci/hotplug/pciehp_ctrl.c |   88 +++++++++++++++++++++++++++++++++++++
 drivers/pci/hotplug/pciehp_hpc.c  |    6 ++-
 3 files changed, 96 insertions(+), 1 deletion(-)
drivers/pci/hotplug/pciehp.h +3 -0
index 4ffcf6b..92d7fed 100644
@@ -110,6 +110,8 @@ struct controller {
 #define INT_BUTTON_PRESS		7
 #define INT_BUTTON_RELEASE		8
 #define INT_BUTTON_CANCEL		9
+#define INT_LINK_UP			10
+#define INT_LINK_DOWN			11
 
 #define STATIC_STATE			0
 #define BLINKINGON_STATE		1
@@ -133,6 +135,7 @@ u8 pciehp_handle_attention_button(struct slot *p_slot);
 u8 pciehp_handle_switch_change(struct slot *p_slot);
 u8 pciehp_handle_presence_change(struct slot *p_slot);
 u8 pciehp_handle_power_fault(struct slot *p_slot);
+void pciehp_handle_linkstate_change(struct slot *p_slot);
 int pciehp_configure_device(struct slot *p_slot);
 int pciehp_unconfigure_device(struct slot *p_slot);
 void pciehp_queue_pushbutton_work(struct work_struct *work);
drivers/pci/hotplug/pciehp_ctrl.c +88 -0

106 lines not on this page · raw message

drivers/pci/hotplug/pciehp_hpc.c +5 -1
index f8c7a5f..1e9f814 100644
@@ -661,7 +661,7 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
 
 		detected &= (PCI_EXP_SLTSTA_ABP | PCI_EXP_SLTSTA_PFD |
 			     PCI_EXP_SLTSTA_MRLSC | PCI_EXP_SLTSTA_PDC |
-			     PCI_EXP_SLTSTA_CC);
+			     PCI_EXP_SLTSTA_CC | PCI_EXP_SLTSTA_DLLSC);
 		detected &= ~intr_loc;
 		intr_loc |= detected;
 		if (!intr_loc)
@@ -702,6 +702,10 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
 		ctrl->power_fault_detected = 1;
 		pciehp_handle_power_fault(slot);
 	}
+
+	if (intr_loc & PCI_EXP_SLTSTA_DLLSC)
+		pciehp_handle_linkstate_change(slot);
+
 	return IRQ_HANDLED;
 }
 
Signature · 1 line
1.7.9.5