]> git.karo-electronics.de Git - linux-beck.git/commitdiff
powerpc/eeh: Cleanup EEH subsystem variables
authorGavin Shan <gwshan@linux.vnet.ibm.com>
Thu, 24 Apr 2014 08:00:17 +0000 (18:00 +1000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Mon, 28 Apr 2014 07:34:23 +0000 (17:34 +1000)
There're 2 EEH subsystem variables: eeh_subsystem_enabled and
eeh_probe_mode. We needn't maintain 2 variables and we can just
have one variable and introduce different flags. The patch also
introduces additional flag EEH_FORCE_DISABLE, which will be used
to disable EEH subsystem via boot parameter ("eeh=off") in future.
Besides, the patch also introduces flag EEH_ENABLED, which is
changed to disable or enable EEH functionality on the fly through
debugfs entry in future.

With the patch applied, the creteria to check the enabled EEH
functionality is changed to:

!EEH_FORCE_DISABLED && EEH_ENABLED : Enabled
                       Other cases : Disabled

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/include/asm/eeh.h
arch/powerpc/kernel/eeh.c

index f0183e36f61097b087d64cefc6426aa58d4c7dce..f4a93218fbcb61b2f5b55d360f1023029d64bdf9 100644 (file)
@@ -32,6 +32,12 @@ struct device_node;
 
 #ifdef CONFIG_EEH
 
+/* EEH subsystem flags */
+#define EEH_ENABLED            0x1     /* EEH enabled          */
+#define EEH_FORCE_DISABLED     0x2     /* EEH disabled         */
+#define EEH_PROBE_MODE_DEV     0x4     /* From PCI device      */
+#define EEH_PROBE_MODE_DEVTREE 0x8     /* From device tree     */
+
 /*
  * The struct is used to trace PE related EEH functionality.
  * In theory, there will have one instance of the struct to
@@ -173,37 +179,40 @@ struct eeh_ops {
        int (*restore_config)(struct device_node *dn);
 };
 
+extern int eeh_subsystem_flags;
 extern struct eeh_ops *eeh_ops;
-extern bool eeh_subsystem_enabled;
 extern raw_spinlock_t confirm_error_lock;
-extern int eeh_probe_mode;
 
 static inline bool eeh_enabled(void)
 {
-       return eeh_subsystem_enabled;
+       if ((eeh_subsystem_flags & EEH_FORCE_DISABLED) ||
+           !(eeh_subsystem_flags & EEH_ENABLED))
+               return false;
+
+       return true;
 }
 
 static inline void eeh_set_enable(bool mode)
 {
-       eeh_subsystem_enabled = mode;
+       if (mode)
+               eeh_subsystem_flags |= EEH_ENABLED;
+       else
+               eeh_subsystem_flags &= ~EEH_ENABLED;
 }
 
-#define EEH_PROBE_MODE_DEV     (1<<0)  /* From PCI device      */
-#define EEH_PROBE_MODE_DEVTREE (1<<1)  /* From device tree     */
-
 static inline void eeh_probe_mode_set(int flag)
 {
-       eeh_probe_mode = flag;
+       eeh_subsystem_flags |= flag;
 }
 
 static inline int eeh_probe_mode_devtree(void)
 {
-       return (eeh_probe_mode == EEH_PROBE_MODE_DEVTREE);
+       return (eeh_subsystem_flags & EEH_PROBE_MODE_DEVTREE);
 }
 
 static inline int eeh_probe_mode_dev(void)
 {
-       return (eeh_probe_mode == EEH_PROBE_MODE_DEV);
+       return (eeh_subsystem_flags & EEH_PROBE_MODE_DEV);
 }
 
 static inline void eeh_serialize_lock(unsigned long *flags)
index 69df8985fc8b9dd1ee889a2f010da330e10aa2e7..06d2b7c6b661e50fddc8b1d39cd8a58cc3da4611 100644 (file)
 /* Time to wait for a PCI slot to report status, in milliseconds */
 #define PCI_BUS_RESET_WAIT_MSEC (5*60*1000)
 
-/* Platform dependent EEH operations */
-struct eeh_ops *eeh_ops = NULL;
-
-bool eeh_subsystem_enabled = false;
-EXPORT_SYMBOL(eeh_subsystem_enabled);
-
 /*
- * EEH probe mode support. The intention is to support multiple
- * platforms for EEH. Some platforms like pSeries do PCI emunation
- * based on device tree. However, other platforms like powernv probe
- * PCI devices from hardware. The flag is used to distinguish that.
- * In addition, struct eeh_ops::probe would be invoked for particular
- * OF node or PCI device so that the corresponding PE would be created
- * there.
+ * EEH probe mode support, which is part of the flags,
+ * is to support multiple platforms for EEH. Some platforms
+ * like pSeries do PCI emunation based on device tree.
+ * However, other platforms like powernv probe PCI devices
+ * from hardware. The flag is used to distinguish that.
+ * In addition, struct eeh_ops::probe would be invoked for
+ * particular OF node or PCI device so that the corresponding
+ * PE would be created there.
  */
-int eeh_probe_mode;
+int eeh_subsystem_flags;
+EXPORT_SYMBOL(eeh_subsystem_flags);
+
+/* Platform dependent EEH operations */
+struct eeh_ops *eeh_ops = NULL;
 
 /* Lock to avoid races due to multiple reports of an error */
 DEFINE_RAW_SPINLOCK(confirm_error_lock);
@@ -842,8 +841,8 @@ int eeh_init(void)
                        &hose_list, list_node)
                        pci_walk_bus(hose->bus, eeh_ops->dev_probe, NULL);
        } else {
-               pr_warning("%s: Invalid probe mode %d\n",
-                          __func__, eeh_probe_mode);
+               pr_warn("%s: Invalid probe mode %x",
+                       __func__, eeh_subsystem_flags);
                return -EINVAL;
        }