From: Yury Murashka <[email protected]> pcie_do_recovery() only clears the error status bits of an error-reporting device if recovery succeeds, but not if it fails. (E.g. because reset failed, drivers are missing pci_error_handlers or those handlers failed.)
One undesirable consequence is that the AER driver may subsequently identify a wrong device when searching for error-reporting devices in is_error_source(), due to stale bits on an unaffected device. Avoid by clearing error status bits on recovery failure. If recovery succeeds, Fatal Errors are generally cleared by a call to pci_restore_state() from drivers' ->slot_reset() callbacks. If recovery fails, those callbacks may not have been invoked or they may not be implemented. Hence clear Fatal Errors as well on recovery failure. Link: https://lore.kernel.org/r/CAPzpGcRCTCZtaX1EVaJNZ103THZKsoszZduY7=gwfydcrmo...@mail.gmail.com/ Signed-off-by: Yury Murashka <[email protected]> [lukas: drop cmdline param, rewrite commit msg, clear fatal errors] Signed-off-by: Lukas Wunner <[email protected]> --- Changes v1 -> v2: * Clear Fatal Errors as well on recovery failure (Sathya, sashiko). drivers/pci/pcie/err.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c index 24a8a8263c2e..a450146fb285 100644 --- a/drivers/pci/pcie/err.c +++ b/drivers/pci/pcie/err.c @@ -289,6 +289,13 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev, return status; failed: + if (host->native_aer) { + pcie_capability_write_word(dev, PCI_EXP_DEVSTA, + PCI_EXP_DEVSTA_UNC_MASK); + pci_aer_clear_nonfatal_status(dev); + pci_aer_clear_fatal_status(dev); + } + pci_walk_bridge(bridge, pci_pm_runtime_put, NULL); pci_walk_bridge(bridge, report_perm_failure_detected, NULL); -- 2.53.0
