PCI/AER: Clear only ERR_FATAL status bits during fatal recovery
authorBjorn Helgaas <bhelgaas@google.com>
Thu, 19 Jul 2018 22:55:58 +0000 (17:55 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 20 Jul 2018 20:27:07 +0000 (15:27 -0500)
During recovery from fatal errors, we previously called
pci_cleanup_aer_uncorrect_error_status(), which cleared *all* uncorrectable
error status bits (both ERR_FATAL and ERR_NONFATAL).

Instead, call a new pci_aer_clear_fatal_status() that clears only the
ERR_FATAL bits (as indicated by the PCI_ERR_UNCOR_SEVER register).

Based-on-patch-by: Oza Pawandeep <poza@codeaurora.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/pci.h
drivers/pci/pcie/aer.c
drivers/pci/pcie/err.c

index b1ce0dcad1dc8660e0bf464cf19bb726525d9768..107c64892b6624686f24161fc1528854d5c00fbf 100644 (file)
@@ -485,10 +485,12 @@ void pci_no_aer(void);
 void pci_aer_init(struct pci_dev *dev);
 void pci_aer_exit(struct pci_dev *dev);
 extern const struct attribute_group aer_stats_attr_group;
+void pci_aer_clear_fatal_status(struct pci_dev *dev);
 #else
 static inline void pci_no_aer(void) { }
 static inline int pci_aer_init(struct pci_dev *d) { return -ENODEV; }
 static inline void pci_aer_exit(struct pci_dev *d) { }
+static inline void pci_aer_clear_fatal_status(struct pci_dev *dev) { }
 #endif
 
 #endif /* DRIVERS_PCI_H */
index 766687094706114d5d954ad8330003396b3e5f3f..b776a768a434af64667c5685e49235fe39e90d87 100644 (file)
@@ -399,6 +399,23 @@ int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev)
 }
 EXPORT_SYMBOL_GPL(pci_cleanup_aer_uncorrect_error_status);
 
+void pci_aer_clear_fatal_status(struct pci_dev *dev)
+{
+       int pos;
+       u32 status, sev;
+
+       pos = dev->aer_cap;
+       if (!pos)
+               return;
+
+       /* Clear status bits for ERR_FATAL errors only */
+       pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
+       pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, &sev);
+       status &= sev;
+       if (status)
+               pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, status);
+}
+
 int pci_cleanup_aer_error_status_regs(struct pci_dev *dev)
 {
        int pos;
index f7ce0cb0b0b70a48902010c3cea0fb1707e5ead9..0539518f98618387287b168262301e5597898cbb 100644 (file)
@@ -316,7 +316,7 @@ void pcie_do_fatal_recovery(struct pci_dev *dev, u32 service)
                 * do error recovery on all subordinates of the bridge instead
                 * of the bridge and clear the error status of the bridge.
                 */
-               pci_cleanup_aer_uncorrect_error_status(dev);
+               pci_aer_clear_fatal_status(dev);
        }
 
        if (result == PCI_ERS_RESULT_RECOVERED) {