PCI Error Recovery
Hmm, failed to cc the kernel mailing list ...
----- Forwarded message from Linas Vepstas <[email protected]> -----
To: Hidetoshi Seto <[email protected]>
Cc: Greg KH <[email protected]>, [email protected], [email protected],
Benjamin Herrenschmidt <[email protected]>,
Paul Mackerras <[email protected]>, [email protected], long <[email protected]>
Subject: [PATCH/RFC] PCI Error Recovery
From: Linas Vepstas <[email protected]>
Hi,
Appended is my current draft PCI Error Recovery patch. Per previous conversatios, it has moved some of the ppc64-specific error reporting code into generic PCI structures: see changes to include/linux/pci.h and a new file drivers/pci/pci-error.c. Note in particular the pci bus states enumerated in
"enum pci_device_io_state"; BenH was suggesting having more of these ... BenH do you want to propose a "final list"?
I named the generic pci error recovery routines "peh" because my brain froze. Better suggestions invited.
The patch includes error recovery code for the IPR scsi device driver that uses the new generic PCI interfaces. There's also some prototype symbios scsi recovery code, but I haven't had a chance to test it due to hardware issues. Ignore the debug statements.
The last chunk of this patch is ppc64 specific code; it uses the new generic interfaces where it can.
Please review, comment, criticize and suggest. I am eager to get the pci-generic parts nailed down, and want to really start moving in a direction that would let this go into mainline.
--linas
p.s. It should apply cleanly to kernel.org 2.6.11 and will recover from pci errors sent to IPR and ethernet on power5 boxes. I haven't tested on power4.
linux/pci.h renamed from linux/pci.h.linas-orig +58 -0
@@ -659,6 +659,63 @@ struct pci_dynids { unsigned int use_driver_data:1; /* pci_driver->driver_data is used */ }; +/* ---------------------------------------------------------------- */ +/** PCI error recovery state. Whenever the PCI bus state changes, +* the io_state_change() callback will be called to notify the +* device driver os state changes. +*/ + +enum pci_device_io_state { + pci_device_io_frozen =1 ,/* I/O to device is blocked */ + pci_device_io_thawed,/* I/O te device is (re-)enabled */ + pci_device_io_perm_failure,/* pci card is dead */ +}; + +/** +* PCI Error notifier event flags. +*/ +#define PEH_NOTIFY_ERROR 1 + +/** PEH event -- structure holding pci controller data that describes +* a change in the isolation status of a PCI slot. A pointer +* to this struct is passed as the data pointer in a notify callback. +*/ +struct peh_event { +struct list_head list; +struct pci_dev *dev;/* affected device */ +enum pci_device_io_state state;/* PCI bus state for the affected device */ +int time_unavail;/* milliseconds until device might be available */ +}; + +/** +* peh_send_failure_event - generate a PCI error event +* @dev pci device +* +* This routine builds a PCI error event which will be delivered +* to all listeners on the peh_notifier_chain. +* +* This routine can be called within an interrupt context; +* the actual event will be delivered in a normal context +* (from a workqueue). +*/ +int peh_send_failure_event (struct pci_dev *dev, +enum pci_device_io_state state, +int time_unavail); + +/** +* peh_register_notifier - Register to find out about EEH events. +* @nb: notifier block to callback on events +*/ +int peh_register_notifier (struct notifier_block *nb); + +/** +* peh_unregister_notifier - Unregister to an EEH event notifier. +* @nb: notifier block to callback on events +*/ +int peh_unregister_notifier (struct notifier_block *nb); + +/* ---------------------------------------------------------------- */ +struct module ;struct pci_driver {struct list_head node;
@@ -670,6 +727,7 @@ struct pci_driver {int (*suspend) (struct pci_dev *dev,pm_message_t state);/* Device suspended */ int (*resume) (struct pci_dev *dev);/* Device woken up */ int (*enable_wake) (struct pci_dev *dev,u32 state,int enable);/* Enable wake event */ +int (*io_state_change) (struct pci_dev *,enum pci_device_io_state );/* state change */ struct device_driver driver;struct pci_dynids dynids;
pci/Makefile renamed from pci/Makefile.linas-orig +1 -1
@@ -3,7 +3,7 @@ # obj-y += access.o bus.o probe.o remove.o pci.o quirks.o \ - names.o pci-driver.o search.o pci-sysfs.o \ + names.o pci-driver.o pci-error.o search.o pci-sysfs.o \ rom.o obj-$(CONFIG_PROC_FS) += proc.o
pci/pci-error.c renamed from pci/pci-error.c.linas-orig +152 -0
152 lines not on this page · raw message
scsi/ipr.c renamed from scsi/ipr.c.linas-orig +66 -0
90 lines not on this page · raw message
scsi/ipr.h renamed from scsi/ipr.h.linas-orig +4 -2
@@ -1132,9 +1132,11 @@ struct ipr_ucode_image_header {#define ipr_trace ipr_dbg("%s: %s: Line: %d\n",\ __FILE__, __FUNCTION__, __LINE__) +#undef IPR_DBG_TRACE +#define IPR_DBG_TRACE 1#if IPR_DBG_TRACE -#define ENTER printk(KERN_INFO IPR_NAME": Entering %s\n", __FUNCTION__) -#define LEAVE printk(KERN_INFO IPR_NAME": Leaving %s\n", __FUNCTION__) +#define ENTER printk(KERN_INFO IPR_NAME": Entering %s jiffies=%lu\n", __FUNCTION__, jiffies) +#define LEAVE printk(KERN_INFO IPR_NAME": Leaving %s jiffies=%lu\n", __FUNCTION__, jiffies)#else #define ENTER #define LEAVE
scsi/sym53c8xx_2/sym_glue.c renamed from scsi/sym53c8xx_2/sym_glue.c.linas-orig +75 -0
111 lines not on this page · raw message
scsi/sym53c8xx_2/sym_glue.h renamed from scsi/sym53c8xx_2/sym_glue.h.linas-orig +4 -0
@@ -358,6 +358,10 @@ struct sym_shcb {char chip_name[8 ];struct pci_dev *device; +/* pci bus i/o state; waiter for clearing of i/o state */ +enum pci_device_io_state io_state; +struct sym_eh_wait *io_reset_wait; +struct Scsi_Host *host;void __iomem * mmio_va;/* MMIO kernel virtual address */
scsi/sym53c8xx_2/sym_hipd.c renamed from scsi/sym53c8xx_2/sym_hipd.c.linas-orig +10 -0
@@ -2836,6 +2836,7 @@ void sym_interrupt (struct sym_hcb *np)u_char istat, istatc;u_char dstat;u_short sist; +u_int icnt;/* * interrupt on the fly ?
@@ -2877,6 +2878,7 @@ void sym_interrupt (struct sym_hcb *np) sist =0 ; dstat =0 ; istatc = istat; + icnt =0 ; do { if (istatc & SIP) sist |= INW (nc_sist);
@@ -2884,6 +2886,14 @@ void sym_interrupt (struct sym_hcb *np) dstat |=INB (nc_dstat); istatc =INB (nc_istat); istat |= istatc; + icnt ++; +if (100 < icnt) { +#define CONFIG_SCSI_SYM53C8XX_EEH_RECOVERY +#ifdef CONFIG_SCSI_SYM53C8XX_EEH_RECOVERY +if (eeh_slot_is_isolated (np->s.device)) +return ; +#endif /* CONFIG_SCSI_SYM53C8XX_EEH_RECOVERY */ + } }while (istatc & (SIP |DIP ));if (DEBUG_FLAGS &DEBUG_TINY )
asm-ppc64/eeh.h renamed from asm-ppc64/eeh.h.linas-orig +75 -22
122 lines not on this page · raw message
asm-ppc64/prom.h renamed from asm-ppc64/prom.h.linas-orig +5 -0
@@ -119,6 +119,7 @@ struct property {*/ struct pci_controller ;struct iommu_table ; +struct eeh_recovery_ops ;struct device_node {char *name;
@@ -137,8 +138,12 @@ struct device_node {int devfn;/* for pci devices */ int eeh_mode;/* See eeh.h for possible EEH_MODEs */ int eeh_config_addr; +int eeh_check_count;/* number of times device driver ignored error */ +int eeh_freeze_count;/* number of times this device froze up. */ +int eeh_is_bridge;/* device is pci-to-pci bridge */ struct pci_controller *phb;/* for pci devices */ struct iommu_table *iommu_table;/* for phb's or bridges */ +u32 config_space[16 ];/* saved PCI config space */ struct property *properties;struct device_node *parent;
asm-ppc64/rtas.h renamed from asm-ppc64/rtas.h.linas-orig +2 -0
@@ -243,4 +243,6 @@ extern unsigned long rtas_rmo_buf;#define GLOBAL_INTERRUPT_QUEUE 9005 +extern int rtas_write_config (struct device_node *dn,int where,int size,u32 val); +#endif /* _PPC64_RTAS_H */
ppc64/kernel/eeh.c renamed from ppc64/kernel/eeh.c.linas-orig +371 -150
743 lines not on this page · raw message
ppc64/kernel/pSeries_pci.c renamed from ppc64/kernel/pSeries_pci.c.linas-orig +1 -1
@@ -101,7 +101,7 @@ static int rtas_pci_read_config(struct preturn PCIBIOS_DEVICE_NOT_FOUND ; } -static int rtas_write_config (struct device_node *dn,int where,int size,u32 val) +int rtas_write_config (struct device_node *dn,int where,int size,u32 val) {unsigned long buid, addr;int ret;
pci/hotplug/rpaphp.h renamed from pci/hotplug/rpaphp.h.linas-orig +2 -1
@@ -118,7 +118,8 @@ extern int rpaphp_enable_pci_slot(structextern 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);
pci/hotplug/rpaphp_core.c renamed from pci/hotplug/rpaphp_core.c.linas-orig +6 -0
@@ -460,12 +460,18 @@ static int __init rpaphp_init(void) {info (DRIVER_DESC " version: " DRIVER_VERSION "\n" ); +/* Get set to handle EEH events. */ +init_eeh_handler (); +/* read all the PRA info from the system */ return init_rpa (); } static void __exit rpaphp_exit(void) { +/* Let EEH know we are going away. */ +exit_eeh_handler (); +cleanup_slots (); }
pci/hotplug/rpaphp_pci.c renamed from pci/hotplug/rpaphp_pci.c.linas-orig +268 -24
362 lines not on this page · raw message
----- End forwarded message -----