From 7ab92e89bf8b0a93f0d53b6d83270e4cd0f7c563 Mon Sep 17 00:00:00 2001
From: Bjorn Helgaas <bhelgaas@google.com>
Date: Thu, 19 Jul 2018 17:55:58 -0500
Subject: [PATCH] PCI/AER: Clear only ERR_FATAL status bits during fatal recovery
Git-commit: 7ab92e89bf8b0a93f0d53b6d83270e4cd0f7c563
Patch-mainline: v4.19-rc1
References: bsc#1161561
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>
Acked-by: Takashi Iwai <tiwai@suse.de>
---
drivers/pci/pcie/aer/aerdrv_core.c | 17 +++++++++++++++++
drivers/pci/pcie/err.c | 2 +-
include/linux/aer.h | 2 ++
3 files changed, 20 insertions(+), 1 deletion(-)
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -70,6 +70,23 @@ int pci_cleanup_aer_uncorrect_error_stat
}
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;
--- a/drivers/pci/pcie/err.c
+++ b/drivers/pci/pcie/err.c
@@ -262,7 +262,7 @@ void pcie_do_fatal_recovery(struct pci_d
* 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) {
--- a/include/linux/aer.h
+++ b/include/linux/aer.h
@@ -45,6 +45,7 @@ int pci_enable_pcie_error_reporting(stru
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);
+void pci_aer_clear_fatal_status(struct pci_dev *dev);
#else
static inline int pci_enable_pcie_error_reporting(struct pci_dev *dev)
{
@@ -62,6 +63,7 @@ static inline int pci_cleanup_aer_error_
{
return -EINVAL;
}
+static inline void pci_aer_clear_fatal_status(struct pci_dev *dev) { }
#endif
void cper_print_aer(struct pci_dev *dev, int aer_severity,