Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ahmed Tiba <ahmed.tiba@arm.com>
To: linux-acpi@vger.kernel.org, devicetree@vger.kernel.org
Cc: tony.luck@intel.com, bp@alien8.de, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org, catalin.marinas@arm.com,
	will@kernel.org, linux-arm-kernel@lists.infradead.org,
	rafael@kernel.org, linux-doc@vger.kernel.org,
	Dmitry.Lamerov@arm.com, Michael.Zhao2@arm.com,
	ahmed.tiba@arm.com
Subject: [PATCH 06/12] efi/cper: adopt estatus iteration helpers
Date: Wed, 17 Dec 2025 11:28:39 +0000	[thread overview]
Message-ID: <20251217112845.1814119-7-ahmed.tiba@arm.com> (raw)
In-Reply-To: <20251217112845.1814119-1-ahmed.tiba@arm.com>

Switch the CPER printer and validator to the estatus_*() accessor
wrappers introduced by the new core. This is a mechanical change that
replaces the local acpi_hest_*() helpers with their aliases and keeps
the section iteration code shared ahead of the GHES conversion.

Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
 drivers/firmware/efi/cper.c | 29 +++++++++++++-------------
 include/acpi/ghes.h         | 41 ++-----------------------------------
 2 files changed, 17 insertions(+), 53 deletions(-)

diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
index 0232bd040f61..07119940486a 100644
--- a/drivers/firmware/efi/cper.c
+++ b/drivers/firmware/efi/cper.c
@@ -26,6 +26,7 @@
 #include <acpi/ghes.h>
 #include <ras/ras_event.h>
 #include <cxl/event.h>
+#include <linux/estatus.h>
 
 /*
  * CPER record ID need to be unique even after reboot, because record
@@ -525,7 +526,7 @@ static void cper_print_fw_err(const char *pfx,
 			      struct acpi_hest_generic_data *gdata,
 			      const struct cper_sec_fw_err_rec_ref *fw_err)
 {
-	void *buf = acpi_hest_get_payload(gdata);
+	void *buf = estatus_get_payload(gdata);
 	u32 offset, length = gdata->error_data_length;
 
 	printk("%s""Firmware Error Record Type: %s\n", pfx,
@@ -607,7 +608,7 @@ cper_estatus_print_section(const char *pfx, struct acpi_hest_generic_data *gdata
 	__u16 severity;
 	char newpfx[64];
 
-	if (acpi_hest_get_version(gdata) >= 3)
+	if (estatus_get_version(gdata) >= 3)
 		cper_print_tstamp(pfx, (struct acpi_hest_generic_data_v300 *)gdata);
 
 	severity = gdata->error_severity;
@@ -628,7 +629,7 @@ cper_estatus_print_section(const char *pfx, struct acpi_hest_generic_data *gdata
 	}
 
 	if (guid_equal(sec_type, &CPER_SEC_PROC_GENERIC)) {
-		struct cper_sec_proc_generic *proc_err = acpi_hest_get_payload(gdata);
+		struct cper_sec_proc_generic *proc_err = estatus_get_payload(gdata);
 
 		printk("%s""section_type: general processor error\n", newpfx);
 		if (gdata->error_data_length >= sizeof(*proc_err))
@@ -636,7 +637,7 @@ cper_estatus_print_section(const char *pfx, struct acpi_hest_generic_data *gdata
 		else
 			goto err_section_too_small;
 	} else if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) {
-		struct cper_sec_mem_err *mem_err = acpi_hest_get_payload(gdata);
+		struct cper_sec_mem_err *mem_err = estatus_get_payload(gdata);
 
 		printk("%s""section_type: memory error\n", newpfx);
 		if (gdata->error_data_length >=
@@ -646,7 +647,7 @@ cper_estatus_print_section(const char *pfx, struct acpi_hest_generic_data *gdata
 		else
 			goto err_section_too_small;
 	} else if (guid_equal(sec_type, &CPER_SEC_PCIE)) {
-		struct cper_sec_pcie *pcie = acpi_hest_get_payload(gdata);
+		struct cper_sec_pcie *pcie = estatus_get_payload(gdata);
 
 		printk("%s""section_type: PCIe error\n", newpfx);
 		if (gdata->error_data_length >= sizeof(*pcie))
@@ -655,7 +656,7 @@ cper_estatus_print_section(const char *pfx, struct acpi_hest_generic_data *gdata
 			goto err_section_too_small;
 #if defined(CONFIG_ARM64) || defined(CONFIG_ARM)
 	} else if (guid_equal(sec_type, &CPER_SEC_PROC_ARM)) {
-		struct cper_sec_proc_arm *arm_err = acpi_hest_get_payload(gdata);
+		struct cper_sec_proc_arm *arm_err = estatus_get_payload(gdata);
 
 		printk("%ssection_type: ARM processor error\n", newpfx);
 		if (gdata->error_data_length >= sizeof(*arm_err))
@@ -665,7 +666,7 @@ cper_estatus_print_section(const char *pfx, struct acpi_hest_generic_data *gdata
 #endif
 #if defined(CONFIG_UEFI_CPER_X86)
 	} else if (guid_equal(sec_type, &CPER_SEC_PROC_IA)) {
-		struct cper_sec_proc_ia *ia_err = acpi_hest_get_payload(gdata);
+		struct cper_sec_proc_ia *ia_err = estatus_get_payload(gdata);
 
 		printk("%ssection_type: IA32/X64 processor error\n", newpfx);
 		if (gdata->error_data_length >= sizeof(*ia_err))
@@ -674,7 +675,7 @@ cper_estatus_print_section(const char *pfx, struct acpi_hest_generic_data *gdata
 			goto err_section_too_small;
 #endif
 	} else if (guid_equal(sec_type, &CPER_SEC_FW_ERR_REC_REF)) {
-		struct cper_sec_fw_err_rec_ref *fw_err = acpi_hest_get_payload(gdata);
+		struct cper_sec_fw_err_rec_ref *fw_err = estatus_get_payload(gdata);
 
 		printk("%ssection_type: Firmware Error Record Reference\n",
 		       newpfx);
@@ -684,7 +685,7 @@ cper_estatus_print_section(const char *pfx, struct acpi_hest_generic_data *gdata
 		else
 			goto err_section_too_small;
 	} else if (guid_equal(sec_type, &CPER_SEC_CXL_PROT_ERR)) {
-		struct cxl_cper_sec_prot_err *prot_err = acpi_hest_get_payload(gdata);
+		struct cxl_cper_sec_prot_err *prot_err = estatus_get_payload(gdata);
 
 		printk("%ssection_type: CXL Protocol Error\n", newpfx);
 		if (gdata->error_data_length >= sizeof(*prot_err))
@@ -692,7 +693,7 @@ cper_estatus_print_section(const char *pfx, struct acpi_hest_generic_data *gdata
 		else
 			goto err_section_too_small;
 	} else {
-		const void *err = acpi_hest_get_payload(gdata);
+		const void *err = estatus_get_payload(gdata);
 
 		printk("%ssection type: unknown, %pUl\n", newpfx, sec_type);
 		printk("%ssection length: %#x\n", newpfx,
@@ -723,7 +724,7 @@ void cper_estatus_print(const char *pfx,
 	printk("%s""event severity: %s\n", pfx, cper_severity_str(severity));
 	snprintf(newpfx, sizeof(newpfx), "%s ", pfx);
 
-	apei_estatus_for_each_section(estatus, gdata) {
+	estatus_for_each_section(estatus, gdata) {
 		cper_estatus_print_section(newpfx, gdata, sec_no);
 		sec_no++;
 	}
@@ -755,11 +756,11 @@ int cper_estatus_check(const struct acpi_hest_generic_status *estatus)
 
 	data_len = estatus->data_length;
 
-	apei_estatus_for_each_section(estatus, gdata) {
-		if (acpi_hest_get_size(gdata) > data_len)
+	estatus_for_each_section(estatus, gdata) {
+		if (estatus_get_size(gdata) > data_len)
 			return -EINVAL;
 
-		record_size = acpi_hest_get_record_size(gdata);
+		record_size = estatus_get_record_size(gdata);
 		if (record_size > data_len)
 			return -EINVAL;
 
diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h
index ebd21b05fe6e..022c0325f1e0 100644
--- a/include/acpi/ghes.h
+++ b/include/acpi/ghes.h
@@ -4,6 +4,7 @@
 
 #include <acpi/apei.h>
 #include <acpi/hed.h>
+#include <linux/estatus.h>
 
 /*
  * One struct ghes is created for each generic hardware error source.
@@ -80,46 +81,8 @@ static inline void ghes_estatus_pool_region_free(unsigned long addr, u32 size) {
 
 int ghes_estatus_pool_init(unsigned int num_ghes);
 
-static inline int acpi_hest_get_version(struct acpi_hest_generic_data *gdata)
-{
-	return gdata->revision >> 8;
-}
-
-static inline void *acpi_hest_get_payload(struct acpi_hest_generic_data *gdata)
-{
-	if (acpi_hest_get_version(gdata) >= 3)
-		return (void *)(((struct acpi_hest_generic_data_v300 *)(gdata)) + 1);
-
-	return gdata + 1;
-}
-
-static inline int acpi_hest_get_error_length(struct acpi_hest_generic_data *gdata)
-{
-	return ((struct acpi_hest_generic_data *)(gdata))->error_data_length;
-}
-
-static inline int acpi_hest_get_size(struct acpi_hest_generic_data *gdata)
-{
-	if (acpi_hest_get_version(gdata) >= 3)
-		return sizeof(struct acpi_hest_generic_data_v300);
-
-	return sizeof(struct acpi_hest_generic_data);
-}
-
-static inline int acpi_hest_get_record_size(struct acpi_hest_generic_data *gdata)
-{
-	return (acpi_hest_get_size(gdata) + acpi_hest_get_error_length(gdata));
-}
-
-static inline void *acpi_hest_get_next(struct acpi_hest_generic_data *gdata)
-{
-	return (void *)(gdata) + acpi_hest_get_record_size(gdata);
-}
-
 #define apei_estatus_for_each_section(estatus, section)			\
-	for (section = (struct acpi_hest_generic_data *)(estatus + 1);	\
-	     (void *)section - (void *)(estatus + 1) < estatus->data_length; \
-	     section = acpi_hest_get_next(section))
+	estatus_for_each_section(estatus, section)
 
 #ifdef CONFIG_ACPI_APEI_SEA
 int ghes_notify_sea(void);
-- 
2.43.0



  parent reply	other threads:[~2025-12-17 11:30 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-17 11:28 [PATCH 00/12] ras: share firmware-first estatus handling Ahmed Tiba
2025-12-17 11:28 ` [PATCH 01/12] ras: add estatus core interfaces Ahmed Tiba
2025-12-17 11:28 ` [PATCH 02/12] ras: add estatus core implementation Ahmed Tiba
2025-12-18 15:42   ` Mauro Carvalho Chehab
2025-12-19 14:35     ` Ahmed Tiba
2025-12-21 19:31   ` kernel test robot
2025-12-17 11:28 ` [PATCH 03/12] ras: add estatus vendor handling and processing Ahmed Tiba
2025-12-18 16:04   ` Mauro Carvalho Chehab
2025-12-19 14:49     ` Ahmed Tiba
2025-12-19 15:30       ` Mauro Carvalho Chehab
2025-12-19 18:11         ` Ahmed Tiba
2025-12-22  8:13           ` Mauro Carvalho Chehab
2025-12-29 15:01             ` Ahmed Tiba
2025-12-21 23:39   ` kernel test robot
2025-12-17 11:28 ` [PATCH 04/12] ras: add estatus queuing and IRQ/NMI handling Ahmed Tiba
2025-12-17 11:28 ` [PATCH 05/12] ras: flesh out estatus processing core Ahmed Tiba
2025-12-17 11:28 ` Ahmed Tiba [this message]
2025-12-17 11:28 ` [PATCH 07/12] ghes: prepare estatus hooks for shared handling Ahmed Tiba
2025-12-17 11:28 ` [PATCH 08/12] ghes: add estatus provider ops Ahmed Tiba
2025-12-17 11:28 ` [PATCH 09/12] ghes: route error handling through shared estatus core Ahmed Tiba
2025-12-17 11:28 ` [PATCH 10/12] dt-bindings: ras: document estatus provider Ahmed Tiba
2025-12-17 11:41   ` Krzysztof Kozlowski
2025-12-17 17:49     ` Ahmed Tiba
2025-12-18  6:48       ` Krzysztof Kozlowski
2025-12-18 10:22         ` Ahmed Tiba
2025-12-18 10:31         ` Ahmed Tiba
2025-12-19  9:53           ` Krzysztof Kozlowski
2025-12-19 10:37             ` Ahmed Tiba
2025-12-19 10:47             ` Ahmed Tiba
2025-12-17 11:28 ` [PATCH 11/12] ras: add DeviceTree estatus provider driver Ahmed Tiba
2025-12-18 12:13   ` Will Deacon
2025-12-18 13:42     ` Ahmed Tiba
2025-12-18 15:19       ` Will Deacon
2025-12-19  9:02         ` Ahmed Tiba
2025-12-19 13:00           ` Will Deacon
2025-12-19 17:21             ` Ahmed Tiba
2026-01-05 21:09               ` Will Deacon
2025-12-17 11:28 ` [PATCH 12/12] doc: ras: describe firmware-first estatus flow Ahmed Tiba
2025-12-21  1:35 ` [PATCH 00/12] ras: share firmware-first estatus handling Borislav Petkov
2025-12-29 11:54   ` Ahmed Tiba
2026-01-14 14:15     ` Borislav Petkov
2026-01-15 12:17       ` Ahmed Tiba
2026-01-20 11:15         ` Borislav Petkov
2026-01-26 10:58           ` Ahmed Tiba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251217112845.1814119-7-ahmed.tiba@arm.com \
    --to=ahmed.tiba@arm.com \
    --cc=Dmitry.Lamerov@arm.com \
    --cc=Michael.Zhao2@arm.com \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=tony.luck@intel.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox