powerpc/eeh: Clean up and document event handling functions
authorRussell Currey <ruscur@russell.cc>
Wed, 19 Apr 2017 07:39:27 +0000 (17:39 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 2 May 2017 12:41:43 +0000 (22:41 +1000)
Remove unnecessary tags in eeh_handle_normal_event(), and add function
comments for eeh_handle_normal_event() and eeh_handle_special_event().

The only functional difference is that in the case of a PE reaching the
maximum number of failures, rather than one message telling you of this
and suggesting you reseat the device, there are two separate messages.

Suggested-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Russell Currey <ruscur@russell.cc>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/eeh_driver.c

index e50d1470714fcc5a1223dc59f4be0734e4eaf611..c405c79e50cdc99267e0fe1bb08aff4578064ce8 100644 (file)
@@ -724,6 +724,15 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,
  */
 #define MAX_WAIT_FOR_RECOVERY 300
 
+/**
+ * eeh_handle_normal_event - Handle EEH events on a specific PE
+ * @pe: EEH PE
+ *
+ * Attempts to recover the given PE.  If recovery fails or the PE has failed
+ * too many times, remove the PE.
+ *
+ * Returns true if @pe should no longer be used, else false.
+ */
 static bool eeh_handle_normal_event(struct eeh_pe *pe)
 {
        struct pci_bus *frozen_bus;
@@ -741,8 +750,13 @@ static bool eeh_handle_normal_event(struct eeh_pe *pe)
 
        eeh_pe_update_time_stamp(pe);
        pe->freeze_count++;
-       if (pe->freeze_count > eeh_max_freezes)
-               goto excess_failures;
+       if (pe->freeze_count > eeh_max_freezes) {
+               pr_err("EEH: PHB#%x-PE#%x has failed %d times in the\n"
+                      "last hour and has been permanently disabled.\n",
+                      pe->phb->global_number, pe->addr,
+                      pe->freeze_count);
+               goto hard_fail;
+       }
        pr_warn("EEH: This PCI device has failed %d times in the last hour\n",
                pe->freeze_count);
 
@@ -872,25 +886,16 @@ static bool eeh_handle_normal_event(struct eeh_pe *pe)
 
        return false;
 
-excess_failures:
+hard_fail:
        /*
         * About 90% of all real-life EEH failures in the field
         * are due to poorly seated PCI cards. Only 10% or so are
         * due to actual, failed cards.
         */
-       pr_err("EEH: PHB#%x-PE#%x has failed %d times in the\n"
-              "last hour and has been permanently disabled.\n"
-              "Please try reseating or replacing it.\n",
-               pe->phb->global_number, pe->addr,
-               pe->freeze_count);
-       goto perm_error;
-
-hard_fail:
        pr_err("EEH: Unable to recover from failure from PHB#%x-PE#%x.\n"
               "Please try reseating or replacing it\n",
                pe->phb->global_number, pe->addr);
 
-perm_error:
        eeh_slot_error_detail(pe, EEH_LOG_PERM);
 
        /* Notify all devices that they're about to go down. */
@@ -923,6 +928,13 @@ perm_error:
        return false;
 }
 
+/**
+ * eeh_handle_special_event - Handle EEH events without a specific failing PE
+ *
+ * Called when an EEH event is detected but can't be narrowed down to a
+ * specific PE.  Iterates through possible failures and handles them as
+ * necessary.
+ */
 static void eeh_handle_special_event(void)
 {
        struct eeh_pe *pe, *phb_pe;