From: Bjorn Helgaas Date: Thu, 22 May 2025 23:21:16 +0000 (-0500) Subject: PCI/AER: Update statistics before ratelimiting X-Git-Tag: v6.16-rc1~50^2~26^2~11 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=88a7765e62b9e4c79c7ca2c7b749ae04f54a5668;p=linux-block.git PCI/AER: Update statistics before ratelimiting There are two AER logging entry points: - aer_print_error() is used by DPC (dpc_process_error()) and native AER handling (aer_process_err_devices()). - pci_print_aer() is used by GHES (aer_recover_work_func()) and CXL (cxl_handle_rdport_errors()) Both use __aer_print_error() to print the AER error bits. Previously __aer_print_error() also incremented the AER statistics via pci_dev_aer_stats_incr(). Call pci_dev_aer_stats_incr() early in the entry points instead of in __aer_print_error() so we update the statistics even if the actual printing of error bits is rate limited by a future change. Signed-off-by: Bjorn Helgaas Tested-by: Krzysztof Wilczyński Reviewed-by: Ilpo Järvinen Reviewed-by: Kuppuswamy Sathyanarayanan Reviewed-by: Jonathan Cameron Link: https://patch.msgid.link/20250522232339.1525671-11-helgaas@kernel.org --- diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index dc5f4bebd613..53f460bb7e6c 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -693,7 +693,6 @@ static void __aer_print_error(struct pci_dev *dev, aer_printk(level, dev, " [%2d] %-22s%s\n", i, errmsg, info->first_error == i ? " (First)" : ""); } - pci_dev_aer_stats_incr(dev, info); } static void aer_print_source(struct pci_dev *dev, struct aer_err_info *info, @@ -715,6 +714,8 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) int id = pci_dev_id(dev); const char *level; + pci_dev_aer_stats_incr(dev, info); + if (!info->status) { pci_err(dev, "PCIe Bus Error: severity=%s, type=Inaccessible, (Unregistered Agent ID)\n", aer_error_severity_string[info->severity]); @@ -783,6 +784,8 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity, info.status = status; info.mask = mask; + pci_dev_aer_stats_incr(dev, &info); + layer = AER_GET_LAYER_ERROR(aer_severity, status); agent = AER_GET_AGENT(aer_severity, status);