powerpc/eeh: for 2.6.23: a fix for bridges, and tweaks
Subsystems (2)
cover powerpc/eeh: for 2.6.23: a fix for bridges, and tweaks
Paul,
The following three patches should be low impact, and I think they could go into 2.6.23 if its not too late.
-- two are formating/printing fixes/enhancements
-- one fixes the way PCI cards with bridges are handled;
in particular, it avoids a nll pointer deref, so is a serious bugfix.
Linas.
PATCH 1/3 powerpc/eeh: tweak printk message.
Print return code to print message. Also fix whitespace.
----
arch/powerpc/platforms/pseries/eeh.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/platforms/pseries/eeh.c +4 -4
@@ -750,12 +750,12 @@ int rtas_set_slot_reset(struct pci_dn *preturn 0 ;if (rc <0 ) { -printk (KERN_ERR "EEH: unrecoverable slot failure %s\n" , - pdn->node->full_name); +printk (KERN_ERR "EEH: unrecoverable slot failure %s\n" , + pdn->node->full_name);return -1 ; } -printk (KERN_ERR "EEH: bus reset %d failed on slot %s\n" , - i+1 , pdn->node->full_name); +printk (KERN_ERR "EEH: bus reset %d failed on slot %s, rc=%d\n" , + i+1 , pdn->node->full_name, rc); }return -1 ;
PATCH 2/3 powerpc/eeh: Fix pci bridge handling bug
The EEH code needs to ignore PCI bridges; sort-of. It was ignoring them in the wrong place, and thus failing to set up the PCI_DN(dn)->pcidev pointer. Imprudent dereferencing of this pointer would lead to a crash on cards with bridges.
----
arch/powerpc/platforms/pseries/eeh_cache.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
arch/powerpc/platforms/pseries/eeh_cache.c +5 -4
@@ -225,6 +225,10 @@ void pci_addr_cache_insert_device(struct {unsigned long flags; +/* Ignore PCI bridges */ +if ((dev->class >>16 ) ==PCI_BASE_CLASS_BRIDGE ) +return ; +spin_lock_irqsave (&pci_io_addr_cache_root.piar_lock, flags);__pci_addr_cache_insert_device (dev);spin_unlock_irqrestore (&pci_io_addr_cache_root.piar_lock, flags);
@@ -285,16 +289,13 @@ void __init pci_addr_cache_build(void)spin_lock_init (&pci_io_addr_cache_root.piar_lock);while ((dev =pci_get_device (PCI_ANY_ID ,PCI_ANY_ID , dev)) !=NULL ) { -/* Ignore PCI bridges */ -if ((dev->class >>16 ) ==PCI_BASE_CLASS_BRIDGE ) -continue ;pci_addr_cache_insert_device (dev); dn =pci_device_to_OF_node (dev);if (!dn)continue ; -pci_dev_get (dev);/* matching put is in eeh_remove_device() */ +pci_dev_get (dev);/* matching put is in eeh_remove_device() */ PCI_DN (dn)->pcidev = dev;eeh_sysfs_add_device (dev);
PATCH 3/3 powerpc/eeh: dump pci bridge status on event
Gather bridge-specific data on EEH events.
----
arch/powerpc/platforms/pseries/eeh.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
arch/powerpc/platforms/pseries/eeh.c +26 -1
@@ -169,6 +169,8 @@ static void rtas_slot_error_detail(struc*/ static size_t gather_pci_data (struct pci_dn *pdn,char * buf,size_t len) { +struct device_node *dn; +struct pci_dev *dev = pdn->pcidev;u32 cfg;int cap, i;int n =0 ;
@@ -184,6 +186,17 @@ static size_t gather_pci_data(struct pci n +=scnprintf (buf+n, len-n,"cmd/stat:%x\n" , cfg);printk (KERN_WARNING "EEH: PCI cmd/status register: %08x\n" , cfg); +/* Gather bridge-specific registers */ +if (dev->class >>16 ==PCI_BASE_CLASS_BRIDGE ) { +rtas_read_config (pdn,PCI_SEC_STATUS ,2 , &cfg); + n +=scnprintf (buf+n, len-n,"sec stat:%x\n" , cfg); +printk (KERN_WARNING "EEH: Bridge secondary status: %04x\n" , cfg); + +rtas_read_config (pdn,PCI_BRIDGE_CONTROL ,2 , &cfg); + n +=scnprintf (buf+n, len-n,"brdg ctl:%x\n" , cfg); +printk (KERN_WARNING "EEH: Bridge control: %04x\n" , cfg); + } +/* Dump out the PCI-X command and status regs */ cap =pci_find_capability (pdn->pcidev,PCI_CAP_ID_PCIX );if (cap) {
@@ -209,7 +222,7 @@ static size_t gather_pci_data(struct pciprintk (KERN_WARNING "EEH: PCI-E %02x: %08x\n" , i, cfg); } - cap =pci_find_ext_capability (pdn->pcidev,PCI_EXT_CAP_ID_ERR ); + cap =pci_find_ext_capability (pdn->pcidev,PCI_EXT_CAP_ID_ERR );if (cap) { n +=scnprintf (buf+n, len-n,"pci-e AER:\n" ); printk(KERN_WARNING
@@ -222,6 +235,18 @@ static size_t gather_pci_data(struct pci } } } + +/* Gather status on devices under the bridge */ +if (dev->class >>16 ==PCI_BASE_CLASS_BRIDGE ) { + dn = pdn->node->child; +while (dn) { + pdn =PCI_DN (dn); +if (pdn) + n +=gather_pci_data (pdn, buf+n, len-n); + dn = dn->sibling; + } + } +return n; }