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 08/12] ghes: add estatus provider ops
Date: Wed, 17 Dec 2025 11:28:41 +0000 [thread overview]
Message-ID: <20251217112845.1814119-9-ahmed.tiba@arm.com> (raw)
In-Reply-To: <20251217112845.1814119-1-ahmed.tiba@arm.com>
Add the estatus_ops implementation that lets GHES present its CPER buffer
through the new core. The helper plugs the existing fixmap read/write code
into the generic callbacks, wires up the acknowledgment path for GHESv2
sources, and exposes the source name/notification attributes. No behaviour
changes yet—the next patch switches the GHES paths over to these hooks.
Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>
---
drivers/acpi/apei/ghes.c | 157 +++++++++++++++++++++++++++++++++++++++
1 file changed, 157 insertions(+)
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 0dc767392a6c..5932542ea942 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -53,6 +53,7 @@
#include <asm/tlbflush.h>
#include <cxl/event.h>
#include <ras/ras_event.h>
+#include <linux/estatus.h>
#include "apei-internal.h"
@@ -250,6 +251,8 @@ static void unmap_gen_v2(struct ghes *ghes)
apei_unmap_generic_address(&ghes->generic_v2->read_ack_register);
}
+static const struct estatus_ops ghes_estatus_ops;
+
static void ghes_ack_error(struct acpi_hest_generic_v2 *gv2)
{
int rc;
@@ -276,6 +279,8 @@ static struct ghes *ghes_new(struct acpi_hest_generic *generic)
return ERR_PTR(-ENOMEM);
ghes->generic = generic;
+ scnprintf(ghes->name, sizeof(ghes->name), "GHES source %d",
+ generic->header.source_id);
if (is_hest_type_generic_v2(ghes)) {
rc = map_gen_v2(ghes);
if (rc)
@@ -299,6 +304,12 @@ static struct ghes *ghes_new(struct acpi_hest_generic *generic)
goto err_unmap_status_addr;
}
+ ghes->estatus_src.ops = &ghes_estatus_ops;
+ ghes->estatus_src.priv = ghes;
+ ghes->estatus_src.estatus = ghes->estatus;
+ ghes->estatus_src.fixmap_idx = FIX_APEI_GHES_IRQ;
+ INIT_LIST_HEAD(&ghes->elist);
+
return ghes;
err_unmap_status_addr:
@@ -1844,3 +1855,149 @@ void ghes_unregister_report_chain(struct notifier_block *nb)
atomic_notifier_chain_unregister(&ghes_report_chain, nb);
}
EXPORT_SYMBOL_GPL(ghes_unregister_report_chain);
+
+#define GHES_ESTATUS_RW_FROM_PHYS 1
+#define GHES_ESTATUS_RW_TO_PHYS 0
+
+static void __iomem *ghes_estatus_map(struct ghes *ghes, u64 pfn,
+ enum fixed_addresses fixmap_idx)
+{
+ phys_addr_t paddr = PFN_PHYS(pfn);
+ pgprot_t prot = arch_apei_get_mem_attribute(paddr);
+
+ __set_fixmap(fixmap_idx, paddr, prot);
+
+ return (void __iomem *)__fix_to_virt(fixmap_idx);
+}
+
+static void ghes_estatus_unmap(void __iomem *vaddr,
+ enum fixed_addresses fixmap_idx)
+{
+ int _idx = virt_to_fix((unsigned long)vaddr);
+
+ WARN_ON_ONCE(fixmap_idx != _idx);
+ clear_fixmap(fixmap_idx);
+}
+
+static void ghes_estatus_copy_buffer(struct ghes *ghes, void *buffer,
+ phys_addr_t paddr, size_t len,
+ int from_phys,
+ enum fixed_addresses fixmap_idx)
+{
+ void __iomem *vaddr;
+ u64 offset;
+ u32 chunk;
+
+ while (len > 0) {
+ offset = paddr - (paddr & PAGE_MASK);
+ vaddr = ghes_estatus_map(ghes, PHYS_PFN(paddr), fixmap_idx);
+ chunk = PAGE_SIZE - offset;
+ chunk = min_t(u32, chunk, len);
+ if (from_phys == GHES_ESTATUS_RW_FROM_PHYS)
+ memcpy_fromio(buffer, vaddr + offset, chunk);
+ else
+ memcpy_toio(vaddr + offset, buffer, chunk);
+
+ len -= chunk;
+ paddr += chunk;
+ buffer += chunk;
+ ghes_estatus_unmap(vaddr, fixmap_idx);
+ }
+}
+
+static int ghes_estatus_get_phys(struct estatus_source *source,
+ phys_addr_t *addr)
+{
+ struct ghes *ghes = source->priv;
+ u64 value = 0;
+ int rc;
+
+ rc = apei_read(&value, &ghes->generic->error_status_address);
+ if (rc)
+ return rc;
+
+ *addr = value;
+ return 0;
+}
+
+static int ghes_estatus_read(struct estatus_source *source, phys_addr_t addr,
+ void *buf, size_t len,
+ enum fixed_addresses fixmap_idx)
+{
+ struct ghes *ghes = source->priv;
+
+ ghes_estatus_copy_buffer(ghes, buf, addr, len,
+ GHES_ESTATUS_RW_FROM_PHYS, fixmap_idx);
+ return 0;
+}
+
+static int ghes_estatus_write(struct estatus_source *source, phys_addr_t addr,
+ const void *buf, size_t len,
+ enum fixed_addresses fixmap_idx)
+{
+ struct ghes *ghes = source->priv;
+
+ ghes_estatus_copy_buffer(ghes, (void *)buf, addr, len,
+ GHES_ESTATUS_RW_TO_PHYS, fixmap_idx);
+ return 0;
+}
+
+static void ghes_estatus_ack(struct estatus_source *source)
+{
+ struct ghes *ghes = source->priv;
+ struct acpi_hest_generic_v2 *gv2;
+ u64 val = 0;
+ int rc;
+
+ if (ghes->generic->header.type != ACPI_HEST_TYPE_GENERIC_ERROR_V2)
+ return;
+
+ gv2 = ghes->generic_v2;
+ rc = apei_read(&val, &gv2->read_ack_register);
+ if (rc)
+ return;
+
+ val &= gv2->read_ack_preserve << gv2->read_ack_register.bit_offset;
+ val |= gv2->read_ack_write << gv2->read_ack_register.bit_offset;
+
+ apei_write(val, &gv2->read_ack_register);
+}
+
+static size_t ghes_estatus_get_max_len(struct estatus_source *source)
+{
+ struct ghes *ghes = source->priv;
+
+ return ghes->generic->error_block_length;
+}
+
+static enum estatus_notify_mode
+ghes_estatus_get_notify_mode(struct estatus_source *source)
+{
+ struct ghes *ghes = source->priv;
+ u8 notify_type = ghes->generic->notify.type;
+
+ if (notify_type == ACPI_HEST_NOTIFY_SEA)
+ return ESTATUS_NOTIFY_SEA;
+
+ return ESTATUS_NOTIFY_ASYNC;
+}
+
+static const char *ghes_estatus_get_name(struct estatus_source *source)
+{
+ struct ghes *ghes = source->priv;
+
+ if (ghes->dev)
+ return dev_name(ghes->dev);
+
+ return ghes->name;
+}
+
+static const struct estatus_ops ghes_estatus_ops = {
+ .get_phys = ghes_estatus_get_phys,
+ .read = ghes_estatus_read,
+ .write = ghes_estatus_write,
+ .ack = ghes_estatus_ack,
+ .get_max_len = ghes_estatus_get_max_len,
+ .get_notify_mode = ghes_estatus_get_notify_mode,
+ .get_name = ghes_estatus_get_name,
+};
--
2.43.0
next prev parent reply other threads:[~2025-12-17 11:31 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 ` [PATCH 06/12] efi/cper: adopt estatus iteration helpers Ahmed Tiba
2025-12-17 11:28 ` [PATCH 07/12] ghes: prepare estatus hooks for shared handling Ahmed Tiba
2025-12-17 11:28 ` Ahmed Tiba [this message]
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-9-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