2.6 PCI Hotplug: receive PPC64 EEH events
PATCH 1/1 2.6 PCI Hotplug: receive PPC64 EEH events
Greg,
This patch implements the catching of EEH events by the hotplug subsystem. Its preliminary in that it doesn't do much with these events; right now, my goal is to stub-in the required interfaces so that development can occur on both the arch/ppc64 tree and the drivers/pci/hotplug tree without
excessive co-dependency of patches. I'm hoping to have these routines
do a whole lot more once some firmware issues get resolved.
--linas
===== drivers/pci/hotplug/rpaphp.h 1.9 vs edited =====
drivers/pci/hotplug/rpaphp.h +2 -1
@@ -124,7 +124,8 @@extern int register_pci_slot (struct slot *slot);extern int rpaphp_unconfig_pci_adapter (struct slot *slot);extern int rpaphp_get_pci_adapter_status (struct slot *slot,int is_init,u8 * value); -extern struct hotplug_slot *rpaphp_find_hotplug_slot (struct pci_dev *dev); +extern void init_eeh_handler (void ); +extern void exit_eeh_handler (void );/* rpaphp_core.c */ extern int rpaphp_add_slot (struct device_node *dn);
===== drivers/pci/hotplug/rpaphp_core.c 1.14 vs edited =====
drivers/pci/hotplug/rpaphp_core.c +4 -12
@@ -54,8 +54,6 @@MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" ); -void eeh_register_disable_func (int (*)(struct pci_dev *)); -module_param (debug, bool,0644 );static int enable_slot (struct hotplug_slot *slot);
@@ -65,7 +63,6 @@static int get_attention_status (struct hotplug_slot *slot,u8 * value);static int get_adapter_status (struct hotplug_slot *slot,u8 * value);static int get_max_bus_speed (struct hotplug_slot *hotplug_slot,enum pci_bus_speed *value); -static int rpaphp_disable_slot (struct pci_dev *dev);struct hotplug_slot_ops rpaphp_hotplug_slot_ops = { .owner =THIS_MODULE ,
@@ -407,8 +404,8 @@ {info (DRIVER_DESC " version: " DRIVER_VERSION "\n" ); -/* let EEH know they can use hotplug */ -eeh_register_disable_func (&rpaphp_disable_slot); +/* Get set to handle EEH events */ +init_eeh_handler ();/* read all the PRA info from the system */ return init_rpa ();
@@ -416,8 +413,8 @@ static void __exit rpaphp_exit(void) { -/* let EEH know we are going away */ -eeh_register_disable_func (NULL ); +/* Stop handling EEH events */ +exit_eeh_handler ();cleanup_slots (); }
@@ -448,11 +445,6 @@ exit:dbg ("%s - Exit: rc[%d]\n" , __FUNCTION__, retval);return retval; -} - -static int rpaphp_disable_slot (struct pci_dev *dev) -{ -return disable_slot (rpaphp_find_hotplug_slot (dev)); }static int disable_slot (struct hotplug_slot *hotplug_slot)
===== drivers/pci/hotplug/rpaphp_pci.c 1.9 vs edited =====
drivers/pci/hotplug/rpaphp_pci.c +29 -4
@@ -22,7 +22,9 @@* Send feedback to <[email protected]> * */ +#include <linux/notifier.h> #include <linux/pci.h> +#include <asm/eeh.h> #include <asm/pci-bridge.h> #include "../pci.h" /* for pci_add_new_bus */
@@ -227,7 +229,7 @@ }sprintf (child_bus->name,"PCI Bus #%02x" , child_bus->number);/* do pci_scan_child_bus */ -pci_scan_child_bus (child_bus); +// pci_scan_child_bus(child_bus); list_for_each_entry (child_dev, &child_bus->devices, bus_list) {eeh_add_device_late (child_dev);
@@ -503,7 +505,7 @@return retval; } -struct hotplug_slot *rpaphp_find_hotplug_slot (struct pci_dev *dev) +static struct slot *rpaphp_find_slot (struct pci_dev *dev) {struct list_head *tmp, *n;struct slot *slot;
@@ -528,11 +530,34 @@for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) {struct pci_dev *pdev =pci_dev_b (ln);if (pdev == dev) -return slot->hotplug_slot; +return slot; } }return NULL ; } -EXPORT_SYMBOL_GPL (rpaphp_find_hotplug_slot); +int handle_eeh_events (struct notifier_block *self, +unsigned long reason,void *ev) +{ +struct eeh_event *event = ev; + +/* Just turn it off for now */ +rpaphp_unconfig_pci_adapter (rpaphp_find_slot (event->dev)); +return 0 ; +} + +static struct notifier_block eeh_block; + +void __init init_eeh_handler (void ) +{ + eeh_block.notifier_call = handle_eeh_events; +eeh_register_notifier (&eeh_block); +} + +void __exit exit_eeh_handler (void) +{ + eeh_block.notifier_call = handle_eeh_events; +eeh_register_notifier (&eeh_block); +} +
Quoted 4 lines · On Wed, Jul 07, 2004 at 03:59:07PM -0500, [email protected] wrote:
drivers/pci/hotplug/rpaphp_pci.c +4
-0+static struct notifier_block eeh_block; + +void __init init_eeh_handler (void ) +{
drivers/pci/hotplug/rpaphp_pci.c line 563
Quoted 10 lines
drivers/pci/hotplug/rpaphp_pci.c +10
-0+ eeh_block.notifier_call = handle_eeh_events; +eeh_register_notifier (&eeh_block); +} + +void __exit exit_eeh_handler (void) +{ + eeh_block.notifier_call = handle_eeh_events; +eeh_register_notifier (&eeh_block); +} +
Um, I don't think you want your exit_* function to look identical to your init_* function :)
greg k-h
Quoted 5 lines · Greg KH
Quoted 1 line · On Wed, Jul 07, 2004 at 03:59:07PM -0500, [email protected] wrote:
+void
__exitexit_eeh_handler(void)Um, I don't think you want your exit_* function to look identical to your init_* function :)
Ooops .... it helps to hit 'save' every now and then efter editing a file. Attached below is the corrected patch, and a repeat copy of the original mail...
---------
Greg,
This patch implements the catching of EEH events by the hotplug subsystem. Its preliminary in that it doesn't do much with these events; right now, my goal is to stub-in the required interfaces so that development can occur on both the arch/ppc64 tree and the drivers/pci/hotplug tree without
excessive co-dependency of patches. I'm hoping to have these routines
do a whole lot more once some firmware issues get resolved.
--linas
===== drivers/pci/hotplug/rpaphp.h 1.9 vs edited =====
drivers/pci/hotplug/rpaphp.h +2 -1
@@ -124,7 +124,8 @@extern int register_pci_slot (struct slot *slot);extern int rpaphp_unconfig_pci_adapter (struct slot *slot);extern int rpaphp_get_pci_adapter_status (struct slot *slot,int is_init,u8 * value); -extern struct hotplug_slot *rpaphp_find_hotplug_slot (struct pci_dev *dev); +extern void init_eeh_handler (void ); +extern void exit_eeh_handler (void );/* rpaphp_core.c */ extern int rpaphp_add_slot (struct device_node *dn);
===== drivers/pci/hotplug/rpaphp_core.c 1.14 vs edited =====
drivers/pci/hotplug/rpaphp_core.c +4 -12
@@ -54,8 +54,6 @@MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" ); -void eeh_register_disable_func (int (*)(struct pci_dev *)); -module_param (debug, bool,0644 );static int enable_slot (struct hotplug_slot *slot);
@@ -65,7 +63,6 @@static int get_attention_status (struct hotplug_slot *slot,u8 * value);static int get_adapter_status (struct hotplug_slot *slot,u8 * value);static int get_max_bus_speed (struct hotplug_slot *hotplug_slot,enum pci_bus_speed *value); -static int rpaphp_disable_slot (struct pci_dev *dev);struct hotplug_slot_ops rpaphp_hotplug_slot_ops = { .owner =THIS_MODULE ,
@@ -407,8 +404,8 @@ {info (DRIVER_DESC " version: " DRIVER_VERSION "\n" ); -/* let EEH know they can use hotplug */ -eeh_register_disable_func (&rpaphp_disable_slot); +/* Get set to handle EEH events */ +init_eeh_handler ();/* read all the PRA info from the system */ return init_rpa ();
@@ -416,8 +413,8 @@ static void __exit rpaphp_exit(void) { -/* let EEH know we are going away */ -eeh_register_disable_func (NULL ); +/* Stop handling EEH events */ +exit_eeh_handler ();cleanup_slots (); }
@@ -448,11 +445,6 @@ exit:dbg ("%s - Exit: rc[%d]\n" , __FUNCTION__, retval);return retval; -} - -static int rpaphp_disable_slot (struct pci_dev *dev) -{ -return disable_slot (rpaphp_find_hotplug_slot (dev)); }static int disable_slot (struct hotplug_slot *hotplug_slot)
===== drivers/pci/hotplug/rpaphp_pci.c 1.9 vs edited =====
drivers/pci/hotplug/rpaphp_pci.c +28 -4
@@ -22,7 +22,9 @@* Send feedback to <[email protected]> * */ +#include <linux/notifier.h> #include <linux/pci.h> +#include <asm/eeh.h> #include <asm/pci-bridge.h> #include "../pci.h" /* for pci_add_new_bus */
@@ -227,7 +229,7 @@ }sprintf (child_bus->name,"PCI Bus #%02x" , child_bus->number);/* do pci_scan_child_bus */ -pci_scan_child_bus (child_bus); +// pci_scan_child_bus(child_bus); list_for_each_entry (child_dev, &child_bus->devices, bus_list) {eeh_add_device_late (child_dev);
@@ -503,7 +505,7 @@return retval; } -struct hotplug_slot *rpaphp_find_hotplug_slot (struct pci_dev *dev) +static struct slot *rpaphp_find_slot (struct pci_dev *dev) {struct list_head *tmp, *n;struct slot *slot;
@@ -528,11 +530,33 @@for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) {struct pci_dev *pdev =pci_dev_b (ln);if (pdev == dev) -return slot->hotplug_slot; +return slot; } }return NULL ; } -EXPORT_SYMBOL_GPL (rpaphp_find_hotplug_slot); +int handle_eeh_events (struct notifier_block *self, +unsigned long reason,void *ev) +{ +struct eeh_event *event = ev; + +/* Just turn it off for now */ +rpaphp_unconfig_pci_adapter (rpaphp_find_slot (event->dev)); +return 0 ; +} + +static struct notifier_block eeh_block; + +void __init init_eeh_handler (void ) +{ + eeh_block.notifier_call = handle_eeh_events; +eeh_register_notifier (&eeh_block); +} + +void __exit exit_eeh_handler (void) +{ +eeh_unregister_notifier (&eeh_block); +} +
drivers/pci/hotplug/rpaphp.h line 128
Quoted 10 lines · On Wed, Jul 07, 2004 at 04:47:39PM -0500, [email protected] wrote:
=====
drivers/pci/hotplug/rpaphp.h1.9 vs edited =====drivers/pci/hotplug/rpaphp.h +2
-1@@ -124,7 +124,8 @@extern int register_pci_slot (struct slot *slot);extern int rpaphp_unconfig_pci_adapter (struct slot *slot);extern int rpaphp_get_pci_adapter_status (struct slot *slot,int is_init,u8 * value); -extern struct hotplug_slot *rpaphp_find_hotplug_slot (struct pci_dev *dev); +extern void init_eeh_handler (void ); +extern void exit_eeh_handler (void );
This belongs in the eeh header file, not the rpaphp.h file.
drivers/pci/hotplug/rpaphp.h line 232
Quoted 6 lines
drivers/pci/hotplug/rpaphp.h +1
-1@@ -227,7 +229,7 @@ }sprintf (child_bus->name,"PCI Bus #%02x" , child_bus->number);/* do pci_scan_child_bus */ -pci_scan_child_bus (child_bus); +// pci_scan_child_bus(child_bus);
And the reason you are commenting out this function is...
thanks,
greg k-h
Quoted 7 lines · Greg KH
drivers/pci/hotplug/rpaphp.h line 128
Quoted 3 lines · On Wed, Jul 07, 2004 at 04:47:39PM -0500, [email protected] wrote:
=====
drivers/pci/hotplug/rpaphp.h1.9 vs edited =====drivers/pci/hotplug/rpaphp.h +2
-0+extern void init_eeh_handler (void ); +extern void exit_eeh_handler (void );This belongs in the eeh header file, not the
rpaphp.hfile.
But these are implemented in rpaphp_pci.c and are called in rpaphp_core.c. Perchance a different function name, such as init_rpaphp_eeh_handler() be better?
Quoted 3 lines
drivers/pci/hotplug/rpaphp_pci.c line 232
Quoted 1 line
drivers/pci/hotplug/rpaphp_pci.c +1
-0+// pci_scan_child_bus(child_bus); And the reason you are commenting out this function is...
Due to a mistake.
--linas
Quoted 9 lines · On Thu, Jul 08, 2004 at 10:04:33AM -0500, [email protected] wrote:
Quoted 7 lines · Greg KH
drivers/pci/hotplug/rpaphp.h line 128
Quoted 3 lines · On Wed, Jul 07, 2004 at 04:47:39PM -0500, [email protected] wrote:
=====
drivers/pci/hotplug/rpaphp.h1.9 vs edited =====drivers/pci/hotplug/rpaphp.h +2
-0+extern void init_eeh_handler (void ); +extern void exit_eeh_handler (void );This belongs in the eeh header file, not the
rpaphp.hfile.
Quoted 3 lines
But these are implemented in
rpaphp_pci.cand are called inrpaphp_core.c. Perchance a different function name, such asinit_rpaphp_eeh_handler()be better?
Ah, yes, see I didn't even catch that :)
They should start with "rpaphp" as they are global symbols.
thanks,
greg k-h
drivers/pci/hotplug/rpaphp_pci.c line 232
Quoted 12 lines · [email protected] wrote:
} sprintf(child_bus->name, "PCI Bus #%02x", child_bus->number); /* do pci_scan_child_bus */drivers/pci/hotplug/rpaphp_pci.c +1
-1-pci_scan_child_bus (child_bus); +// pci_scan_child_bus(child_bus);
Why remove pci_scan_child_bus call?
Linda
Quoted 9 lines · Linda Xie
drivers/pci/hotplug/rpaphp_pci.c line 232
Quoted 6 lines · [email protected] wrote:
} sprintf(child_bus->name, "PCI Bus #%02x", child_bus->number); /* do pci_scan_child_bus */drivers/pci/hotplug/rpaphp_pci.c +1
-1-pci_scan_child_bus (child_bus); +// pci_scan_child_bus(child_bus); Why remove
pci_scan_child_buscall?
Because it won't compile otherwise. (Actually, I didn't mean to leave that in the patch, it was a work-around to get my tree to compile).
pci_scan_child_bus() is currently defined only as a static fuction in drivers/pci/probe.c and thus cannot be called outside of that file. Maybe there's a patch to drivers/pci/probe.c that hasn't been applied yet?
--linas
Quoted 11 lines · On Wed, Jul 07, 2004 at 07:06:42PM -0500, [email protected] wrote:
Quoted 9 lines · Linda Xie
drivers/pci/hotplug/rpaphp_pci.c line 232
Quoted 6 lines · [email protected] wrote:
} sprintf(child_bus->name, "PCI Bus #%02x", child_bus->number); /* do pci_scan_child_bus */drivers/pci/hotplug/rpaphp_pci.c +1
-1-pci_scan_child_bus (child_bus); +// pci_scan_child_bus(child_bus); Why remove
pci_scan_child_buscall?
Quoted 8 lines
Because it won't compile otherwise. (Actually, I didn't mean to leave that in the patch, it was a work-around to get my tree to compile).
pci_scan_child_bus()is currently defined only as a static fuction indrivers/pci/probe.cand thus cannot be called outside of that file. Maybe there's a patch todrivers/pci/probe.cthat hasn't been applied yet?
It's in the latest -bk tree, right?
greg k-h
Quoted 3 lines · Greg KH
Quoted 1 line
pci_scan_child_bus()is currently ...It's in the latest -bk tree, right?
yes, it looks correct in the current tree (it wasn't when
I'd previously cloned). It's possible I'm not using bk correctly;
once I've modified a file, 'bk pull' never merges in newer changes made upstream. So I have to 'bk clone' all the time, which is a pain in the neck. What am I doing wrong?
--linas
Quoted 10 lines · On Thu, Jul 08, 2004 at 10:24:25AM -0500, [email protected] wrote:
Quoted 3 lines · Greg KH
Quoted 1 line
pci_scan_child_bus()is currently ...It's in the latest -bk tree, right?
yes, it looks correct in the current tree (it wasn't when
I'd previously cloned). It's possible I'm not using bk correctly;
once I've modified a file, 'bk pull' never merges in newer changes made upstream. So I have to 'bk clone' all the time, which is a pain in the neck. What am I doing wrong?
Not checking in your file before pulling.
greg k-h