Thread (13 messages) flat view 13 messages, 3 authors, 8d ago

Re: [PATCH 0/6] PCI/AER: Support Advisory Non-Fatal Errors

From: Lukas Wunner <lukas@wunner.de>
Date: 2026-07-31 18:47:18
Also in: linux-pci
Subsystem: pci enhanced error handling (eeh) for powerpc, pci subsystem, the rest · Maintainers: Mahesh J Salgaonkar, Bjorn Helgaas, Linus Torvalds

On Mon, Jul 27, 2026 at 04:12:02PM +0200, Lukas Wunner wrote:
There is one other sashiko finding I need to address:

It complained that in the native case, Advisory Non-Fatal Errors are
reported with the same loglevel and ratelimiting as the accompanying
Correctable Error.  But that's intentional.  However in the Firmware
First case, I got that wrong in that the loglevel and ratelimiting of
non-Advisory Non-Fatal Errors is used.  I'll come back with another
fixup for that!
Below please find a fixup for this finding of sashiko.  With that,
I believe I have addressed all sashiko findings which are not
pre-existing issues.

This fixup is intended to be folded into the top-most commit
on pci/aer.  If you prefer a proper, separate patch to apply
on top of the branch, please let me know.  Same if you find
anything objectionable in this fixup.

Thanks!

-- >8 --
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index 2a380bb9bfcb..dd2aa5dd4dda 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -1028,13 +1028,15 @@ int cper_severity_to_aer(int cper_severity)
 EXPORT_SYMBOL_GPL(cper_severity_to_aer);
 #endif
 
-void pci_print_aer(struct pci_dev *dev, int aer_severity,
-		   struct aer_capability_regs *aer)
+static void __pci_print_aer(struct pci_dev *dev, int aer_severity,
+			    struct aer_capability_regs *aer,
+			    bool ratelimit_print, const char* level)
 {
 	const char *bus_type, *sev;
 	int tlp_header_valid = 0;
 	u32 status, mask;
 	struct aer_err_info info = {
+		.level = level,
 		.severity = aer_severity,
 		.first_error = PCI_ERR_CAP_FEP(aer->cap_control),
 	};
@@ -1043,12 +1045,10 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity,
 		status = aer->cor_status;
 		mask = aer->cor_mask;
 		sev = "cor";
-		info.level = KERN_WARNING;
 	} else {
 		status = aer->uncor_status;
 		mask = aer->uncor_mask;
 		sev = "uncor";
-		info.level = KERN_ERR;
 		tlp_header_valid = tlp_header_logged(status & ~mask,
 						     aer->cap_control);
 	}
@@ -1067,7 +1067,7 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity,
 	 * For Advisory Non-Fatal Errors, record statistics and tracing
 	 * even if ratelimited
 	 */
-	if (!aer_ratelimit(dev, info.severity))
+	if (!ratelimit_print)
 		goto anfe;
 
 	aer_printk(info.level, dev,
@@ -1094,10 +1094,25 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity,
 		if (anfe_status) {
 			aer->uncor_status = anfe_status;
 			aer->uncor_mask = 0;
-			pci_print_aer(dev, AER_NONFATAL, aer);
+			__pci_print_aer(dev, AER_NONFATAL, aer,
+					ratelimit_print, level);
 		}
 	}
 }
+
+void pci_print_aer(struct pci_dev *dev, int aer_severity,
+		   struct aer_capability_regs *aer)
+{
+	/*
+	 * Precalculate ratelimit counter and log level so that Advisory
+	 * Non-Fatal Errors are treated like the accompanying Correctable Error
+	 */
+	bool ratelimit_print = aer_ratelimit(dev, aer_severity);
+	const char *level = aer_severity == AER_CORRECTABLE ? KERN_WARNING
+							    : KERN_ERR;
+
+	__pci_print_aer(dev, aer_severity, aer, ratelimit_print, level);
+}
 EXPORT_SYMBOL_GPL(pci_print_aer);
 
 /**

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help