]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/powerpc/platforms/pseries/eeh_driver.c
[PATCH] powerpc/pseries: clear PCI failure counter if no new failures
[linux-2.6-omap-h63xx.git] / arch / powerpc / platforms / pseries / eeh_driver.c
index e3cbba49fd6e83466be3074294e543ccc576e768..2a9eb26307306fa2b447f18cdde1ea2399de7d4e 100644 (file)
@@ -23,9 +23,8 @@
  *
  */
 #include <linux/delay.h>
-#include <linux/irq.h>
 #include <linux/interrupt.h>
-#include <linux/notifier.h>
+#include <linux/irq.h>
 #include <linux/pci.h>
 #include <asm/eeh.h>
 #include <asm/eeh_event.h>
@@ -37,7 +36,7 @@
 
 static inline const char * pcid_name (struct pci_dev *pdev)
 {
-       if (pdev->dev.driver)
+       if (pdev && pdev->dev.driver)
                return pdev->dev.driver->name;
        return "";
 }
@@ -250,13 +249,14 @@ static int eeh_reset_device (struct pci_dn *pe_dn, struct pci_bus *bus)
  */
 #define MAX_WAIT_FOR_RECOVERY 15
 
-void handle_eeh_events (struct eeh_event *event)
+struct pci_dn * handle_eeh_events (struct eeh_event *event)
 {
        struct device_node *frozen_dn;
        struct pci_dn *frozen_pdn;
        struct pci_bus *frozen_bus;
        int rc = 0;
        enum pci_ers_result result = PCI_ERS_RESULT_NONE;
+       const char *pci_str, *drv_str;
 
        frozen_dn = find_device_pe(event->dn);
        frozen_bus = pcibios_find_pci_bus(frozen_dn);
@@ -264,7 +264,7 @@ void handle_eeh_events (struct eeh_event *event)
        if (!frozen_dn) {
                printk(KERN_ERR "EEH: Error: Cannot find partition endpoint for %s\n",
                        pci_name(event->dev));
-               return;
+               return NULL;
        }
 
        /* There are two different styles for coming up with the PE.
@@ -279,7 +279,7 @@ void handle_eeh_events (struct eeh_event *event)
        if (!frozen_bus) {
                printk(KERN_ERR "EEH: Cannot find PCI bus for %s\n",
                        frozen_dn->full_name);
-               return;
+               return NULL;
        }
 
 #if 0
@@ -291,9 +291,17 @@ void handle_eeh_events (struct eeh_event *event)
 
        frozen_pdn = PCI_DN(frozen_dn);
        frozen_pdn->eeh_freeze_count++;
+
+       if (frozen_pdn->pcidev) {
+               pci_str = pci_name (frozen_pdn->pcidev);
+               drv_str = pcid_name (frozen_pdn->pcidev);
+       } else {
+               pci_str = pci_name (event->dev);
+               drv_str = pcid_name (event->dev);
+       }
        
        if (frozen_pdn->eeh_freeze_count > EEH_MAX_ALLOWED_FREEZES)
-               goto hard_fail;
+               goto excess_failures;
 
        /* If the reset state is a '5' and the time to reset is 0 (infinity)
         * or is more then 15 seconds, then mark this as a permanent failure.
@@ -306,9 +314,7 @@ void handle_eeh_events (struct eeh_event *event)
        eeh_slot_error_detail(frozen_pdn, 1 /* Temporary Error */);
        printk(KERN_WARNING
           "EEH: This PCI device has failed %d times since last reboot: %s - %s\n",
-               frozen_pdn->eeh_freeze_count,
-               pci_name (frozen_pdn->pcidev), 
-               pcid_name(frozen_pdn->pcidev));
+               frozen_pdn->eeh_freeze_count, drv_str, pci_str);
 
        /* Walk the various device drivers attached to this slot through
         * a reset sequence, giving each an opportunity to do what it needs
@@ -348,9 +354,9 @@ void handle_eeh_events (struct eeh_event *event)
        /* Tell all device drivers that they can resume operations */
        pci_walk_bus(frozen_bus, eeh_report_resume, NULL);
 
-       return;
+       return frozen_pdn;
        
-hard_fail:
+excess_failures:
        /*
         * About 90% of all real-life EEH failures in the field
         * are due to poorly seated PCI cards. Only 10% or so are
@@ -360,10 +366,16 @@ hard_fail:
           "EEH: PCI device %s - %s has failed %d times \n"
           "and has been permanently disabled.  Please try reseating\n"
           "this device or replacing it.\n",
-               pci_name (frozen_pdn->pcidev), 
-               pcid_name(frozen_pdn->pcidev), 
-               frozen_pdn->eeh_freeze_count);
+               drv_str, pci_str, frozen_pdn->eeh_freeze_count);
+       goto perm_error;
+
+hard_fail:
+       printk(KERN_ERR
+          "EEH: Unable to recover from failure of PCI device %s - %s\n"
+          "Please try reseating this device or replacing it.\n",
+               drv_str, pci_str);
 
+perm_error:
        eeh_slot_error_detail(frozen_pdn, 2 /* Permanent Error */);
 
        /* Notify all devices that they're about to go down. */
@@ -371,6 +383,8 @@ hard_fail:
 
        /* Shut down the device drivers for good. */
        pcibios_remove_pci_devices(frozen_bus);
+
+       return NULL;
 }
 
 /* ---------- end of file ---------- */