powerpc/eeh: Allow to set maximal frozen times
authorGavin Shan <gwshan@linux.vnet.ibm.com>
Thu, 11 Dec 2014 03:28:56 +0000 (14:28 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 23 Jan 2015 03:02:54 +0000 (14:02 +1100)
When PE's frozen count hits maximal allowed frozen times, which is
5 currently, it will be forced to be offline permanently. Once the
PE is removed permanently, rebooting machine is required to bring
the PE back. It's not convienent when testing EEH functionality.

The patch exports the maximal allowed frozen times through debugfs
entry (/sys/kernel/debug/powerpc/eeh_max_freezes).

Requested-by: Ryan Grimm <grimm@linux.vnet.ibm.com>
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/eeh.h
arch/powerpc/kernel/eeh.c
arch/powerpc/kernel/eeh_driver.c

index 3e4dd34f2bd2fcd52569a84f8e07cb2a9cf9658f..55abfd09e47fc7b4387e3a4c88b5bdc14c050a47 100644 (file)
@@ -218,6 +218,7 @@ struct eeh_ops {
 };
 
 extern int eeh_subsystem_flags;
+extern int eeh_max_freezes;
 extern struct eeh_ops *eeh_ops;
 extern raw_spinlock_t confirm_error_lock;
 
@@ -255,12 +256,6 @@ static inline void eeh_serialize_unlock(unsigned long flags)
        raw_spin_unlock_irqrestore(&confirm_error_lock, flags);
 }
 
-/*
- * Max number of EEH freezes allowed before we consider the device
- * to be permanently disabled.
- */
-#define EEH_MAX_ALLOWED_FREEZES 5
-
 typedef void *(*eeh_traverse_func)(void *data, void *flag);
 void eeh_set_pe_aux_size(int size);
 int eeh_phb_pe_create(struct pci_controller *phb);
index e1b6d8e172893c3fba28371eaf0b641b59f3f955..3b2252e7731b61ee47ac334ee4dce9c129727831 100644 (file)
 int eeh_subsystem_flags;
 EXPORT_SYMBOL(eeh_subsystem_flags);
 
+/*
+ * EEH allowed maximal frozen times. If one particular PE's
+ * frozen count in last hour exceeds this limit, the PE will
+ * be forced to be offline permanently.
+ */
+int eeh_max_freezes = 5;
+
 /* Platform dependent EEH operations */
 struct eeh_ops *eeh_ops = NULL;
 
@@ -1652,8 +1659,22 @@ static int eeh_enable_dbgfs_get(void *data, u64 *val)
        return 0;
 }
 
+static int eeh_freeze_dbgfs_set(void *data, u64 val)
+{
+       eeh_max_freezes = val;
+       return 0;
+}
+
+static int eeh_freeze_dbgfs_get(void *data, u64 *val)
+{
+       *val = eeh_max_freezes;
+       return 0;
+}
+
 DEFINE_SIMPLE_ATTRIBUTE(eeh_enable_dbgfs_ops, eeh_enable_dbgfs_get,
                        eeh_enable_dbgfs_set, "0x%llx\n");
+DEFINE_SIMPLE_ATTRIBUTE(eeh_freeze_dbgfs_ops, eeh_freeze_dbgfs_get,
+                       eeh_freeze_dbgfs_set, "0x%llx\n");
 #endif
 
 static int __init eeh_init_proc(void)
@@ -1664,6 +1685,9 @@ static int __init eeh_init_proc(void)
                debugfs_create_file("eeh_enable", 0600,
                                     powerpc_debugfs_root, NULL,
                                     &eeh_enable_dbgfs_ops);
+               debugfs_create_file("eeh_max_freezes", 0600,
+                                   powerpc_debugfs_root, NULL,
+                                   &eeh_freeze_dbgfs_ops);
 #endif
        }
 
index ac00672af7d1999a1d1537bfa2f3729bb69216ef..d099540c0f560de2b8f81ef85e5a51e020b3529b 100644 (file)
@@ -667,7 +667,7 @@ static void eeh_handle_normal_event(struct eeh_pe *pe)
 
        eeh_pe_update_time_stamp(pe);
        pe->freeze_count++;
-       if (pe->freeze_count > EEH_MAX_ALLOWED_FREEZES)
+       if (pe->freeze_count > eeh_max_freezes)
                goto excess_failures;
        pr_warn("EEH: This PCI device has failed %d times in the last hour\n",
                pe->freeze_count);