Remove ghes_handle_aer() and re-use the existing extlog_print_pcie()
to have a common PCIe logging handler. Update the function
documentation.

Except for the warning ("PCIe error section too small"),
no functional change intended.

Signed-off-by: Pierre Gondois <[email protected]>
---
 drivers/acpi/apei/apei-internal.h |  1 +
 drivers/acpi/apei/extlog.c        | 14 +++++++-
 drivers/acpi/apei/ghes.c          | 54 ++-----------------------------
 3 files changed, 16 insertions(+), 53 deletions(-)

diff --git a/drivers/acpi/apei/apei-internal.h 
b/drivers/acpi/apei/apei-internal.h
index 5063c743b4cf0..22a33a21017a3 100644
--- a/drivers/acpi/apei/apei-internal.h
+++ b/drivers/acpi/apei/apei-internal.h
@@ -14,6 +14,7 @@ int ghes_severity(int severity);
 int cxl_cper_post_event(enum cxl_event_type event_type,
                        struct cxl_cper_event_rec *rec, u32 len);
 u32 acpi_extlog_mem_err_min_len(u64 validation_bits);
+void extlog_print_pcie(struct acpi_hest_generic_data *gdata);
 void acpi_extlog_report(const struct acpi_hest_generic_status *estatus);
 
 struct apei_exec_context;
diff --git a/drivers/acpi/apei/extlog.c b/drivers/acpi/apei/extlog.c
index bd407436928b4..42ba8ba13804f 100644
--- a/drivers/acpi/apei/extlog.c
+++ b/drivers/acpi/apei/extlog.c
@@ -19,7 +19,19 @@
 
 #include "apei-internal.h"
 
-static void extlog_print_pcie(struct acpi_hest_generic_data *gdata)
+/*
+ * PCIe AER errors need to be sent to the AER driver for reporting and
+ * recovery. The CPER severities map to the following AER severities and
+ * require the following handling:
+ *
+ * CPER_SEV_CORRECTED or CPER_SEV_INFORMATIONAL -> AER_CORRECTABLE
+ *     These need to be reported by the AER driver but no recovery is
+ *     necessary.
+ * CPER_SEV_RECOVERABLE -> AER_NONFATAL
+ * CPER_SEV_FATAL or CPER_SEC_RESET -> AER_FATAL
+ *     These both need to be reported and recovered from by the AER driver.
+ */
+void extlog_print_pcie(struct acpi_hest_generic_data *gdata)
 {
 #ifdef CONFIG_ACPI_APEI_PCIEAER
        struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata);
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 623ac2a7f7a75..7d2864fa14503 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -18,6 +18,7 @@
  */
 
 #include <linux/arm_sdei.h>
+#include <linux/atomic.h>
 #include <linux/kernel.h>
 #include <linux/moduleparam.h>
 #include <linux/init.h>
@@ -37,9 +38,7 @@
 #include <linux/llist.h>
 #include <linux/genalloc.h>
 #include <linux/kfifo.h>
-#include <linux/pci.h>
 #include <linux/pfn.h>
-#include <linux/aer.h>
 #include <linux/nmi.h>
 #include <linux/sched/clock.h>
 #include <linux/uuid.h>
@@ -627,55 +626,6 @@ static bool ghes_handle_arm_hw_error(struct 
acpi_hest_generic_data *gdata,
        return queued;
 }
 
-/*
- * PCIe AER errors need to be sent to the AER driver for reporting and
- * recovery. The GHES severities map to the following AER severities and
- * require the following handling:
- *
- * GHES_SEV_CORRECTABLE -> AER_CORRECTABLE
- *     These need to be reported by the AER driver but no recovery is
- *     necessary.
- * GHES_SEV_RECOVERABLE -> AER_NONFATAL
- * GHES_SEV_RECOVERABLE && CPER_SEC_RESET -> AER_FATAL
- *     These both need to be reported and recovered from by the AER driver.
- * GHES_SEV_PANIC does not make it to this handling since the kernel must
- *     panic.
- */
-static void ghes_handle_aer(struct acpi_hest_generic_data *gdata)
-{
-#ifdef CONFIG_ACPI_APEI_PCIEAER
-       struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata);
-
-       if (gdata->error_data_length < sizeof(*pcie_err))
-               return;
-
-       if (pcie_err->validation_bits & CPER_PCIE_VALID_DEVICE_ID &&
-           pcie_err->validation_bits & CPER_PCIE_VALID_AER_INFO) {
-               struct aer_capability_regs aer_info;
-               unsigned int devfn;
-               int aer_severity;
-
-               devfn = PCI_DEVFN(pcie_err->device_id.device,
-                                 pcie_err->device_id.function);
-               aer_severity = cper_severity_to_aer(gdata->error_severity);
-
-               /*
-                * If firmware reset the component to contain
-                * the error, we must reinitialize it before
-                * use, so treat it as a fatal AER error.
-                */
-               if (gdata->flags & CPER_SEC_RESET)
-                       aer_severity = AER_FATAL;
-
-               aer_cap_regs_unpack(&aer_info, pcie_err->aer_info, 
sizeof(pcie_err->aer_info));
-
-               aer_recover_queue(pcie_err->device_id.segment,
-                                 pcie_err->device_id.bus,
-                                 devfn, aer_severity, &aer_info);
-       }
-#endif
-}
-
 static BLOCKING_NOTIFIER_HEAD(vendor_record_notify_list);
 
 int ghes_register_vendor_record_notifier(struct notifier_block *nb)
@@ -995,7 +945,7 @@ static void ghes_do_proc(struct ghes *ghes,
                        arch_apei_report_mem_error2(sev, mem_err);
                        queued |= ghes_handle_memory_failure2(gdata, sev, sync);
                } else if (guid_equal(sec_type, &CPER_SEC_PCIE)) {
-                       ghes_handle_aer(gdata);
+                       extlog_print_pcie(gdata);
                } else if (guid_equal(sec_type, &CPER_SEC_PROC_ARM)) {
                        queued |= ghes_handle_arm_hw_error(gdata, sev, sync);
                } else if (guid_equal(sec_type, &CPER_SEC_CXL_PROT_ERR)) {
-- 
2.43.0


Reply via email to