Shift the vendor record workqueue helpers into ghes_cper.c so both GHES
and future DT-based providers can use the same implementation. The change
is mechanical and keeps the notifier behavior identical.

Signed-off-by: Ahmed Tiba <[email protected]>
---
 drivers/acpi/apei/ghes.c      | 68 ------------------------------------------
 drivers/acpi/apei/ghes_cper.c | 69 +++++++++++++++++++++++++++++++++++++++++++
 include/acpi/ghes_cper.h      |  2 ++
 3 files changed, 71 insertions(+), 68 deletions(-)

diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index e9cb576eefcf..07e4001ea8d7 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -383,74 +383,6 @@ static void ghes_handle_aer(struct acpi_hest_generic_data 
*gdata)
 #endif
 }
 
-static BLOCKING_NOTIFIER_HEAD(vendor_record_notify_list);
-
-int ghes_register_vendor_record_notifier(struct notifier_block *nb)
-{
-       return blocking_notifier_chain_register(&vendor_record_notify_list, nb);
-}
-EXPORT_SYMBOL_GPL(ghes_register_vendor_record_notifier);
-
-void ghes_unregister_vendor_record_notifier(struct notifier_block *nb)
-{
-       blocking_notifier_chain_unregister(&vendor_record_notify_list, nb);
-}
-EXPORT_SYMBOL_GPL(ghes_unregister_vendor_record_notifier);
-
-static void ghes_vendor_record_notifier_destroy(void *nb)
-{
-       ghes_unregister_vendor_record_notifier(nb);
-}
-
-int devm_ghes_register_vendor_record_notifier(struct device *dev,
-                                             struct notifier_block *nb)
-{
-       int ret;
-
-       ret = ghes_register_vendor_record_notifier(nb);
-       if (ret)
-               return ret;
-
-       return devm_add_action_or_reset(dev, 
ghes_vendor_record_notifier_destroy, nb);
-}
-EXPORT_SYMBOL_GPL(devm_ghes_register_vendor_record_notifier);
-
-static void ghes_vendor_record_work_func(struct work_struct *work)
-{
-       struct ghes_vendor_record_entry *entry;
-       struct acpi_hest_generic_data *gdata;
-       u32 len;
-
-       entry = container_of(work, struct ghes_vendor_record_entry, work);
-       gdata = GHES_GDATA_FROM_VENDOR_ENTRY(entry);
-
-       blocking_notifier_call_chain(&vendor_record_notify_list,
-                                    entry->error_severity, gdata);
-
-       len = GHES_VENDOR_ENTRY_LEN(acpi_hest_get_record_size(gdata));
-       gen_pool_free(ghes_estatus_pool, (unsigned long)entry, len);
-}
-
-static void ghes_defer_non_standard_event(struct acpi_hest_generic_data *gdata,
-                                         int sev)
-{
-       struct acpi_hest_generic_data *copied_gdata;
-       struct ghes_vendor_record_entry *entry;
-       u32 len;
-
-       len = GHES_VENDOR_ENTRY_LEN(acpi_hest_get_record_size(gdata));
-       entry = (void *)gen_pool_alloc(ghes_estatus_pool, len);
-       if (!entry)
-               return;
-
-       copied_gdata = GHES_GDATA_FROM_VENDOR_ENTRY(entry);
-       memcpy(copied_gdata, gdata, acpi_hest_get_record_size(gdata));
-       entry->error_severity = sev;
-
-       INIT_WORK(&entry->work, ghes_vendor_record_work_func);
-       schedule_work(&entry->work);
-}
-
 /* Room for 8 entries */
 #define CXL_CPER_PROT_ERR_FIFO_DEPTH 8
 static DEFINE_KFIFO(cxl_cper_prot_err_fifo, struct cxl_cper_prot_err_work_data,
diff --git a/drivers/acpi/apei/ghes_cper.c b/drivers/acpi/apei/ghes_cper.c
index 44b644584703..7e4a66b788b8 100644
--- a/drivers/acpi/apei/ghes_cper.c
+++ b/drivers/acpi/apei/ghes_cper.c
@@ -18,6 +18,7 @@
 #include <linux/kernel.h>
 #include <linux/math64.h>
 #include <linux/mm.h>
+#include <linux/notifier.h>
 #include <linux/ratelimit.h>
 #include <linux/rcupdate.h>
 #include <linux/sched/clock.h>
@@ -281,6 +282,74 @@ void ghes_clear_estatus(struct ghes *ghes,
                ghes_ack_error(ghes->generic_v2);
 }
 
+static BLOCKING_NOTIFIER_HEAD(vendor_record_notify_list);
+
+int ghes_register_vendor_record_notifier(struct notifier_block *nb)
+{
+       return blocking_notifier_chain_register(&vendor_record_notify_list, nb);
+}
+EXPORT_SYMBOL_GPL(ghes_register_vendor_record_notifier);
+
+void ghes_unregister_vendor_record_notifier(struct notifier_block *nb)
+{
+       blocking_notifier_chain_unregister(&vendor_record_notify_list, nb);
+}
+EXPORT_SYMBOL_GPL(ghes_unregister_vendor_record_notifier);
+
+static void ghes_vendor_record_notifier_destroy(void *nb)
+{
+       ghes_unregister_vendor_record_notifier(nb);
+}
+
+int devm_ghes_register_vendor_record_notifier(struct device *dev,
+                                             struct notifier_block *nb)
+{
+       int ret;
+
+       ret = ghes_register_vendor_record_notifier(nb);
+       if (ret)
+               return ret;
+
+       return devm_add_action_or_reset(dev, 
ghes_vendor_record_notifier_destroy, nb);
+}
+EXPORT_SYMBOL_GPL(devm_ghes_register_vendor_record_notifier);
+
+static void ghes_vendor_record_work_func(struct work_struct *work)
+{
+       struct ghes_vendor_record_entry *entry;
+       struct acpi_hest_generic_data *gdata;
+       u32 len;
+
+       entry = container_of(work, struct ghes_vendor_record_entry, work);
+       gdata = GHES_GDATA_FROM_VENDOR_ENTRY(entry);
+
+       blocking_notifier_call_chain(&vendor_record_notify_list,
+                                    entry->error_severity, gdata);
+
+       len = GHES_VENDOR_ENTRY_LEN(acpi_hest_get_record_size(gdata));
+       gen_pool_free(ghes_estatus_pool, (unsigned long)entry, len);
+}
+
+void ghes_defer_non_standard_event(struct acpi_hest_generic_data *gdata,
+                                  int sev)
+{
+       struct acpi_hest_generic_data *copied_gdata;
+       struct ghes_vendor_record_entry *entry;
+       u32 len;
+
+       len = GHES_VENDOR_ENTRY_LEN(acpi_hest_get_record_size(gdata));
+       entry = (void *)gen_pool_alloc(ghes_estatus_pool, len);
+       if (!entry)
+               return;
+
+       copied_gdata = GHES_GDATA_FROM_VENDOR_ENTRY(entry);
+       memcpy(copied_gdata, gdata, acpi_hest_get_record_size(gdata));
+       entry->error_severity = sev;
+
+       INIT_WORK(&entry->work, ghes_vendor_record_work_func);
+       schedule_work(&entry->work);
+}
+
 /*
  * GHES error status reporting throttle, to report more kinds of
  * errors, instead of just most frequently occurred errors.
diff --git a/include/acpi/ghes_cper.h b/include/acpi/ghes_cper.h
index 15305c8be9a7..d9f9253d8de9 100644
--- a/include/acpi/ghes_cper.h
+++ b/include/acpi/ghes_cper.h
@@ -104,5 +104,7 @@ int __ghes_read_estatus(struct acpi_hest_generic_status 
*estatus,
 int ghes_estatus_cached(struct acpi_hest_generic_status *estatus);
 void ghes_estatus_cache_add(struct acpi_hest_generic *generic,
                            struct acpi_hest_generic_status *estatus);
+void ghes_defer_non_standard_event(struct acpi_hest_generic_data *gdata,
+                                  int sev);
 
 #endif /* ACPI_APEI_GHES_CPER_H */

-- 
2.43.0


Reply via email to