Skip to contentSkip to conversation

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

RFC PATCH Superseded Rajat Jain 1 participant 1 message Nov 19, 2013 PCI

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Rajat Jain

author
#0 lore raw

RFC PATCH 2/4 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:

* Add "pciehp_use_link_events" module parameter to indicate link state changes to be used for hot-plug.

* Define and use interrupt events for linkup / linkdown.

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

* Many ports use inband mechanism such as receiver detection to find out whether an adapter is present. In such HP ports, when link goes down, adapter presence will also toggle. Thus don't bail out the removal process initiated by link down, if adapter is not found to be present.

* The current pciehp driver disabled the link in case of a hot-removal. Since for link change based hot-plug to work, we need that enabled, hence make sure to not disable the link permanently if link state based hot-plug is to be used.

* pciehp_reset_slot - reset of secondary bus may cause undesirable spurious link notifications. Thus disable these around the secondary bus reset.

---
 drivers/pci/hotplug/pciehp.h      |    4 ++
 drivers/pci/hotplug/pciehp_core.c |    3 +
 drivers/pci/hotplug/pciehp_ctrl.c |  132 ++++++++++++++++++++++++++++++++++++-
 drivers/pci/hotplug/pciehp_hpc.c  |   56 +++++++++++-----
 4 files changed, 179 insertions(+), 16 deletions(-)
drivers/pci/hotplug/pciehp.h +4 -0
index fc322ed..64a6840 100644
@@ -44,6 +44,7 @@ extern bool pciehp_poll_mode;
 extern int pciehp_poll_time;
 extern bool pciehp_debug;
 extern bool pciehp_force;
+extern bool pciehp_use_link_events;      /* Use link state events for hotplug */
 
 #define dbg(format, arg...)						\
 do {									\
@@ -110,6 +111,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 +136,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);
+u8 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_core.c +3 -0
index f4a18f5..5a2c43c 100644
@@ -42,6 +42,7 @@ bool pciehp_debug;
 bool pciehp_poll_mode;
 int pciehp_poll_time;
 bool pciehp_force;
+bool pciehp_use_link_events;
 
 #define DRIVER_VERSION	"0.4"
 #define DRIVER_AUTHOR	"Dan Zink <[email protected]>, Greg Kroah-Hartman <[email protected]>, Dely Sy <[email protected]>"
@@ -55,10 +56,12 @@ module_param(pciehp_debug, bool, 0644);
 module_param(pciehp_poll_mode, bool, 0644);
 module_param(pciehp_poll_time, int, 0644);
 module_param(pciehp_force, bool, 0644);
+module_param(pciehp_use_link_events, bool, 0644);
 MODULE_PARM_DESC(pciehp_debug, "Debugging mode enabled or not");
 MODULE_PARM_DESC(pciehp_poll_mode, "Using polling mechanism for hot-plug events or not");
 MODULE_PARM_DESC(pciehp_poll_time, "Polling mechanism frequency, in seconds");
 MODULE_PARM_DESC(pciehp_force, "Force pciehp, even if OSHP is missing");
+MODULE_PARM_DESC(pciehp_use_link_events, "Use link state change events to drive pciehp hot-plug");
 
 #define PCIE_MODULE_NAME "pciehp"
 
drivers/pci/hotplug/pciehp_ctrl.c +131 -1

156 lines not on this page · raw message

drivers/pci/hotplug/pciehp_hpc.c +41 -15

107 lines not on this page · raw message

Signature · 1 line
1.7.9.5