powerpc/powernv: Rework EEH reset
Subsystems (2)
PATCH 2/3 powerpc/eeh: Cleanup on eeh_subsystem_enabled
In reply to Gavin ShanThe patch cleans up variable eeh_subsystem_enabled so that we needn't refer the variable directly from external. Instead, we will use function eeh_enabled() and eeh_set_enable() to operate the variable.
--- arch/powerpc/include/asm/eeh.h | 21 +++++++++++++++++++-- arch/powerpc/kernel/eeh.c | 12 ++++++------ arch/powerpc/platforms/powernv/eeh-powernv.c | 2 +- arch/powerpc/platforms/pseries/eeh_pseries.c | 2 +- 4 files changed, 27 insertions(+), 10 deletions(-)
arch/powerpc/include/asm/eeh.h +19 -2
@@ -172,10 +172,20 @@ struct eeh_ops { };extern struct eeh_ops *eeh_ops; -extern int eeh_subsystem_enabled; +extern bool eeh_subsystem_enabled;extern raw_spinlock_t confirm_error_lock;extern int eeh_probe_mode; +static inline bool eeh_enabled (void ) +{ +return eeh_subsystem_enabled; +} + +static inline void eeh_set_enable (bool mode) +{ + eeh_subsystem_enabled = mode; +} +#define EEH_PROBE_MODE_DEV (1<<0)/* From PCI device */ #define EEH_PROBE_MODE_DEVTREE (1<<1)/* From device tree */
@@ -246,7 +256,7 @@ void eeh_remove_device(struct pci_dev *);* If this macro yields TRUE, the caller relays to eeh_check_failure() * which does further tests out of line. */ -#define EEH_POSSIBLE_ERROR (val, type) ((val) == (type)~0 && eeh_subsystem_enabled) +#define EEH_POSSIBLE_ERROR (val, type) ((val) == (type)~0 && eeh_enabled())/* * Reads from a device which has been isolated by EEH will return
@@ -257,6 +267,13 @@ void eeh_remove_device(struct pci_dev *);#else /* !CONFIG_EEH */ +static inline bool eeh_enabled (void ) +{ +return false; +} + +static inline void eeh_set_enable (bool mode) { } +static inline int eeh_init (void ) {return 0 ;
arch/powerpc/kernel/eeh.c +6 -6
@@ -89,7 +89,7 @@/* Platform dependent EEH operations */ struct eeh_ops *eeh_ops =NULL ; -int eeh_subsystem_enabled; +bool eeh_subsystem_enabled = false;EXPORT_SYMBOL (eeh_subsystem_enabled);/*
@@ -364,7 +364,7 @@ int eeh_dev_check_failure(struct eeh_dev *edev) eeh_stats.total_mmio_ffs++; -if (!eeh_subsystem_enabled) +if (!eeh_enabled ())return 0 ;if (!edev) {
@@ -822,7 +822,7 @@ int eeh_init(void)return ret; } -if (eeh_subsystem_enabled) +if (eeh_enabled ())pr_info ("EEH: PCI Enhanced I/O Error Handling Enabled\n" );else pr_warning ("EEH: No capable adapters found\n" );
@@ -897,7 +897,7 @@ void eeh_add_device_late(struct pci_dev *dev)struct device_node *dn;struct eeh_dev *edev; -if (!dev || !eeh_subsystem_enabled) +if (!dev || !eeh_enabled ())return ;pr_debug ("EEH: Adding device %s\n" ,pci_name (dev));
@@ -1005,7 +1005,7 @@ void eeh_remove_device(struct pci_dev *dev) {struct eeh_dev *edev; -if (!dev || !eeh_subsystem_enabled) +if (!dev || !eeh_enabled ())return ; edev =pci_dev_to_eeh_dev (dev);
@@ -1045,7 +1045,7 @@ void eeh_remove_device(struct pci_dev *dev)static int proc_eeh_show (struct seq_file *m,void *v) { -if (0 == eeh_subsystem_enabled) { +if (!eeh_enabled ()) {seq_printf (m,"EEH Subsystem is globally disabled\n" );seq_printf (m,"eeh_total_mmio_ffs=%llu\n" , eeh_stats.total_mmio_ffs); }else {
arch/powerpc/platforms/powernv/eeh-powernv.c +1 -1
@@ -145,7 +145,7 @@ static int powernv_eeh_dev_probe(struct pci_dev *dev, void *flag)* Enable EEH explicitly so that we will do EEH check * while accessing I/O stuff */ - eeh_subsystem_enabled =1 ; +eeh_set_enable (true);/* Save memory bars */ eeh_save_bars (edev);
arch/powerpc/platforms/pseries/eeh_pseries.c +1 -1
@@ -265,7 +265,7 @@ static void *pseries_eeh_of_probe(struct device_node *dn, void *flag) enable =1 ;if (enable) { - eeh_subsystem_enabled =1 ; +eeh_set_enable (true);eeh_add_to_parent_pe (edev); pr_debug("%s: EEH enabled on %s PHB#%d-PE#%x, config addr#%x\n",
Signature · 1 line
1.7.10.4
PATCH 1/3 powerpc/powernv: Rework EEH reset
When doing reset in order to recover the affected PE, we issue hot reset on PE primary bus if it's not root bus. Otherwise, we issue hot or fundamental reset on root port or PHB accordingly. For the later case, we didn't cover the situation where PE only includes root port and it potentially causes kernel crash upon EEH error to the PE.
The patch reworks the logic of EEH reset to improve the code readability and also avoid the kernel crash.
--- arch/powerpc/platforms/powernv/eeh-ioda.c | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-)
arch/powerpc/platforms/powernv/eeh-ioda.c +4 -25
@@ -489,8 +489,7 @@ static int ioda_eeh_bridge_reset(struct pci_controller *hose,static int ioda_eeh_reset (struct eeh_pe *pe,int option) {struct pci_controller *hose = pe->phb; -struct eeh_dev *edev; -struct pci_dev *dev; +struct pci_bus *bus;int ret;/*
@@ -519,31 +518,11 @@ static int ioda_eeh_reset(struct eeh_pe *pe, int option)if (pe->type &EEH_PE_PHB ) { ret =ioda_eeh_phb_reset (hose, option); }else { -if (pe->type &EEH_PE_DEVICE ) { -/* -* If it's device PE, we didn't refer to the parent -* PCI bus yet. So we have to figure it out indirectly. -*/ - edev =list_first_entry (&pe->edevs, - struct eeh_dev, list); - dev =eeh_dev_to_pci_dev (edev); - dev = dev->bus->self; - }else { -/* -* If it's bus PE, the parent PCI bus is already there -* and just pick it up. -*/ - dev = pe->bus->self; - } - -/* -* Do reset based on the fact that the direct upstream bridge -* is root bridge (port) or not. -*/ -if (dev->bus->number ==0 ) + bus =eeh_pe_bus_get (pe); +if (pci_is_root_bus (bus)) ret =ioda_eeh_root_reset (hose, option);else - ret =ioda_eeh_bridge_reset (hose, dev, option); + ret =ioda_eeh_bridge_reset (hose, bus->self, option); }return ret;
Signature · 1 line
1.7.10.4
PATCH 3/3 powerpc/eeh: Disable EEH on reboot
We possiblly detect EEH errors during reboot, particularly in kexec path, but it's impossible for device drivers and EEH core to handle or recover them properly.
The patch registers one reboot notifier for EEH and disable EEH subsystem during reboot. That means the EEH errors is going to be cleared by hardware reset or second kernel during early stage of PCI probe.
--- arch/powerpc/kernel/eeh.c | 20 ++++++++++++++++++++ arch/powerpc/platforms/powernv/eeh-ioda.c | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-)
arch/powerpc/kernel/eeh.c +20 -0
@@ -28,6 +28,7 @@#include <linux/pci.h> #include <linux/proc_fs.h> #include <linux/rbtree.h> +#include <linux/reboot.h> #include <linux/seq_file.h> #include <linux/spinlock.h> #include <linux/export.h>
@@ -747,6 +748,17 @@ int __exit eeh_ops_unregister(const char *name)return -EEXIST ; } +static int eeh_reboot_notifier (struct notifier_block *nb, +unsigned long action,void *unused) +{ +eeh_set_enable (false); +return NOTIFY_DONE ; +} + +static struct notifier_block eeh_reboot_nb = { + .notifier_call = eeh_reboot_notifier, +}; +/** * eeh_init - EEH initialization *
@@ -778,6 +790,14 @@ int eeh_init(void)if (machine_is (powernv) && cnt++ <=0 )return ret; +/* Register reboot notifier */ + ret =register_reboot_notifier (&eeh_reboot_nb); +if (ret) { +pr_warn ("%s: Failed to register notifier (%d)\n" , + __func__, ret); +return ret; + } +/* call platform initialization function */ if (!eeh_ops) { pr_warning("%s: Platform EEH operation not found\n",
arch/powerpc/platforms/powernv/eeh-ioda.c +2 -1
@@ -44,7 +44,8 @@ static int ioda_eeh_event(struct notifier_block *nb,/* We simply send special EEH event */ if ((changed_evts &OPAL_EVENT_PCI_ERROR ) && - (events &OPAL_EVENT_PCI_ERROR )) + (events &OPAL_EVENT_PCI_ERROR ) && +eeh_enabled ())eeh_send_failure_event (NULL );return 0 ;
Signature · 1 line
1.7.10.4