]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
PCI/AER: Clear error status registers during enumeration and restore
authorTaku Izumi <izumi.taku@jp.fujitsu.com>
Thu, 17 Sep 2015 15:09:37 +0000 (10:09 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 17 Sep 2015 15:09:37 +0000 (10:09 -0500)
AER errors might be recorded when powering-on devices.  These errors can be
ignored, so firmware usually clears them before the OS enumerates devices.
However, firmware is not involved when devices are added via hotplug, so
the OS may discover power-up errors that should be ignored.  The same may
happen when powering up devices when resuming after suspend.

Clear the AER error status registers during enumeration and resume.

[bhelgaas: changelog, remove repetitive comments]
Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/pci.c
drivers/pci/pcie/aer/aerdrv_core.c
drivers/pci/probe.c
include/linux/aer.h

index 6a9a1116f1ebed7312f903570df56615352d57c1..62ecf45a423022b045979b8e9e7a67389703c37d 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/pci_hotplug.h>
 #include <asm-generic/pci-bridge.h>
 #include <asm/setup.h>
+#include <linux/aer.h>
 #include "pci.h"
 
 const char *pci_power_names[] = {
@@ -1099,6 +1100,8 @@ void pci_restore_state(struct pci_dev *dev)
        pci_restore_ats_state(dev);
        pci_restore_vc_state(dev);
 
+       pci_cleanup_aer_error_status_regs(dev);
+
        pci_restore_config_space(dev);
 
        pci_restore_pcix_state(dev);
index 9803e3d039febf7f5ea0e3613da5bb07243d501e..fba785e9df75570b35a9b90e671bc8d5dbad6e91 100644 (file)
@@ -74,6 +74,34 @@ int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev)
 }
 EXPORT_SYMBOL_GPL(pci_cleanup_aer_uncorrect_error_status);
 
+int pci_cleanup_aer_error_status_regs(struct pci_dev *dev)
+{
+       int pos;
+       u32 status;
+       int port_type;
+
+       if (!pci_is_pcie(dev))
+               return -ENODEV;
+
+       pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
+       if (!pos)
+               return -EIO;
+
+       port_type = pci_pcie_type(dev);
+       if (port_type == PCI_EXP_TYPE_ROOT_PORT) {
+               pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, &status);
+               pci_write_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, status);
+       }
+
+       pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS, &status);
+       pci_write_config_dword(dev, pos + PCI_ERR_COR_STATUS, status);
+
+       pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
+       pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, status);
+
+       return 0;
+}
+
 /**
  * add_error_device - list device to be handled
  * @e_info: pointer to error info
index 0b2be174d9818e9ffe86110068c9eb2e3ea19f11..8cd9710498e481db9aa0940ef1a1d0c41b23621f 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/cpumask.h>
 #include <linux/pci-aspm.h>
+#include <linux/aer.h>
 #include <asm-generic/pci-bridge.h>
 #include "pci.h"
 
@@ -1621,6 +1622,8 @@ static void pci_init_capabilities(struct pci_dev *dev)
 
        /* Enable ACS P2P upstream forwarding */
        pci_enable_acs(dev);
+
+       pci_cleanup_aer_error_status_regs(dev);
 }
 
 static void pci_set_msi_domain(struct pci_dev *dev)
index 4fef65e5702396bab72e501d158b2c514d279127..744b997d6a94ae01852c190d195f89fa3c4124ae 100644 (file)
@@ -42,6 +42,7 @@ struct aer_capability_regs {
 int pci_enable_pcie_error_reporting(struct pci_dev *dev);
 int pci_disable_pcie_error_reporting(struct pci_dev *dev);
 int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev);
+int pci_cleanup_aer_error_status_regs(struct pci_dev *dev);
 #else
 static inline int pci_enable_pcie_error_reporting(struct pci_dev *dev)
 {
@@ -55,6 +56,10 @@ static inline int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev)
 {
        return -EINVAL;
 }
+static inline int pci_cleanup_aer_error_status_regs(struct pci_dev *dev)
+{
+       return -EINVAL;
+}
 #endif
 
 void cper_print_aer(struct pci_dev *dev, int cper_severity,