* [PATCH v4 0/9] Enable EINJv2 Support
@ 2025-03-06 23:48 Zaid Alali
2025-03-06 23:48 ` [PATCH v4 1/9] ACPICA: Update values to hex to follow ACPI specs Zaid Alali
` (8 more replies)
0 siblings, 9 replies; 20+ messages in thread
From: Zaid Alali @ 2025-03-06 23:48 UTC (permalink / raw)
To: rafael, lenb, james.morse, tony.luck, bp, robert.moore,
dan.j.williams, zaidal, Jonathan.Cameron, Benjamin.Cheatham,
Avadhut.Naik, viro, arnd, ira.weiny, dave.jiang,
sthanneeru.opensrc, linux-acpi, linux-kernel, acpica-devel
From: Your Name <zaidal@os.amperecomputing.com>
The goal of this update is to allow the driver to simultaneously
support EINJ and EINJv2. The implementation follows the approved
ACPI specs(1)(2) that enables the driver to discover system
capabilities through GET_ERROR_TYPE.
Note: The first two ACPICA patches are to be dropped once merged in
ACPICA project, see pull request(3).
(1) https://bugzilla.tianocore.org/show_bug.cgi?id=4615
(2) https://bugzilla.tianocore.org/attachment.cgi?id=1521
(3) https://github.com/acpica/acpica/pull/977
Zaid Alali (9):
ACPICA: Update values to hex to follow ACPI specs
ACPICA: Add EINJv2 get error type action
ACPI: APEI: EINJ: Fix kernel test robot sparse warning
ACPI: APEI: EINJ: Remove redundant calls to
einj_get_available_error_type
ACPI: APEI: EINJ: Enable the discovery of EINJv2 capabilities
ACPI: APEI: EINJ: Add einjv2 extension struct
ACPI: APEI: EINJ: Add debugfs files for EINJv2 support
ACPI: APEI: EINJ: Enable EINJv2 error injections
ACPI: APEI: EINJ: Update the documentation for EINJv2 support
.../firmware-guide/acpi/apei/einj.rst | 41 ++-
drivers/acpi/apei/apei-internal.h | 2 +-
drivers/acpi/apei/einj-core.c | 322 +++++++++++++-----
drivers/acpi/apei/einj-cxl.c | 2 +-
include/acpi/actbl1.h | 25 +-
5 files changed, 299 insertions(+), 93 deletions(-)
--
2.46.0
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v4 1/9] ACPICA: Update values to hex to follow ACPI specs
2025-03-06 23:48 [PATCH v4 0/9] Enable EINJv2 Support Zaid Alali
@ 2025-03-06 23:48 ` Zaid Alali
2025-03-06 23:48 ` [PATCH v4 2/9] ACPICA: Add EINJv2 get error type action Zaid Alali
` (7 subsequent siblings)
8 siblings, 0 replies; 20+ messages in thread
From: Zaid Alali @ 2025-03-06 23:48 UTC (permalink / raw)
To: rafael, lenb, james.morse, tony.luck, bp, robert.moore,
dan.j.williams, zaidal, Jonathan.Cameron, Benjamin.Cheatham,
Avadhut.Naik, viro, arnd, ira.weiny, dave.jiang,
sthanneeru.opensrc, linux-acpi, linux-kernel, acpica-devel
ACPI specs(1) define Error Injection Actions in hex values.
This commit intends to update values from decimal to hex to be
consistent with ACPI specs. This commit and the following one are
not to be merged and will come form ACPICA project see pull request(2).
(1) https://uefi.org/specs/ACPI/6.5/18_Platform_Error_Interfaces.html
(2) https://github.com/acpica/acpica/pull/977
Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com>
---
include/acpi/actbl1.h | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h
index 387fc821703a..c701c434976c 100644
--- a/include/acpi/actbl1.h
+++ b/include/acpi/actbl1.h
@@ -1024,18 +1024,18 @@ struct acpi_einj_entry {
/* Values for Action field above */
enum acpi_einj_actions {
- ACPI_EINJ_BEGIN_OPERATION = 0,
- ACPI_EINJ_GET_TRIGGER_TABLE = 1,
- ACPI_EINJ_SET_ERROR_TYPE = 2,
- ACPI_EINJ_GET_ERROR_TYPE = 3,
- ACPI_EINJ_END_OPERATION = 4,
- ACPI_EINJ_EXECUTE_OPERATION = 5,
- ACPI_EINJ_CHECK_BUSY_STATUS = 6,
- ACPI_EINJ_GET_COMMAND_STATUS = 7,
- ACPI_EINJ_SET_ERROR_TYPE_WITH_ADDRESS = 8,
- ACPI_EINJ_GET_EXECUTE_TIMINGS = 9,
- ACPI_EINJ_ACTION_RESERVED = 10, /* 10 and greater are reserved */
- ACPI_EINJ_TRIGGER_ERROR = 0xFF /* Except for this value */
+ ACPI_EINJ_BEGIN_OPERATION = 0x0,
+ ACPI_EINJ_GET_TRIGGER_TABLE = 0x1,
+ ACPI_EINJ_SET_ERROR_TYPE = 0x2,
+ ACPI_EINJ_GET_ERROR_TYPE = 0x3,
+ ACPI_EINJ_END_OPERATION = 0x4,
+ ACPI_EINJ_EXECUTE_OPERATION = 0x5,
+ ACPI_EINJ_CHECK_BUSY_STATUS = 0x6,
+ ACPI_EINJ_GET_COMMAND_STATUS = 0x7,
+ ACPI_EINJ_SET_ERROR_TYPE_WITH_ADDRESS = 0x8,
+ ACPI_EINJ_GET_EXECUTE_TIMINGS = 0x9,
+ ACPI_EINJ_ACTION_RESERVED = 0xA, /* 0xA and greater are reserved */
+ ACPI_EINJ_TRIGGER_ERROR = 0xFF /* Except for this value */
};
/* Values for Instruction field above */
--
2.46.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v4 2/9] ACPICA: Add EINJv2 get error type action
2025-03-06 23:48 [PATCH v4 0/9] Enable EINJv2 Support Zaid Alali
2025-03-06 23:48 ` [PATCH v4 1/9] ACPICA: Update values to hex to follow ACPI specs Zaid Alali
@ 2025-03-06 23:48 ` Zaid Alali
2025-03-06 23:48 ` [PATCH v4 3/9] ACPI: APEI: EINJ: Fix kernel test robot sparse warning Zaid Alali
` (6 subsequent siblings)
8 siblings, 0 replies; 20+ messages in thread
From: Zaid Alali @ 2025-03-06 23:48 UTC (permalink / raw)
To: rafael, lenb, james.morse, tony.luck, bp, robert.moore,
dan.j.williams, zaidal, Jonathan.Cameron, Benjamin.Cheatham,
Avadhut.Naik, viro, arnd, ira.weiny, dave.jiang,
sthanneeru.opensrc, linux-acpi, linux-kernel, acpica-devel
Add EINJV2_GET_ERROR_TYPE as defined in the approved new ACPI
specs(1)(2).
Proposed ACPI spces for EINJv2:
(1) https://bugzilla.tianocore.org/show_bug.cgi?id=4615
(2) https://bugzilla.tianocore.org/attachment.cgi?id=1521
This commit is not a direct merge, it will come from ACPICA
project, see pull request(3).
(3) https://github.com/acpica/acpica/pull/977
Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com>
---
include/acpi/actbl1.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h
index c701c434976c..f52d5cafaf76 100644
--- a/include/acpi/actbl1.h
+++ b/include/acpi/actbl1.h
@@ -1034,7 +1034,8 @@ enum acpi_einj_actions {
ACPI_EINJ_GET_COMMAND_STATUS = 0x7,
ACPI_EINJ_SET_ERROR_TYPE_WITH_ADDRESS = 0x8,
ACPI_EINJ_GET_EXECUTE_TIMINGS = 0x9,
- ACPI_EINJ_ACTION_RESERVED = 0xA, /* 0xA and greater are reserved */
+ ACPI_EINJV2_GET_ERROR_TYPE = 0x11,
+ ACPI_EINJ_ACTION_RESERVED = 0x12, /* 0x12 and greater are reserved */
ACPI_EINJ_TRIGGER_ERROR = 0xFF /* Except for this value */
};
--
2.46.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v4 3/9] ACPI: APEI: EINJ: Fix kernel test robot sparse warning
2025-03-06 23:48 [PATCH v4 0/9] Enable EINJv2 Support Zaid Alali
2025-03-06 23:48 ` [PATCH v4 1/9] ACPICA: Update values to hex to follow ACPI specs Zaid Alali
2025-03-06 23:48 ` [PATCH v4 2/9] ACPICA: Add EINJv2 get error type action Zaid Alali
@ 2025-03-06 23:48 ` Zaid Alali
2025-03-08 8:55 ` kernel test robot
` (2 more replies)
2025-03-06 23:48 ` [PATCH v4 4/9] ACPI: APEI: EINJ: Remove redundant calls to einj_get_available_error_type Zaid Alali
` (5 subsequent siblings)
8 siblings, 3 replies; 20+ messages in thread
From: Zaid Alali @ 2025-03-06 23:48 UTC (permalink / raw)
To: rafael, lenb, james.morse, tony.luck, bp, robert.moore,
dan.j.williams, zaidal, Jonathan.Cameron, Benjamin.Cheatham,
Avadhut.Naik, viro, arnd, ira.weiny, dave.jiang,
sthanneeru.opensrc, linux-acpi, linux-kernel, acpica-devel
This patch fixes the kernel test robot warning reported here:
https://lore.kernel.org/all/202410241620.oApALow5-lkp@intel.com/
Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com>
---
drivers/acpi/apei/einj-core.c | 104 +++++++++++++++++++---------------
1 file changed, 59 insertions(+), 45 deletions(-)
diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
index 04731a5b01fa..b40ed44c4983 100644
--- a/drivers/acpi/apei/einj-core.c
+++ b/drivers/acpi/apei/einj-core.c
@@ -149,7 +149,7 @@ static DEFINE_MUTEX(einj_mutex);
*/
bool einj_initialized __ro_after_init;
-static void *einj_param;
+static void __iomem *einj_param;
static void einj_exec_ctx_init(struct apei_exec_context *ctx)
{
@@ -214,21 +214,23 @@ static void check_vendor_extension(u64 paddr,
struct set_error_type_with_address *v5param)
{
int offset = v5param->vendor_extension;
- struct vendor_error_type_extension *v;
+ struct vendor_error_type_extension v;
+ void __iomem *p;
u32 sbdf;
if (!offset)
return;
- v = acpi_os_map_iomem(paddr + offset, sizeof(*v));
- if (!v)
+ p = acpi_os_map_iomem(paddr + offset, sizeof(v));
+ if (!p)
return;
- get_oem_vendor_struct(paddr, offset, v);
- sbdf = v->pcie_sbdf;
+ memcpy_fromio(&v, p, sizeof(v));
+ get_oem_vendor_struct(paddr, offset, &v);
+ sbdf = v.pcie_sbdf;
sprintf(vendor_dev, "%x:%x:%x.%x vendor_id=%x device_id=%x rev_id=%x\n",
sbdf >> 24, (sbdf >> 16) & 0xff,
(sbdf >> 11) & 0x1f, (sbdf >> 8) & 0x7,
- v->vendor_id, v->device_id, v->rev_id);
- acpi_os_unmap_iomem(v, sizeof(*v));
+ v.vendor_id, v.device_id, v.rev_id);
+ acpi_os_unmap_iomem(p, sizeof(v));
}
static void *einj_get_parameter_address(void)
@@ -252,26 +254,30 @@ static void *einj_get_parameter_address(void)
entry++;
}
if (pa_v5) {
- struct set_error_type_with_address *v5param;
+ struct set_error_type_with_address v5param;
+ void __iomem *p;
- v5param = acpi_os_map_iomem(pa_v5, sizeof(*v5param));
- if (v5param) {
+ p = acpi_os_map_iomem(pa_v5, sizeof(v5param));
+ if (p) {
+ memcpy_fromio(&v5param, p, sizeof(v5param));
acpi5 = 1;
- check_vendor_extension(pa_v5, v5param);
- return v5param;
+ check_vendor_extension(pa_v5, &v5param);
+ return p;
}
}
if (param_extension && pa_v4) {
- struct einj_parameter *v4param;
+ struct einj_parameter v4param;
+ void __iomem *p;
- v4param = acpi_os_map_iomem(pa_v4, sizeof(*v4param));
- if (!v4param)
+ p = acpi_os_map_iomem(pa_v4, sizeof(v4param));
+ if (!p)
return NULL;
- if (v4param->reserved1 || v4param->reserved2) {
- acpi_os_unmap_iomem(v4param, sizeof(*v4param));
+ memcpy_fromio(&v4param, p, sizeof(v4param));
+ if (v4param.reserved1 || v4param.reserved2) {
+ acpi_os_unmap_iomem(p, sizeof(v4param));
return NULL;
}
- return v4param;
+ return p;
}
return NULL;
@@ -317,7 +323,7 @@ static struct acpi_generic_address *einj_get_trigger_parameter_region(
static int __einj_error_trigger(u64 trigger_paddr, u32 type,
u64 param1, u64 param2)
{
- struct acpi_einj_trigger *trigger_tab = NULL;
+ struct acpi_einj_trigger trigger_tab;
struct apei_exec_context trigger_ctx;
struct apei_resources trigger_resources;
struct acpi_whea_header *trigger_entry;
@@ -325,54 +331,57 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
u32 table_size;
int rc = -EIO;
struct acpi_generic_address *trigger_param_region = NULL;
+ void __iomem *p;
- r = request_mem_region(trigger_paddr, sizeof(*trigger_tab),
+ r = request_mem_region(trigger_paddr, sizeof(trigger_tab),
"APEI EINJ Trigger Table");
if (!r) {
pr_err("Can not request [mem %#010llx-%#010llx] for Trigger table\n",
(unsigned long long)trigger_paddr,
(unsigned long long)trigger_paddr +
- sizeof(*trigger_tab) - 1);
+ sizeof(trigger_tab) - 1);
goto out;
}
- trigger_tab = ioremap_cache(trigger_paddr, sizeof(*trigger_tab));
- if (!trigger_tab) {
+ p = ioremap_cache(trigger_paddr, sizeof(trigger_tab));
+ if (!p) {
pr_err("Failed to map trigger table!\n");
goto out_rel_header;
}
- rc = einj_check_trigger_header(trigger_tab);
+ memcpy_fromio(&trigger_tab, p, sizeof(trigger_tab));
+ rc = einj_check_trigger_header(&trigger_tab);
if (rc) {
pr_warn(FW_BUG "Invalid trigger error action table.\n");
goto out_rel_header;
}
/* No action structures in the TRIGGER_ERROR table, nothing to do */
- if (!trigger_tab->entry_count)
+ if (!trigger_tab.entry_count)
goto out_rel_header;
rc = -EIO;
- table_size = trigger_tab->table_size;
- r = request_mem_region(trigger_paddr + sizeof(*trigger_tab),
- table_size - sizeof(*trigger_tab),
+ table_size = trigger_tab.table_size;
+ r = request_mem_region(trigger_paddr + sizeof(trigger_tab),
+ table_size - sizeof(trigger_tab),
"APEI EINJ Trigger Table");
if (!r) {
pr_err("Can not request [mem %#010llx-%#010llx] for Trigger Table Entry\n",
- (unsigned long long)trigger_paddr + sizeof(*trigger_tab),
+ (unsigned long long)trigger_paddr + sizeof(trigger_tab),
(unsigned long long)trigger_paddr + table_size - 1);
goto out_rel_header;
}
- iounmap(trigger_tab);
- trigger_tab = ioremap_cache(trigger_paddr, table_size);
- if (!trigger_tab) {
+ iounmap(p);
+ p = ioremap_cache(trigger_paddr, table_size);
+ if (!p) {
pr_err("Failed to map trigger table!\n");
goto out_rel_entry;
}
+ memcpy_fromio(&trigger_tab, p, sizeof(trigger_tab));
trigger_entry = (struct acpi_whea_header *)
- ((char *)trigger_tab + sizeof(struct acpi_einj_trigger));
+ ((char *)&trigger_tab + sizeof(struct acpi_einj_trigger));
apei_resources_init(&trigger_resources);
apei_exec_ctx_init(&trigger_ctx, einj_ins_type,
ARRAY_SIZE(einj_ins_type),
- trigger_entry, trigger_tab->entry_count);
+ trigger_entry, trigger_tab.entry_count);
rc = apei_exec_collect_resources(&trigger_ctx, &trigger_resources);
if (rc)
goto out_fini;
@@ -390,7 +399,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
apei_resources_init(&addr_resources);
trigger_param_region = einj_get_trigger_parameter_region(
- trigger_tab, param1, param2);
+ &trigger_tab, param1, param2);
if (trigger_param_region) {
rc = apei_resources_add(&addr_resources,
trigger_param_region->address,
@@ -419,13 +428,13 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
out_fini:
apei_resources_fini(&trigger_resources);
out_rel_entry:
- release_mem_region(trigger_paddr + sizeof(*trigger_tab),
- table_size - sizeof(*trigger_tab));
+ release_mem_region(trigger_paddr + sizeof(trigger_tab),
+ table_size - sizeof(trigger_tab));
out_rel_header:
- release_mem_region(trigger_paddr, sizeof(*trigger_tab));
+ release_mem_region(trigger_paddr, sizeof(trigger_tab));
out:
- if (trigger_tab)
- iounmap(trigger_tab);
+ if (p)
+ iounmap(p);
return rc;
}
@@ -444,8 +453,10 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
return rc;
apei_exec_ctx_set_input(&ctx, type);
if (acpi5) {
- struct set_error_type_with_address *v5param = einj_param;
+ struct set_error_type_with_address *v5param, v5_struct;
+ v5param = &v5_struct;
+ memcpy_fromio(v5param, einj_param, sizeof(*v5param));
v5param->type = type;
if (type & ACPI5_VENDOR_BIT) {
switch (vendor_flags) {
@@ -490,15 +501,18 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
break;
}
}
+ memcpy_toio(einj_param, v5param, sizeof(*v5param));
} else {
rc = apei_exec_run(&ctx, ACPI_EINJ_SET_ERROR_TYPE);
if (rc)
return rc;
if (einj_param) {
- struct einj_parameter *v4param = einj_param;
+ struct einj_parameter v4param;
- v4param->param1 = param1;
- v4param->param2 = param2;
+ memcpy_fromio(&v4param, einj_param, sizeof(v4param));
+ v4param.param1 = param1;
+ v4param.param2 = param2;
+ memcpy_toio(einj_param, &v4param, sizeof(v4param));
}
}
rc = apei_exec_run(&ctx, ACPI_EINJ_EXECUTE_OPERATION);
--
2.46.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v4 4/9] ACPI: APEI: EINJ: Remove redundant calls to einj_get_available_error_type
2025-03-06 23:48 [PATCH v4 0/9] Enable EINJv2 Support Zaid Alali
` (2 preceding siblings ...)
2025-03-06 23:48 ` [PATCH v4 3/9] ACPI: APEI: EINJ: Fix kernel test robot sparse warning Zaid Alali
@ 2025-03-06 23:48 ` Zaid Alali
2025-03-06 23:48 ` [PATCH v4 5/9] ACPI: APEI: EINJ: Enable the discovery of EINJv2 capabilities Zaid Alali
` (4 subsequent siblings)
8 siblings, 0 replies; 20+ messages in thread
From: Zaid Alali @ 2025-03-06 23:48 UTC (permalink / raw)
To: rafael, lenb, james.morse, tony.luck, bp, robert.moore,
dan.j.williams, zaidal, Jonathan.Cameron, Benjamin.Cheatham,
Avadhut.Naik, viro, arnd, ira.weiny, dave.jiang,
sthanneeru.opensrc, linux-acpi, linux-kernel, acpica-devel
A single call to einj_get_available_error_type in init function is
sufficient to save the return value in a global variable to be used
later in various places in the code. This commit does not introduce
any functional changes, but only removing unnecessary redundant
function calls.
Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
drivers/acpi/apei/einj-core.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
index b40ed44c4983..3f828f9265a8 100644
--- a/drivers/acpi/apei/einj-core.c
+++ b/drivers/acpi/apei/einj-core.c
@@ -83,6 +83,8 @@ static struct debugfs_blob_wrapper vendor_blob;
static struct debugfs_blob_wrapper vendor_errors;
static char vendor_dev[64];
+static u32 available_error_type;
+
/*
* Some BIOSes allow parameters to the SET_ERROR_TYPE entries in the
* EINJ table through an unpublished extension. Use with caution as
@@ -662,14 +664,9 @@ static struct { u32 mask; const char *str; } const einj_error_type_string[] = {
static int available_error_type_show(struct seq_file *m, void *v)
{
- int rc;
- u32 error_type = 0;
- rc = einj_get_available_error_type(&error_type);
- if (rc)
- return rc;
for (int pos = 0; pos < ARRAY_SIZE(einj_error_type_string); pos++)
- if (error_type & einj_error_type_string[pos].mask)
+ if (available_error_type & einj_error_type_string[pos].mask)
seq_printf(m, "0x%08x\t%s\n", einj_error_type_string[pos].mask,
einj_error_type_string[pos].str);
@@ -692,8 +689,7 @@ bool einj_is_cxl_error_type(u64 type)
int einj_validate_error_type(u64 type)
{
- u32 tval, vendor, available_error_type = 0;
- int rc;
+ u32 tval, vendor;
/* Only low 32 bits for error type are valid */
if (type & GENMASK_ULL(63, 32))
@@ -709,13 +705,9 @@ int einj_validate_error_type(u64 type)
/* Only one error type can be specified */
if (tval & (tval - 1))
return -EINVAL;
- if (!vendor) {
- rc = einj_get_available_error_type(&available_error_type);
- if (rc)
- return rc;
+ if (!vendor)
if (!(type & available_error_type))
return -EINVAL;
- }
return 0;
}
@@ -791,6 +783,10 @@ static int __init einj_probe(struct platform_device *pdev)
goto err_put_table;
}
+ rc = einj_get_available_error_type(&available_error_type);
+ if (rc)
+ return rc;
+
rc = -ENOMEM;
einj_debug_dir = debugfs_create_dir("einj", apei_get_debugfs_dir());
--
2.46.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v4 5/9] ACPI: APEI: EINJ: Enable the discovery of EINJv2 capabilities
2025-03-06 23:48 [PATCH v4 0/9] Enable EINJv2 Support Zaid Alali
` (3 preceding siblings ...)
2025-03-06 23:48 ` [PATCH v4 4/9] ACPI: APEI: EINJ: Remove redundant calls to einj_get_available_error_type Zaid Alali
@ 2025-03-06 23:48 ` Zaid Alali
2025-03-13 9:39 ` Jonathan Cameron
2025-03-06 23:48 ` [PATCH v4 6/9] ACPI: APEI: EINJ: Add einjv2 extension struct Zaid Alali
` (3 subsequent siblings)
8 siblings, 1 reply; 20+ messages in thread
From: Zaid Alali @ 2025-03-06 23:48 UTC (permalink / raw)
To: rafael, lenb, james.morse, tony.luck, bp, robert.moore,
dan.j.williams, zaidal, Jonathan.Cameron, Benjamin.Cheatham,
Avadhut.Naik, viro, arnd, ira.weiny, dave.jiang,
sthanneeru.opensrc, linux-acpi, linux-kernel, acpica-devel
Enable the driver to show all supported error injections for EINJ
and EINJv2 at the same time. EINJv2 capabilities can be discovered
by checking the return value of get_error_type, where bit 30 set
indicates EINJv2 support.
Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com>
---
drivers/acpi/apei/apei-internal.h | 2 +-
drivers/acpi/apei/einj-core.c | 64 ++++++++++++++++++++++++-------
drivers/acpi/apei/einj-cxl.c | 2 +-
3 files changed, 52 insertions(+), 16 deletions(-)
diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
index cd2766c69d78..77c10a7a7a9f 100644
--- a/drivers/acpi/apei/apei-internal.h
+++ b/drivers/acpi/apei/apei-internal.h
@@ -131,7 +131,7 @@ static inline u32 cper_estatus_len(struct acpi_hest_generic_status *estatus)
int apei_osc_setup(void);
-int einj_get_available_error_type(u32 *type);
+int einj_get_available_error_type(u32 *type, int einj_action);
int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, u64 param3,
u64 param4);
int einj_cxl_rch_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
index 3f828f9265a8..aee9a7b17313 100644
--- a/drivers/acpi/apei/einj-core.c
+++ b/drivers/acpi/apei/einj-core.c
@@ -33,6 +33,7 @@
#define SLEEP_UNIT_MAX 5000 /* 5ms */
/* Firmware should respond within 1 seconds */
#define FIRMWARE_TIMEOUT (1 * USEC_PER_SEC)
+#define ACPI65_EINJV2_SUPP BIT(30)
#define ACPI5_VENDOR_BIT BIT(31)
#define MEM_ERROR_MASK (ACPI_EINJ_MEMORY_CORRECTABLE | \
ACPI_EINJ_MEMORY_UNCORRECTABLE | \
@@ -84,6 +85,7 @@ static struct debugfs_blob_wrapper vendor_errors;
static char vendor_dev[64];
static u32 available_error_type;
+static u32 available_error_type_v2;
/*
* Some BIOSes allow parameters to the SET_ERROR_TYPE entries in the
@@ -159,13 +161,13 @@ static void einj_exec_ctx_init(struct apei_exec_context *ctx)
EINJ_TAB_ENTRY(einj_tab), einj_tab->entries);
}
-static int __einj_get_available_error_type(u32 *type)
+static int __einj_get_available_error_type(u32 *type, int einj_action)
{
struct apei_exec_context ctx;
int rc;
einj_exec_ctx_init(&ctx);
- rc = apei_exec_run(&ctx, ACPI_EINJ_GET_ERROR_TYPE);
+ rc = apei_exec_run(&ctx, einj_action);
if (rc)
return rc;
*type = apei_exec_ctx_get_output(&ctx);
@@ -174,12 +176,12 @@ static int __einj_get_available_error_type(u32 *type)
}
/* Get error injection capabilities of the platform */
-int einj_get_available_error_type(u32 *type)
+int einj_get_available_error_type(u32 *type, int einj_action)
{
int rc;
mutex_lock(&einj_mutex);
- rc = __einj_get_available_error_type(type);
+ rc = __einj_get_available_error_type(type, einj_action);
mutex_unlock(&einj_mutex);
return rc;
@@ -646,6 +648,7 @@ static u64 error_param2;
static u64 error_param3;
static u64 error_param4;
static struct dentry *einj_debug_dir;
+static char einj_buf[32];
static struct { u32 mask; const char *str; } const einj_error_type_string[] = {
{ BIT(0), "Processor Correctable" },
{ BIT(1), "Processor Uncorrectable non-fatal" },
@@ -662,6 +665,12 @@ static struct { u32 mask; const char *str; } const einj_error_type_string[] = {
{ BIT(31), "Vendor Defined Error Types" },
};
+static struct { u32 mask; const char *str; } const einjv2_error_type_string[] = {
+ { BIT(0), "EINJV2 Processor Error" },
+ { BIT(1), "EINJV2 Memory Error" },
+ { BIT(2), "EINJV2 PCI Express Error" },
+};
+
static int available_error_type_show(struct seq_file *m, void *v)
{
@@ -669,17 +678,22 @@ static int available_error_type_show(struct seq_file *m, void *v)
if (available_error_type & einj_error_type_string[pos].mask)
seq_printf(m, "0x%08x\t%s\n", einj_error_type_string[pos].mask,
einj_error_type_string[pos].str);
-
+ if (available_error_type & ACPI65_EINJV2_SUPP) {
+ for (int pos = 0; pos < ARRAY_SIZE(einjv2_error_type_string); pos++) {
+ if (available_error_type_v2 & einjv2_error_type_string[pos].mask)
+ seq_printf(m, "V2_0x%08x\t%s\n", einjv2_error_type_string[pos].mask,
+ einjv2_error_type_string[pos].str);
+ }
+ }
return 0;
}
DEFINE_SHOW_ATTRIBUTE(available_error_type);
-static int error_type_get(void *data, u64 *val)
+static ssize_t error_type_get(struct file *file, char __user *buf,
+ size_t count, loff_t *ppos)
{
- *val = error_type;
-
- return 0;
+ return simple_read_from_buffer(buf, count, ppos, einj_buf, strlen(einj_buf));
}
bool einj_is_cxl_error_type(u64 type)
@@ -712,9 +726,23 @@ int einj_validate_error_type(u64 type)
return 0;
}
-static int error_type_set(void *data, u64 val)
+static ssize_t error_type_set(struct file *file, const char __user *buf,
+ size_t count, loff_t *ppos)
{
int rc;
+ u64 val;
+
+ memset(einj_buf, 0, sizeof(einj_buf));
+ if (copy_from_user(einj_buf, buf, count))
+ return -EFAULT;
+
+ if (strncmp(einj_buf, "V2_", 3) == 0) {
+ if (!sscanf(einj_buf, "V2_%llx", &val))
+ return -EINVAL;
+ } else {
+ if (!sscanf(einj_buf, "%llx", &val))
+ return -EINVAL;
+ }
rc = einj_validate_error_type(val);
if (rc)
@@ -722,11 +750,13 @@ static int error_type_set(void *data, u64 val)
error_type = val;
- return 0;
+ return count;
}
-DEFINE_DEBUGFS_ATTRIBUTE(error_type_fops, error_type_get, error_type_set,
- "0x%llx\n");
+static const struct file_operations error_type_fops = {
+ .read = error_type_get,
+ .write = error_type_set,
+};
static int error_inject_set(void *data, u64 val)
{
@@ -783,9 +813,15 @@ static int __init einj_probe(struct platform_device *pdev)
goto err_put_table;
}
- rc = einj_get_available_error_type(&available_error_type);
+ rc = einj_get_available_error_type(&available_error_type, ACPI_EINJ_GET_ERROR_TYPE);
if (rc)
return rc;
+ if (available_error_type & ACPI65_EINJV2_SUPP) {
+ rc = einj_get_available_error_type(&available_error_type_v2,
+ ACPI_EINJV2_GET_ERROR_TYPE);
+ if (rc)
+ return rc;
+ }
rc = -ENOMEM;
einj_debug_dir = debugfs_create_dir("einj", apei_get_debugfs_dir());
diff --git a/drivers/acpi/apei/einj-cxl.c b/drivers/acpi/apei/einj-cxl.c
index 78da9ae543a2..e70a416ec925 100644
--- a/drivers/acpi/apei/einj-cxl.c
+++ b/drivers/acpi/apei/einj-cxl.c
@@ -30,7 +30,7 @@ int einj_cxl_available_error_type_show(struct seq_file *m, void *v)
int cxl_err, rc;
u32 available_error_type = 0;
- rc = einj_get_available_error_type(&available_error_type);
+ rc = einj_get_available_error_type(&available_error_type, ACPI_EINJ_GET_ERROR_TYPE);
if (rc)
return rc;
--
2.46.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v4 6/9] ACPI: APEI: EINJ: Add einjv2 extension struct
2025-03-06 23:48 [PATCH v4 0/9] Enable EINJv2 Support Zaid Alali
` (4 preceding siblings ...)
2025-03-06 23:48 ` [PATCH v4 5/9] ACPI: APEI: EINJ: Enable the discovery of EINJv2 capabilities Zaid Alali
@ 2025-03-06 23:48 ` Zaid Alali
2025-03-13 9:42 ` Jonathan Cameron
2025-03-06 23:48 ` [PATCH v4 7/9] ACPI: APEI: EINJ: Add debugfs files for EINJv2 support Zaid Alali
` (2 subsequent siblings)
8 siblings, 1 reply; 20+ messages in thread
From: Zaid Alali @ 2025-03-06 23:48 UTC (permalink / raw)
To: rafael, lenb, james.morse, tony.luck, bp, robert.moore,
dan.j.williams, zaidal, Jonathan.Cameron, Benjamin.Cheatham,
Avadhut.Naik, viro, arnd, ira.weiny, dave.jiang,
sthanneeru.opensrc, linux-acpi, linux-kernel, acpica-devel
Add einjv2 extension struct and EINJv2 error types to prepare
the driver for EINJv2 support. ACPI specifications(1) enables
EINJv2 by extending set_error_type_with_address struct.
(1) https://bugzilla.tianocore.org/show_bug.cgi?id=4615
Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com>
---
drivers/acpi/apei/einj-core.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
index aee9a7b17313..32b8d102f399 100644
--- a/drivers/acpi/apei/einj-core.c
+++ b/drivers/acpi/apei/einj-core.c
@@ -50,6 +50,28 @@
*/
static int acpi5;
+struct syndrome_array {
+ union {
+ u32 acpi_id;
+ u32 device_id;
+ u32 pcie_sbdf;
+ u8 vendor_id[16];
+ } comp_id;
+ union {
+ u32 proc_synd;
+ u32 mem_synd;
+ u32 pcie_synd;
+ u8 vendor_synd[16];
+ } comp_synd;
+};
+
+struct einjv2_extension_struct {
+ u32 length;
+ u16 revision;
+ u16 component_arr_count;
+ struct syndrome_array component_arr[];
+};
+
struct set_error_type_with_address {
u32 type;
u32 vendor_extension;
@@ -58,6 +80,7 @@ struct set_error_type_with_address {
u64 memory_address;
u64 memory_address_range;
u32 pcie_sbdf;
+ struct einjv2_extension_struct einjv2_struct;
};
enum {
SETWA_FLAGS_APICID = 1,
--
2.46.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v4 7/9] ACPI: APEI: EINJ: Add debugfs files for EINJv2 support
2025-03-06 23:48 [PATCH v4 0/9] Enable EINJv2 Support Zaid Alali
` (5 preceding siblings ...)
2025-03-06 23:48 ` [PATCH v4 6/9] ACPI: APEI: EINJ: Add einjv2 extension struct Zaid Alali
@ 2025-03-06 23:48 ` Zaid Alali
2025-03-13 9:46 ` Jonathan Cameron
2025-03-06 23:48 ` [PATCH v4 8/9] ACPI: APEI: EINJ: Enable EINJv2 error injections Zaid Alali
2025-03-06 23:48 ` [PATCH v4 9/9] ACPI: APEI: EINJ: Update the documentation for EINJv2 support Zaid Alali
8 siblings, 1 reply; 20+ messages in thread
From: Zaid Alali @ 2025-03-06 23:48 UTC (permalink / raw)
To: rafael, lenb, james.morse, tony.luck, bp, robert.moore,
dan.j.williams, zaidal, Jonathan.Cameron, Benjamin.Cheatham,
Avadhut.Naik, viro, arnd, ira.weiny, dave.jiang,
sthanneeru.opensrc, linux-acpi, linux-kernel, acpica-devel
Create a debugfs blob file to be used for reading the user
input for the component array. EINJv2 enables users to inject
errors to multiple components/devices at the same time using
component array.
Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com>
---
drivers/acpi/apei/einj-core.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
index 32b8d102f399..4c748fa0a479 100644
--- a/drivers/acpi/apei/einj-core.c
+++ b/drivers/acpi/apei/einj-core.c
@@ -33,6 +33,7 @@
#define SLEEP_UNIT_MAX 5000 /* 5ms */
/* Firmware should respond within 1 seconds */
#define FIRMWARE_TIMEOUT (1 * USEC_PER_SEC)
+#define COMP_ARR_SIZE 1024
#define ACPI65_EINJV2_SUPP BIT(30)
#define ACPI5_VENDOR_BIT BIT(31)
#define MEM_ERROR_MASK (ACPI_EINJ_MEMORY_CORRECTABLE | \
@@ -107,6 +108,9 @@ static struct debugfs_blob_wrapper vendor_blob;
static struct debugfs_blob_wrapper vendor_errors;
static char vendor_dev[64];
+static struct debugfs_blob_wrapper einjv2_component_arr;
+static u64 component_count;
+static void *user_input;
static u32 available_error_type;
static u32 available_error_type_v2;
@@ -890,6 +894,19 @@ static int __init einj_probe(struct platform_device *pdev)
&error_param4);
debugfs_create_x32("notrigger", S_IRUSR | S_IWUSR,
einj_debug_dir, ¬rigger);
+ if (available_error_type & ACPI65_EINJV2_SUPP) {
+ debugfs_create_x64("einjv2_component_count", S_IRUSR | S_IWUSR,
+ einj_debug_dir, &component_count);
+ user_input = kzalloc(COMP_ARR_SIZE, GFP_KERNEL);
+ if (!user_input) {
+ rc = -ENOMEM;
+ goto err_alloc;
+ }
+ einjv2_component_arr.data = user_input;
+ einjv2_component_arr.size = COMP_ARR_SIZE;
+ debugfs_create_blob("einjv2_component_array", S_IRUSR | S_IWUSR,
+ einj_debug_dir, &einjv2_component_arr);
+ }
}
if (vendor_dev[0]) {
@@ -909,6 +926,8 @@ static int __init einj_probe(struct platform_device *pdev)
return 0;
+err_alloc:
+ apei_exec_post_unmap_gars(&ctx);
err_release:
apei_resources_release(&einj_resources);
err_fini:
@@ -933,6 +952,7 @@ static void __exit einj_remove(struct platform_device *pdev)
if (vendor_errors.size)
acpi_os_unmap_memory(vendor_errors.data, vendor_errors.size);
}
+ kfree(user_input);
einj_exec_ctx_init(&ctx);
apei_exec_post_unmap_gars(&ctx);
apei_resources_release(&einj_resources);
--
2.46.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v4 8/9] ACPI: APEI: EINJ: Enable EINJv2 error injections
2025-03-06 23:48 [PATCH v4 0/9] Enable EINJv2 Support Zaid Alali
` (6 preceding siblings ...)
2025-03-06 23:48 ` [PATCH v4 7/9] ACPI: APEI: EINJ: Add debugfs files for EINJv2 support Zaid Alali
@ 2025-03-06 23:48 ` Zaid Alali
2025-03-13 9:56 ` Jonathan Cameron
2025-03-06 23:48 ` [PATCH v4 9/9] ACPI: APEI: EINJ: Update the documentation for EINJv2 support Zaid Alali
8 siblings, 1 reply; 20+ messages in thread
From: Zaid Alali @ 2025-03-06 23:48 UTC (permalink / raw)
To: rafael, lenb, james.morse, tony.luck, bp, robert.moore,
dan.j.williams, zaidal, Jonathan.Cameron, Benjamin.Cheatham,
Avadhut.Naik, viro, arnd, ira.weiny, dave.jiang,
sthanneeru.opensrc, linux-acpi, linux-kernel, acpica-devel
Enable the driver to inject EINJv2 type errors. The component
array values are parsed from user_input and expected to contain
hex values for component id and syndrome separated by space,
and multiple components are separated by new line as follows:
component_id1 component_syndrome1
component_id2 component_syndrome2
:
component_id(n) component_syndrome(n)
for example:
$comp_arr="0x1 0x2
>0x1 0x4
>0x2 0x4"
$cd /sys/kernel/debug/apei/einj/
$echo "$comp_arr" > einjv2_component_array
Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com>
---
drivers/acpi/apei/einj-core.c | 101 ++++++++++++++++++++++++++++++----
1 file changed, 90 insertions(+), 11 deletions(-)
diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
index 4c748fa0a479..1aea84958b00 100644
--- a/drivers/acpi/apei/einj-core.c
+++ b/drivers/acpi/apei/einj-core.c
@@ -87,6 +87,13 @@ enum {
SETWA_FLAGS_APICID = 1,
SETWA_FLAGS_MEM = 2,
SETWA_FLAGS_PCIE_SBDF = 4,
+ SETWA_FLAGS_EINJV2 = 8,
+};
+
+enum {
+ EINJV2_PROCESSOR_ERROR = 0x1,
+ EINJV2_MEMORY_ERROR = 0x2,
+ EINJV2_PCIE_ERROR = 0x4,
};
/*
@@ -111,6 +118,7 @@ static char vendor_dev[64];
static struct debugfs_blob_wrapper einjv2_component_arr;
static u64 component_count;
static void *user_input;
+static int nr_components;
static u32 available_error_type;
static u32 available_error_type_v2;
@@ -181,6 +189,8 @@ static DEFINE_MUTEX(einj_mutex);
bool einj_initialized __ro_after_init;
static void __iomem *einj_param;
+static u32 v5param_size;
+static bool is_V2;
static void einj_exec_ctx_init(struct apei_exec_context *ctx)
{
@@ -288,11 +298,24 @@ static void *einj_get_parameter_address(void)
struct set_error_type_with_address v5param;
void __iomem *p;
+ v5param_size = sizeof(v5param);
p = acpi_os_map_iomem(pa_v5, sizeof(v5param));
if (p) {
- memcpy_fromio(&v5param, p, sizeof(v5param));
+ int offset, len;
+
+ memcpy_fromio(&v5param, p, v5param_size);
acpi5 = 1;
check_vendor_extension(pa_v5, &v5param);
+ if (available_error_type & ACPI65_EINJV2_SUPP) {
+ len = v5param.einjv2_struct.length;
+ offset = offsetof(struct einjv2_extension_struct, component_arr);
+ nr_components = (len - offset) / 32;
+ acpi_os_unmap_iomem(p, v5param_size);
+ offset = offsetof(struct set_error_type_with_address, einjv2_struct);
+ v5param_size = offset + struct_size(&v5param.einjv2_struct,
+ component_arr, nr_components);
+ p = acpi_os_map_iomem(pa_v5, v5param_size);
+ }
return p;
}
}
@@ -484,10 +507,10 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
return rc;
apei_exec_ctx_set_input(&ctx, type);
if (acpi5) {
- struct set_error_type_with_address *v5param, v5_struct;
+ struct set_error_type_with_address *v5param;
- v5param = &v5_struct;
- memcpy_fromio(v5param, einj_param, sizeof(*v5param));
+ v5param = kmalloc(v5param_size, GFP_KERNEL);
+ memcpy_fromio(v5param, einj_param, v5param_size);
v5param->type = type;
if (type & ACPI5_VENDOR_BIT) {
switch (vendor_flags) {
@@ -507,8 +530,49 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
v5param->flags = flags;
v5param->memory_address = param1;
v5param->memory_address_range = param2;
- v5param->apicid = param3;
- v5param->pcie_sbdf = param4;
+
+ if (is_V2) {
+ int count = 0, bytes_read, pos = 0;
+ unsigned int comp, synd;
+ struct syndrome_array *component_arr;
+
+ if (component_count > nr_components)
+ goto err_out;
+
+ v5param->einjv2_struct.component_arr_count = component_count;
+ component_arr = v5param->einjv2_struct.component_arr;
+
+ while (sscanf(user_input + pos, "%x %x\n%n", &comp, &synd,
+ &bytes_read) == 2) {
+ pos += bytes_read;
+ if (count > component_count)
+ goto err_out;
+
+ switch (type) {
+ case EINJV2_PROCESSOR_ERROR:
+ component_arr[count].comp_id.acpi_id = comp;
+ component_arr[count].comp_synd.proc_synd = synd;
+ break;
+ case EINJV2_MEMORY_ERROR:
+ component_arr[count].comp_id.device_id = comp;
+ component_arr[count].comp_synd.mem_synd = synd;
+ break;
+ case EINJV2_PCIE_ERROR:
+ component_arr[count].comp_id.pcie_sbdf = comp;
+ component_arr[count].comp_synd.pcie_synd = synd;
+ break;
+ }
+ count++;
+ }
+ if (count != component_count)
+ goto err_out;
+
+ /* clear buffer after user input for next injection */
+ memset(user_input, 0, COMP_ARR_SIZE);
+ } else {
+ v5param->apicid = param3;
+ v5param->pcie_sbdf = param4;
+ }
} else {
switch (type) {
case ACPI_EINJ_PROCESSOR_CORRECTABLE:
@@ -532,7 +596,8 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
break;
}
}
- memcpy_toio(einj_param, v5param, sizeof(*v5param));
+ memcpy_toio(einj_param, v5param, v5param_size);
+ kfree(v5param);
} else {
rc = apei_exec_run(&ctx, ACPI_EINJ_SET_ERROR_TYPE);
if (rc)
@@ -584,6 +649,9 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
rc = apei_exec_run_optional(&ctx, ACPI_EINJ_END_OPERATION);
return rc;
+err_out:
+ memset(user_input, 0, COMP_ARR_SIZE);
+ return -EINVAL;
}
/* Inject the specified hardware error */
@@ -594,10 +662,15 @@ int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, u64 param3,
u64 base_addr, size;
/* If user manually set "flags", make sure it is legal */
- if (flags && (flags &
- ~(SETWA_FLAGS_APICID|SETWA_FLAGS_MEM|SETWA_FLAGS_PCIE_SBDF)))
+ if (flags && (flags & ~(SETWA_FLAGS_APICID | SETWA_FLAGS_MEM |
+ SETWA_FLAGS_PCIE_SBDF | SETWA_FLAGS_EINJV2)))
return -EINVAL;
+ /* check if type is a valid EINJv2 error type */
+ if (is_V2) {
+ if (!(type & available_error_type_v2))
+ return -EINVAL;
+ }
/*
* We need extra sanity checks for memory errors.
* Other types leap directly to injection.
@@ -747,7 +820,7 @@ int einj_validate_error_type(u64 type)
if (tval & (tval - 1))
return -EINVAL;
if (!vendor)
- if (!(type & available_error_type))
+ if (!(type & (available_error_type | available_error_type_v2)))
return -EINVAL;
return 0;
@@ -766,9 +839,11 @@ static ssize_t error_type_set(struct file *file, const char __user *buf,
if (strncmp(einj_buf, "V2_", 3) == 0) {
if (!sscanf(einj_buf, "V2_%llx", &val))
return -EINVAL;
+ is_V2 = true;
} else {
if (!sscanf(einj_buf, "%llx", &val))
return -EINVAL;
+ is_V2 = false;
}
rc = einj_validate_error_type(val);
@@ -790,6 +865,9 @@ static int error_inject_set(void *data, u64 val)
if (!error_type)
return -EINVAL;
+ if (is_V2)
+ error_flags |= SETWA_FLAGS_EINJV2;
+
return einj_error_inject(error_type, error_flags, error_param1, error_param2,
error_param3, error_param4);
}
@@ -945,10 +1023,11 @@ static void __exit einj_remove(struct platform_device *pdev)
if (einj_param) {
acpi_size size = (acpi5) ?
- sizeof(struct set_error_type_with_address) :
+ v5param_size :
sizeof(struct einj_parameter);
acpi_os_unmap_iomem(einj_param, size);
+
if (vendor_errors.size)
acpi_os_unmap_memory(vendor_errors.data, vendor_errors.size);
}
--
2.46.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v4 9/9] ACPI: APEI: EINJ: Update the documentation for EINJv2 support
2025-03-06 23:48 [PATCH v4 0/9] Enable EINJv2 Support Zaid Alali
` (7 preceding siblings ...)
2025-03-06 23:48 ` [PATCH v4 8/9] ACPI: APEI: EINJ: Enable EINJv2 error injections Zaid Alali
@ 2025-03-06 23:48 ` Zaid Alali
2025-03-13 9:59 ` Jonathan Cameron
8 siblings, 1 reply; 20+ messages in thread
From: Zaid Alali @ 2025-03-06 23:48 UTC (permalink / raw)
To: rafael, lenb, james.morse, tony.luck, bp, robert.moore,
dan.j.williams, zaidal, Jonathan.Cameron, Benjamin.Cheatham,
Avadhut.Naik, viro, arnd, ira.weiny, dave.jiang,
sthanneeru.opensrc, linux-acpi, linux-kernel, acpica-devel
Add documentation for the updated ACPI specs for EINJv2(1)(2)
(1)https://bugzilla.tianocore.org/show_bug.cgi?id=4615
(2)https://bugzilla.tianocore.org/attachment.cgi?id=1446
Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com>
---
.../firmware-guide/acpi/apei/einj.rst | 41 ++++++++++++++++++-
1 file changed, 39 insertions(+), 2 deletions(-)
diff --git a/Documentation/firmware-guide/acpi/apei/einj.rst b/Documentation/firmware-guide/acpi/apei/einj.rst
index c52b9da08fa9..31c848183af0 100644
--- a/Documentation/firmware-guide/acpi/apei/einj.rst
+++ b/Documentation/firmware-guide/acpi/apei/einj.rst
@@ -59,6 +59,9 @@ The following files belong to it:
0x00000200 Platform Correctable
0x00000400 Platform Uncorrectable non-fatal
0x00000800 Platform Uncorrectable fatal
+ V2_0x00000001 EINJV2 Processor Error
+ V2_0x00000002 EINJV2 Memory Error
+ V2_0x00000004 EINJV2 PCI Express Error
================ ===================================
The format of the file contents are as above, except present are only
@@ -85,9 +88,11 @@ The following files belong to it:
Bit 0
Processor APIC field valid (see param3 below).
Bit 1
- Memory address and mask valid (param1 and param2).
+ Memory address and range valid (param1 and param2).
Bit 2
PCIe (seg,bus,dev,fn) valid (see param4 below).
+ Bit 3
+ EINJv2 extension structure is valid
If set to zero, legacy behavior is mimicked where the type of
injection specifies just one bit set, and param1 is multiplexed.
@@ -110,6 +115,7 @@ The following files belong to it:
Used when the 0x1 bit is set in "flags" to specify the APIC id
- param4
+
Used when the 0x4 bit is set in "flags" to specify target PCIe device
- notrigger
@@ -122,6 +128,18 @@ The following files belong to it:
this actually works depends on what operations the BIOS actually
includes in the trigger phase.
+- einjv2_component_count
+
+ The value from this file is used to set the "Component Array Count"
+ field of EINJv2 Extension Structure.
+
+- einjv2_component_array
+
+ The contents of this file are used to set the "Component Array" field
+ of the EINJv2 Extension Structure. The expected format is hex values
+ for component id and syndrome separated by space, and multiple
+ components are separated by new line.
+
CXL error types are supported from ACPI 6.5 onwards (given a CXL port
is present). The EINJ user interface for CXL error types is at
<debugfs mount point>/cxl. The following files belong to it:
@@ -139,7 +157,6 @@ is present). The EINJ user interface for CXL error types is at
under <debugfs mount point>/apei/einj, while CXL 1.1/1.0 port injections
must use this file.
-
BIOS versions based on the ACPI 4.0 specification have limited options
in controlling where the errors are injected. Your BIOS may support an
extension (enabled with the param_extension=1 module parameter, or boot
@@ -194,6 +211,26 @@ An error injection example::
# echo 0x8 > error_type # Choose correctable memory error
# echo 1 > error_inject # Inject now
+An EINJv2 error injection example::
+
+ # cd /sys/kernel/debug/apei/einj
+ # cat available_error_type # See which errors can be injected
+ 0x00000002 Processor Uncorrectable non-fatal
+ 0x00000008 Memory Correctable
+ 0x00000010 Memory Uncorrectable non-fatal
+ 0x00000001 EINJV2 Processor Error
+ 0x00000002 EINJV2 Memory Error
+
+ # echo 0x12345000 > param1 # Set memory address for injection
+ # echo 0xfffffffffffff000 > param2 # Range - anywhere in this page
+ # comp_arr="0x1 0x2 # Fill in the component array
+ >0x1 0x4
+ >0x2 0x4"
+ # echo "$comp_arr" > einjv2_component_array
+ # echo V2_0x2 > error_type # Choose EINJv2 memory error
+ # echo 0xa > flags # set flags to indicate EINJv2
+ # echo 1 > error_inject # Inject now
+
You should see something like this in dmesg::
[22715.830801] EDAC sbridge MC3: HANDLING MCE MEMORY ERROR
--
2.46.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH v4 3/9] ACPI: APEI: EINJ: Fix kernel test robot sparse warning
2025-03-06 23:48 ` [PATCH v4 3/9] ACPI: APEI: EINJ: Fix kernel test robot sparse warning Zaid Alali
@ 2025-03-08 8:55 ` kernel test robot
2025-03-13 9:37 ` Jonathan Cameron
2025-03-13 9:50 ` Jonathan Cameron
2 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2025-03-08 8:55 UTC (permalink / raw)
To: Zaid Alali, rafael, lenb, james.morse, tony.luck, bp,
robert.moore, dan.j.williams, Jonathan.Cameron, Benjamin.Cheatham,
Avadhut.Naik, viro, arnd, ira.weiny, dave.jiang,
sthanneeru.opensrc, linux-acpi, linux-kernel, acpica-devel
Cc: oe-kbuild-all
Hi Zaid,
kernel test robot noticed the following build warnings:
[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on rafael-pm/bleeding-edge linus/master v6.14-rc5 next-20250307]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Zaid-Alali/ACPICA-Update-values-to-hex-to-follow-ACPI-specs/20250307-075155
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link: https://lore.kernel.org/r/20250306234810.75511-4-zaidal%40os.amperecomputing.com
patch subject: [PATCH v4 3/9] ACPI: APEI: EINJ: Fix kernel test robot sparse warning
config: i386-randconfig-063-20250308 (https://download.01.org/0day-ci/archive/20250308/202503081600.JxR875hh-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250308/202503081600.JxR875hh-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503081600.JxR875hh-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
>> drivers/acpi/apei/einj-core.c:265:32: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected void * @@ got void [noderef] __iomem *[assigned] p @@
drivers/acpi/apei/einj-core.c:265:32: sparse: expected void *
drivers/acpi/apei/einj-core.c:265:32: sparse: got void [noderef] __iomem *[assigned] p
drivers/acpi/apei/einj-core.c:280:24: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected void * @@ got void [noderef] __iomem *[assigned] p @@
drivers/acpi/apei/einj-core.c:280:24: sparse: expected void *
drivers/acpi/apei/einj-core.c:280:24: sparse: got void [noderef] __iomem *[assigned] p
>> drivers/acpi/apei/einj-core.c:824:20: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void [noderef] __iomem *static [toplevel] einj_param @@ got void * @@
drivers/acpi/apei/einj-core.c:824:20: sparse: expected void [noderef] __iomem *static [toplevel] einj_param
drivers/acpi/apei/einj-core.c:824:20: sparse: got void *
vim +265 drivers/acpi/apei/einj-core.c
235
236 static void *einj_get_parameter_address(void)
237 {
238 int i;
239 u64 pa_v4 = 0, pa_v5 = 0;
240 struct acpi_whea_header *entry;
241
242 entry = EINJ_TAB_ENTRY(einj_tab);
243 for (i = 0; i < einj_tab->entries; i++) {
244 if (entry->action == ACPI_EINJ_SET_ERROR_TYPE &&
245 entry->instruction == ACPI_EINJ_WRITE_REGISTER &&
246 entry->register_region.space_id ==
247 ACPI_ADR_SPACE_SYSTEM_MEMORY)
248 pa_v4 = get_unaligned(&entry->register_region.address);
249 if (entry->action == ACPI_EINJ_SET_ERROR_TYPE_WITH_ADDRESS &&
250 entry->instruction == ACPI_EINJ_WRITE_REGISTER &&
251 entry->register_region.space_id ==
252 ACPI_ADR_SPACE_SYSTEM_MEMORY)
253 pa_v5 = get_unaligned(&entry->register_region.address);
254 entry++;
255 }
256 if (pa_v5) {
257 struct set_error_type_with_address v5param;
258 void __iomem *p;
259
260 p = acpi_os_map_iomem(pa_v5, sizeof(v5param));
261 if (p) {
262 memcpy_fromio(&v5param, p, sizeof(v5param));
263 acpi5 = 1;
264 check_vendor_extension(pa_v5, &v5param);
> 265 return p;
266 }
267 }
268 if (param_extension && pa_v4) {
269 struct einj_parameter v4param;
270 void __iomem *p;
271
272 p = acpi_os_map_iomem(pa_v4, sizeof(v4param));
273 if (!p)
274 return NULL;
275 memcpy_fromio(&v4param, p, sizeof(v4param));
276 if (v4param.reserved1 || v4param.reserved2) {
277 acpi_os_unmap_iomem(p, sizeof(v4param));
278 return NULL;
279 }
280 return p;
281 }
282
283 return NULL;
284 }
285
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v4 3/9] ACPI: APEI: EINJ: Fix kernel test robot sparse warning
2025-03-06 23:48 ` [PATCH v4 3/9] ACPI: APEI: EINJ: Fix kernel test robot sparse warning Zaid Alali
2025-03-08 8:55 ` kernel test robot
@ 2025-03-13 9:37 ` Jonathan Cameron
2025-03-13 9:50 ` Jonathan Cameron
2 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2025-03-13 9:37 UTC (permalink / raw)
To: Zaid Alali
Cc: rafael, lenb, james.morse, tony.luck, bp, robert.moore,
dan.j.williams, Benjamin.Cheatham, Avadhut.Naik, viro, arnd,
ira.weiny, dave.jiang, sthanneeru.opensrc, linux-acpi,
linux-kernel, acpica-devel
On Thu, 6 Mar 2025 15:48:04 -0800
Zaid Alali <zaidal@os.amperecomputing.com> wrote:
> This patch fixes the kernel test robot warning reported here:
> https://lore.kernel.org/all/202410241620.oApALow5-lkp@intel.com/
>
> Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com>
Hi Zaid,
I'm not so keen on loosing the type of the pointer as that leads
to slightly odd situation of using the size of where we care copying it
to later for the dma mapping. Kind of fine, but weird looking!
Also, if you keep original naming and introduce a new v_copy or similar
then you can end up with a shorter and probably easier to review patch.
(slightly)
Jonathan
> ---
> drivers/acpi/apei/einj-core.c | 104 +++++++++++++++++++---------------
> 1 file changed, 59 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
> index 04731a5b01fa..b40ed44c4983 100644
> --- a/drivers/acpi/apei/einj-core.c
> +++ b/drivers/acpi/apei/einj-core.c
> @@ -149,7 +149,7 @@ static DEFINE_MUTEX(einj_mutex);
> */
> bool einj_initialized __ro_after_init;
>
> -static void *einj_param;
> +static void __iomem *einj_param;
>
> static void einj_exec_ctx_init(struct apei_exec_context *ctx)
> {
> @@ -214,21 +214,23 @@ static void check_vendor_extension(u64 paddr,
> struct set_error_type_with_address *v5param)
> {
> int offset = v5param->vendor_extension;
> - struct vendor_error_type_extension *v;
> + struct vendor_error_type_extension v;
> + void __iomem *p;
I'd keep it typed.
struct __iomem vendor_error_extension *p;
> u32 sbdf;
>
> if (!offset)
> return;
> - v = acpi_os_map_iomem(paddr + offset, sizeof(*v));
> - if (!v)
> + p = acpi_os_map_iomem(paddr + offset, sizeof(v));
then this can be sizeof(*p)
Or reduce the diff and rename the copy + add __iomem
marking to the original *v definition.
Call the copy v_copy or something like that.
> + if (!p)
> return;
> - get_oem_vendor_struct(paddr, offset, v);
> - sbdf = v->pcie_sbdf;
> + memcpy_fromio(&v, p, sizeof(v));
> + get_oem_vendor_struct(paddr, offset, &v);
> + sbdf = v.pcie_sbdf;
> sprintf(vendor_dev, "%x:%x:%x.%x vendor_id=%x device_id=%x rev_id=%x\n",
> sbdf >> 24, (sbdf >> 16) & 0xff,
> (sbdf >> 11) & 0x1f, (sbdf >> 8) & 0x7,
> - v->vendor_id, v->device_id, v->rev_id);
> - acpi_os_unmap_iomem(v, sizeof(*v));
> + v.vendor_id, v.device_id, v.rev_id);
> + acpi_os_unmap_iomem(p, sizeof(v));
> }
>
> static void *einj_get_parameter_address(void)
> @@ -252,26 +254,30 @@ static void *einj_get_parameter_address(void)
> entry++;
> }
> if (pa_v5) {
> - struct set_error_type_with_address *v5param;
> + struct set_error_type_with_address v5param;
> + void __iomem *p;
Similar to above in remaining cases.
Jonathan
>
> - v5param = acpi_os_map_iomem(pa_v5, sizeof(*v5param));
> - if (v5param) {
> + p = acpi_os_map_iomem(pa_v5, sizeof(v5param));
> + if (p) {
> + memcpy_fromio(&v5param, p, sizeof(v5param));
> acpi5 = 1;
> - check_vendor_extension(pa_v5, v5param);
> - return v5param;
> + check_vendor_extension(pa_v5, &v5param);
> + return p;
> }
> }
> if (param_extension && pa_v4) {
> - struct einj_parameter *v4param;
> + struct einj_parameter v4param;
> + void __iomem *p;
>
> - v4param = acpi_os_map_iomem(pa_v4, sizeof(*v4param));
> - if (!v4param)
> + p = acpi_os_map_iomem(pa_v4, sizeof(v4param));
> + if (!p)
> return NULL;
> - if (v4param->reserved1 || v4param->reserved2) {
> - acpi_os_unmap_iomem(v4param, sizeof(*v4param));
> + memcpy_fromio(&v4param, p, sizeof(v4param));
> + if (v4param.reserved1 || v4param.reserved2) {
> + acpi_os_unmap_iomem(p, sizeof(v4param));
> return NULL;
> }
> - return v4param;
> + return p;
> }
>
> return NULL;
> @@ -317,7 +323,7 @@ static struct acpi_generic_address *einj_get_trigger_parameter_region(
> static int __einj_error_trigger(u64 trigger_paddr, u32 type,
> u64 param1, u64 param2)
> {
> - struct acpi_einj_trigger *trigger_tab = NULL;
> + struct acpi_einj_trigger trigger_tab;
> struct apei_exec_context trigger_ctx;
> struct apei_resources trigger_resources;
> struct acpi_whea_header *trigger_entry;
> @@ -325,54 +331,57 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
> u32 table_size;
> int rc = -EIO;
> struct acpi_generic_address *trigger_param_region = NULL;
> + void __iomem *p;
>
> - r = request_mem_region(trigger_paddr, sizeof(*trigger_tab),
> + r = request_mem_region(trigger_paddr, sizeof(trigger_tab),
> "APEI EINJ Trigger Table");
> if (!r) {
> pr_err("Can not request [mem %#010llx-%#010llx] for Trigger table\n",
> (unsigned long long)trigger_paddr,
> (unsigned long long)trigger_paddr +
> - sizeof(*trigger_tab) - 1);
> + sizeof(trigger_tab) - 1);
> goto out;
> }
> - trigger_tab = ioremap_cache(trigger_paddr, sizeof(*trigger_tab));
> - if (!trigger_tab) {
> + p = ioremap_cache(trigger_paddr, sizeof(trigger_tab));
> + if (!p) {
> pr_err("Failed to map trigger table!\n");
> goto out_rel_header;
> }
> - rc = einj_check_trigger_header(trigger_tab);
> + memcpy_fromio(&trigger_tab, p, sizeof(trigger_tab));
> + rc = einj_check_trigger_header(&trigger_tab);
> if (rc) {
> pr_warn(FW_BUG "Invalid trigger error action table.\n");
> goto out_rel_header;
> }
>
> /* No action structures in the TRIGGER_ERROR table, nothing to do */
> - if (!trigger_tab->entry_count)
> + if (!trigger_tab.entry_count)
> goto out_rel_header;
>
> rc = -EIO;
> - table_size = trigger_tab->table_size;
> - r = request_mem_region(trigger_paddr + sizeof(*trigger_tab),
> - table_size - sizeof(*trigger_tab),
> + table_size = trigger_tab.table_size;
> + r = request_mem_region(trigger_paddr + sizeof(trigger_tab),
> + table_size - sizeof(trigger_tab),
> "APEI EINJ Trigger Table");
> if (!r) {
> pr_err("Can not request [mem %#010llx-%#010llx] for Trigger Table Entry\n",
> - (unsigned long long)trigger_paddr + sizeof(*trigger_tab),
> + (unsigned long long)trigger_paddr + sizeof(trigger_tab),
> (unsigned long long)trigger_paddr + table_size - 1);
> goto out_rel_header;
> }
> - iounmap(trigger_tab);
> - trigger_tab = ioremap_cache(trigger_paddr, table_size);
> - if (!trigger_tab) {
> + iounmap(p);
> + p = ioremap_cache(trigger_paddr, table_size);
> + if (!p) {
> pr_err("Failed to map trigger table!\n");
> goto out_rel_entry;
> }
> + memcpy_fromio(&trigger_tab, p, sizeof(trigger_tab));
> trigger_entry = (struct acpi_whea_header *)
> - ((char *)trigger_tab + sizeof(struct acpi_einj_trigger));
> + ((char *)&trigger_tab + sizeof(struct acpi_einj_trigger));
> apei_resources_init(&trigger_resources);
> apei_exec_ctx_init(&trigger_ctx, einj_ins_type,
> ARRAY_SIZE(einj_ins_type),
> - trigger_entry, trigger_tab->entry_count);
> + trigger_entry, trigger_tab.entry_count);
> rc = apei_exec_collect_resources(&trigger_ctx, &trigger_resources);
> if (rc)
> goto out_fini;
> @@ -390,7 +399,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
>
> apei_resources_init(&addr_resources);
> trigger_param_region = einj_get_trigger_parameter_region(
> - trigger_tab, param1, param2);
> + &trigger_tab, param1, param2);
> if (trigger_param_region) {
> rc = apei_resources_add(&addr_resources,
> trigger_param_region->address,
> @@ -419,13 +428,13 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
> out_fini:
> apei_resources_fini(&trigger_resources);
> out_rel_entry:
> - release_mem_region(trigger_paddr + sizeof(*trigger_tab),
> - table_size - sizeof(*trigger_tab));
> + release_mem_region(trigger_paddr + sizeof(trigger_tab),
> + table_size - sizeof(trigger_tab));
> out_rel_header:
> - release_mem_region(trigger_paddr, sizeof(*trigger_tab));
> + release_mem_region(trigger_paddr, sizeof(trigger_tab));
> out:
> - if (trigger_tab)
> - iounmap(trigger_tab);
> + if (p)
> + iounmap(p);
>
> return rc;
> }
> @@ -444,8 +453,10 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
> return rc;
> apei_exec_ctx_set_input(&ctx, type);
> if (acpi5) {
> - struct set_error_type_with_address *v5param = einj_param;
> + struct set_error_type_with_address *v5param, v5_struct;
>
> + v5param = &v5_struct;
> + memcpy_fromio(v5param, einj_param, sizeof(*v5param));
> v5param->type = type;
> if (type & ACPI5_VENDOR_BIT) {
> switch (vendor_flags) {
> @@ -490,15 +501,18 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
> break;
> }
> }
> + memcpy_toio(einj_param, v5param, sizeof(*v5param));
> } else {
> rc = apei_exec_run(&ctx, ACPI_EINJ_SET_ERROR_TYPE);
> if (rc)
> return rc;
> if (einj_param) {
> - struct einj_parameter *v4param = einj_param;
> + struct einj_parameter v4param;
>
> - v4param->param1 = param1;
> - v4param->param2 = param2;
> + memcpy_fromio(&v4param, einj_param, sizeof(v4param));
> + v4param.param1 = param1;
> + v4param.param2 = param2;
> + memcpy_toio(einj_param, &v4param, sizeof(v4param));
> }
> }
> rc = apei_exec_run(&ctx, ACPI_EINJ_EXECUTE_OPERATION);
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v4 5/9] ACPI: APEI: EINJ: Enable the discovery of EINJv2 capabilities
2025-03-06 23:48 ` [PATCH v4 5/9] ACPI: APEI: EINJ: Enable the discovery of EINJv2 capabilities Zaid Alali
@ 2025-03-13 9:39 ` Jonathan Cameron
0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2025-03-13 9:39 UTC (permalink / raw)
To: Zaid Alali
Cc: rafael, lenb, james.morse, tony.luck, bp, robert.moore,
dan.j.williams, Benjamin.Cheatham, Avadhut.Naik, viro, arnd,
ira.weiny, dave.jiang, sthanneeru.opensrc, linux-acpi,
linux-kernel, acpica-devel
On Thu, 6 Mar 2025 15:48:06 -0800
Zaid Alali <zaidal@os.amperecomputing.com> wrote:
> Enable the driver to show all supported error injections for EINJ
> and EINJv2 at the same time. EINJv2 capabilities can be discovered
> by checking the return value of get_error_type, where bit 30 set
> indicates EINJv2 support.
>
> Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com>
Trivial comment for another day inline.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
> drivers/acpi/apei/apei-internal.h | 2 +-
> drivers/acpi/apei/einj-core.c | 64 ++++++++++++++++++++++++-------
> drivers/acpi/apei/einj-cxl.c | 2 +-
> 3 files changed, 52 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
> index cd2766c69d78..77c10a7a7a9f 100644
> --- a/drivers/acpi/apei/apei-internal.h
> +++ b/drivers/acpi/apei/apei-internal.h
> @@ -131,7 +131,7 @@ static inline u32 cper_estatus_len(struct acpi_hest_generic_status *estatus)
>
> int apei_osc_setup(void);
>
> -int einj_get_available_error_type(u32 *type);
> +int einj_get_available_error_type(u32 *type, int einj_action);
> int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, u64 param3,
> u64 param4);
> int einj_cxl_rch_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
> diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
> index 3f828f9265a8..aee9a7b17313 100644
> --- a/drivers/acpi/apei/einj-core.c
> +++ b/drivers/acpi/apei/einj-core.c
> @@ -33,6 +33,7 @@
> #define SLEEP_UNIT_MAX 5000 /* 5ms */
> /* Firmware should respond within 1 seconds */
> #define FIRMWARE_TIMEOUT (1 * USEC_PER_SEC)
> +#define ACPI65_EINJV2_SUPP BIT(30)
> #define ACPI5_VENDOR_BIT BIT(31)
> #define MEM_ERROR_MASK (ACPI_EINJ_MEMORY_CORRECTABLE | \
> ACPI_EINJ_MEMORY_UNCORRECTABLE | \
> @@ -84,6 +85,7 @@ static struct debugfs_blob_wrapper vendor_errors;
> static char vendor_dev[64];
>
> static u32 available_error_type;
> +static u32 available_error_type_v2;
>
> /*
> * Some BIOSes allow parameters to the SET_ERROR_TYPE entries in the
> @@ -159,13 +161,13 @@ static void einj_exec_ctx_init(struct apei_exec_context *ctx)
> EINJ_TAB_ENTRY(einj_tab), einj_tab->entries);
> }
>
> -static int __einj_get_available_error_type(u32 *type)
> +static int __einj_get_available_error_type(u32 *type, int einj_action)
> {
> struct apei_exec_context ctx;
> int rc;
>
> einj_exec_ctx_init(&ctx);
> - rc = apei_exec_run(&ctx, ACPI_EINJ_GET_ERROR_TYPE);
> + rc = apei_exec_run(&ctx, einj_action);
> if (rc)
> return rc;
> *type = apei_exec_ctx_get_output(&ctx);
> @@ -174,12 +176,12 @@ static int __einj_get_available_error_type(u32 *type)
> }
>
> /* Get error injection capabilities of the platform */
> -int einj_get_available_error_type(u32 *type)
> +int einj_get_available_error_type(u32 *type, int einj_action)
> {
> int rc;
>
> mutex_lock(&einj_mutex);
Might be worth looking at using guard(mutex) in here to simplify paths.
But that's a job for another day!
> - rc = __einj_get_available_error_type(type);
> + rc = __einj_get_available_error_type(type, einj_action);
> mutex_unlock(&einj_mutex);
>
> return rc;
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v4 6/9] ACPI: APEI: EINJ: Add einjv2 extension struct
2025-03-06 23:48 ` [PATCH v4 6/9] ACPI: APEI: EINJ: Add einjv2 extension struct Zaid Alali
@ 2025-03-13 9:42 ` Jonathan Cameron
2025-03-13 20:06 ` Zaid Alali
0 siblings, 1 reply; 20+ messages in thread
From: Jonathan Cameron @ 2025-03-13 9:42 UTC (permalink / raw)
To: Zaid Alali
Cc: rafael, lenb, james.morse, tony.luck, bp, robert.moore,
dan.j.williams, Benjamin.Cheatham, Avadhut.Naik, viro, arnd,
ira.weiny, dave.jiang, sthanneeru.opensrc, linux-acpi,
linux-kernel, acpica-devel
On Thu, 6 Mar 2025 15:48:07 -0800
Zaid Alali <zaidal@os.amperecomputing.com> wrote:
> Add einjv2 extension struct and EINJv2 error types to prepare
> the driver for EINJv2 support. ACPI specifications(1) enables
> EINJv2 by extending set_error_type_with_address struct.
>
> (1) https://bugzilla.tianocore.org/show_bug.cgi?id=4615
Still seems to be down.
Also, we have tag for this.
>
> Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com>
Link: https://bugzilla.tianocore.org/show_bug.cgi?id=4615 # [1]
One additional request inline.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
> drivers/acpi/apei/einj-core.c | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
> diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
> index aee9a7b17313..32b8d102f399 100644
> --- a/drivers/acpi/apei/einj-core.c
> +++ b/drivers/acpi/apei/einj-core.c
> @@ -50,6 +50,28 @@
> */
> static int acpi5;
>
> +struct syndrome_array {
> + union {
> + u32 acpi_id;
> + u32 device_id;
> + u32 pcie_sbdf;
> + u8 vendor_id[16];
> + } comp_id;
> + union {
> + u32 proc_synd;
> + u32 mem_synd;
> + u32 pcie_synd;
> + u8 vendor_synd[16];
> + } comp_synd;
> +};
> +
> +struct einjv2_extension_struct {
> + u32 length;
> + u16 revision;
> + u16 component_arr_count;
> + struct syndrome_array component_arr[];
__counted_by(component_arr_count);
should be fine and marking these is always good to do in
new code (and old code if you have time!)
> +};
> +
> struct set_error_type_with_address {
> u32 type;
> u32 vendor_extension;
> @@ -58,6 +80,7 @@ struct set_error_type_with_address {
> u64 memory_address;
> u64 memory_address_range;
> u32 pcie_sbdf;
> + struct einjv2_extension_struct einjv2_struct;
> };
> enum {
> SETWA_FLAGS_APICID = 1,
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v4 7/9] ACPI: APEI: EINJ: Add debugfs files for EINJv2 support
2025-03-06 23:48 ` [PATCH v4 7/9] ACPI: APEI: EINJ: Add debugfs files for EINJv2 support Zaid Alali
@ 2025-03-13 9:46 ` Jonathan Cameron
0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2025-03-13 9:46 UTC (permalink / raw)
To: Zaid Alali
Cc: rafael, lenb, james.morse, tony.luck, bp, robert.moore,
dan.j.williams, Benjamin.Cheatham, Avadhut.Naik, viro, arnd,
ira.weiny, dave.jiang, sthanneeru.opensrc, linux-acpi,
linux-kernel, acpica-devel
On Thu, 6 Mar 2025 15:48:08 -0800
Zaid Alali <zaidal@os.amperecomputing.com> wrote:
> Create a debugfs blob file to be used for reading the user
> input for the component array. EINJv2 enables users to inject
> errors to multiple components/devices at the same time using
> component array.
>
> Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com>
LGTM
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v4 3/9] ACPI: APEI: EINJ: Fix kernel test robot sparse warning
2025-03-06 23:48 ` [PATCH v4 3/9] ACPI: APEI: EINJ: Fix kernel test robot sparse warning Zaid Alali
2025-03-08 8:55 ` kernel test robot
2025-03-13 9:37 ` Jonathan Cameron
@ 2025-03-13 9:50 ` Jonathan Cameron
2 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2025-03-13 9:50 UTC (permalink / raw)
To: Zaid Alali
Cc: rafael, lenb, james.morse, tony.luck, bp, robert.moore,
dan.j.williams, Benjamin.Cheatham, Avadhut.Naik, viro, arnd,
ira.weiny, dave.jiang, sthanneeru.opensrc, linux-acpi,
linux-kernel, acpica-devel
On Thu, 6 Mar 2025 15:48:04 -0800
Zaid Alali <zaidal@os.amperecomputing.com> wrote:
> This patch fixes the kernel test robot warning reported here:
> https://lore.kernel.org/all/202410241620.oApALow5-lkp@intel.com/
>
> Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com>
Follow up below.
> ---
> drivers/acpi/apei/einj-core.c | 104 +++++++++++++++++++---------------
> 1 file changed, 59 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
> index 04731a5b01fa..b40ed44c4983 100644
> --- a/drivers/acpi/apei/einj-core.c
> +++ b/drivers/acpi/apei/einj-core.c
> @@ -149,7 +149,7 @@ static DEFINE_MUTEX(einj_mutex);
> */
> bool einj_initialized __ro_after_init;
>
> -static void *einj_param;
> +static void __iomem *einj_param;
>
> static void einj_exec_ctx_init(struct apei_exec_context *ctx)
> {
> @@ -214,21 +214,23 @@ static void check_vendor_extension(u64 paddr,
> struct set_error_type_with_address *v5param)
> {
> int offset = v5param->vendor_extension;
> - struct vendor_error_type_extension *v;
> + struct vendor_error_type_extension v;
> + void __iomem *p;
> u32 sbdf;
>
> if (!offset)
> return;
> - v = acpi_os_map_iomem(paddr + offset, sizeof(*v));
> - if (!v)
> + p = acpi_os_map_iomem(paddr + offset, sizeof(v));
> + if (!p)
> return;
> - get_oem_vendor_struct(paddr, offset, v);
> - sbdf = v->pcie_sbdf;
> + memcpy_fromio(&v, p, sizeof(v));
> + get_oem_vendor_struct(paddr, offset, &v);
> + sbdf = v.pcie_sbdf;
> sprintf(vendor_dev, "%x:%x:%x.%x vendor_id=%x device_id=%x rev_id=%x\n",
> sbdf >> 24, (sbdf >> 16) & 0xff,
> (sbdf >> 11) & 0x1f, (sbdf >> 8) & 0x7,
> - v->vendor_id, v->device_id, v->rev_id);
> - acpi_os_unmap_iomem(v, sizeof(*v));
> + v.vendor_id, v.device_id, v.rev_id);
> + acpi_os_unmap_iomem(p, sizeof(v));
> }
>
> static void *einj_get_parameter_address(void)
Doesn't this return type want the __iomem marking as well?
> @@ -252,26 +254,30 @@ static void *einj_get_parameter_address(void)
> entry++;
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v4 8/9] ACPI: APEI: EINJ: Enable EINJv2 error injections
2025-03-06 23:48 ` [PATCH v4 8/9] ACPI: APEI: EINJ: Enable EINJv2 error injections Zaid Alali
@ 2025-03-13 9:56 ` Jonathan Cameron
0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2025-03-13 9:56 UTC (permalink / raw)
To: Zaid Alali
Cc: rafael, lenb, james.morse, tony.luck, bp, robert.moore,
dan.j.williams, Benjamin.Cheatham, Avadhut.Naik, viro, arnd,
ira.weiny, dave.jiang, sthanneeru.opensrc, linux-acpi,
linux-kernel, acpica-devel
On Thu, 6 Mar 2025 15:48:09 -0800
Zaid Alali <zaidal@os.amperecomputing.com> wrote:
> Enable the driver to inject EINJv2 type errors. The component
> array values are parsed from user_input and expected to contain
> hex values for component id and syndrome separated by space,
> and multiple components are separated by new line as follows:
>
> component_id1 component_syndrome1
> component_id2 component_syndrome2
> :
> component_id(n) component_syndrome(n)
>
> for example:
>
> $comp_arr="0x1 0x2
> >0x1 0x4
> >0x2 0x4"
> $cd /sys/kernel/debug/apei/einj/
> $echo "$comp_arr" > einjv2_component_array
>
> Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com>
> ---
> drivers/acpi/apei/einj-core.c | 101 ++++++++++++++++++++++++++++++----
> 1 file changed, 90 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
> index 4c748fa0a479..1aea84958b00 100644
> --- a/drivers/acpi/apei/einj-core.c
> +++ b/drivers/acpi/apei/einj-core.c
> static void einj_exec_ctx_init(struct apei_exec_context *ctx)
> {
> @@ -288,11 +298,24 @@ static void *einj_get_parameter_address(void)
> struct set_error_type_with_address v5param;
> void __iomem *p;
>
> + v5param_size = sizeof(v5param);
> p = acpi_os_map_iomem(pa_v5, sizeof(v5param));
> if (p) {
> - memcpy_fromio(&v5param, p, sizeof(v5param));
> + int offset, len;
> +
> + memcpy_fromio(&v5param, p, v5param_size);
> acpi5 = 1;
> check_vendor_extension(pa_v5, &v5param);
> + if (available_error_type & ACPI65_EINJV2_SUPP) {
> + len = v5param.einjv2_struct.length;
> + offset = offsetof(struct einjv2_extension_struct, component_arr);
> + nr_components = (len - offset) / 32;
Can we use sizeof() anything for that 32?
> + acpi_os_unmap_iomem(p, v5param_size);
I wonder if a comment or two would be useful here to explain why we need to expand the mapping.
> + offset = offsetof(struct set_error_type_with_address, einjv2_struct);
> + v5param_size = offset + struct_size(&v5param.einjv2_struct,
> + component_arr, nr_components);
> + p = acpi_os_map_iomem(pa_v5, v5param_size);
> + }
> return p;
> }
> }
...
> @@ -945,10 +1023,11 @@ static void __exit einj_remove(struct platform_device *pdev)
>
> if (einj_param) {
> acpi_size size = (acpi5) ?
> - sizeof(struct set_error_type_with_address) :
> + v5param_size :
> sizeof(struct einj_parameter);
>
> acpi_os_unmap_iomem(einj_param, size);
> +
Unrelated change that shouldn't be in this patch.
> if (vendor_errors.size)
> acpi_os_unmap_memory(vendor_errors.data, vendor_errors.size);
> }
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v4 9/9] ACPI: APEI: EINJ: Update the documentation for EINJv2 support
2025-03-06 23:48 ` [PATCH v4 9/9] ACPI: APEI: EINJ: Update the documentation for EINJv2 support Zaid Alali
@ 2025-03-13 9:59 ` Jonathan Cameron
0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2025-03-13 9:59 UTC (permalink / raw)
To: Zaid Alali
Cc: rafael, lenb, james.morse, tony.luck, bp, robert.moore,
dan.j.williams, Benjamin.Cheatham, Avadhut.Naik, viro, arnd,
ira.weiny, dave.jiang, sthanneeru.opensrc, linux-acpi,
linux-kernel, acpica-devel
On Thu, 6 Mar 2025 15:48:10 -0800
Zaid Alali <zaidal@os.amperecomputing.com> wrote:
> Add documentation for the updated ACPI specs for EINJv2(1)(2)
>
> (1)https://bugzilla.tianocore.org/show_bug.cgi?id=4615
> (2)https://bugzilla.tianocore.org/attachment.cgi?id=1446
>
> Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com>
> ---
> .../firmware-guide/acpi/apei/einj.rst | 41 ++++++++++++++++++-
> 1 file changed, 39 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/firmware-guide/acpi/apei/einj.rst b/Documentation/firmware-guide/acpi/apei/einj.rst
> index c52b9da08fa9..31c848183af0 100644
> --- a/Documentation/firmware-guide/acpi/apei/einj.rst
> +++ b/Documentation/firmware-guide/acpi/apei/einj.rst
> @@ -59,6 +59,9 @@ The following files belong to it:
> 0x00000200 Platform Correctable
> 0x00000400 Platform Uncorrectable non-fatal
> 0x00000800 Platform Uncorrectable fatal
> + V2_0x00000001 EINJV2 Processor Error
> + V2_0x00000002 EINJV2 Memory Error
> + V2_0x00000004 EINJV2 PCI Express Error
> ================ ===================================
>
> The format of the file contents are as above, except present are only
> @@ -85,9 +88,11 @@ The following files belong to it:
> Bit 0
> Processor APIC field valid (see param3 below).
> Bit 1
> - Memory address and mask valid (param1 and param2).
> + Memory address and range valid (param1 and param2).
So was this a bug technically before? If it was maybe separate
patch.
> Bit 2
> PCIe (seg,bus,dev,fn) valid (see param4 below).
> + Bit 3
> + EINJv2 extension structure is valid
>
> If set to zero, legacy behavior is mimicked where the type of
> injection specifies just one bit set, and param1 is multiplexed.
> @@ -110,6 +115,7 @@ The following files belong to it:
> Used when the 0x1 bit is set in "flags" to specify the APIC id
>
> - param4
> +
This also shouldn't really be in a patch adding new stuff.
We should treat docs in similar fashion to code - if it is just whitespace
separate patch.
> Used when the 0x4 bit is set in "flags" to specify target PCIe device
>
> - notrigger
> @@ -122,6 +128,18 @@ The following files belong to it:
> this actually works depends on what operations the BIOS actually
> includes in the trigger phase.
>
> +- einjv2_component_count
> +
> + The value from this file is used to set the "Component Array Count"
> + field of EINJv2 Extension Structure.
Can we not parse this from the provided component array? Why is separate
parameter useful? You don't seem to write it below in the example.
> +
> +- einjv2_component_array
> +
> + The contents of this file are used to set the "Component Array" field
> + of the EINJv2 Extension Structure. The expected format is hex values
> + for component id and syndrome separated by space, and multiple
> + components are separated by new line.
> +
> CXL error types are supported from ACPI 6.5 onwards (given a CXL port
> is present). The EINJ user interface for CXL error types is at
> <debugfs mount point>/cxl. The following files belong to it:
> @@ -139,7 +157,6 @@ is present). The EINJ user interface for CXL error types is at
> under <debugfs mount point>/apei/einj, while CXL 1.1/1.0 port injections
> must use this file.
>
> -
Another white space change that shouldn't be in this patch in my view.
> BIOS versions based on the ACPI 4.0 specification have limited options
> in controlling where the errors are injected. Your BIOS may support an
> extension (enabled with the param_extension=1 module parameter, or boot
> @@ -194,6 +211,26 @@ An error injection example::
> # echo 0x8 > error_type # Choose correctable memory error
> # echo 1 > error_inject # Inject now
>
> +An EINJv2 error injection example::
> +
> + # cd /sys/kernel/debug/apei/einj
> + # cat available_error_type # See which errors can be injected
> + 0x00000002 Processor Uncorrectable non-fatal
> + 0x00000008 Memory Correctable
> + 0x00000010 Memory Uncorrectable non-fatal
> + 0x00000001 EINJV2 Processor Error
> + 0x00000002 EINJV2 Memory Error
> +
> + # echo 0x12345000 > param1 # Set memory address for injection
> + # echo 0xfffffffffffff000 > param2 # Range - anywhere in this page
> + # comp_arr="0x1 0x2 # Fill in the component array
> + >0x1 0x4
> + >0x2 0x4"
> + # echo "$comp_arr" > einjv2_component_array
> + # echo V2_0x2 > error_type # Choose EINJv2 memory error
> + # echo 0xa > flags # set flags to indicate EINJv2
> + # echo 1 > error_inject # Inject now
> +
> You should see something like this in dmesg::
>
> [22715.830801] EDAC sbridge MC3: HANDLING MCE MEMORY ERROR
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v4 6/9] ACPI: APEI: EINJ: Add einjv2 extension struct
2025-03-13 9:42 ` Jonathan Cameron
@ 2025-03-13 20:06 ` Zaid Alali
2025-03-14 9:27 ` Jonathan Cameron
0 siblings, 1 reply; 20+ messages in thread
From: Zaid Alali @ 2025-03-13 20:06 UTC (permalink / raw)
To: Jonathan Cameron
Cc: rafael, lenb, james.morse, tony.luck, bp, robert.moore,
dan.j.williams, Benjamin.Cheatham, Avadhut.Naik, viro, arnd,
ira.weiny, dave.jiang, sthanneeru.opensrc, linux-acpi,
linux-kernel, acpica-devel
On Thu, Mar 13, 2025 at 09:42:30AM +0000, Jonathan Cameron wrote:
> On Thu, 6 Mar 2025 15:48:07 -0800
> Zaid Alali <zaidal@os.amperecomputing.com> wrote:
>
> > Add einjv2 extension struct and EINJv2 error types to prepare
> > the driver for EINJv2 support. ACPI specifications(1) enables
> > EINJv2 by extending set_error_type_with_address struct.
> >
> > (1) https://bugzilla.tianocore.org/show_bug.cgi?id=4615
> Still seems to be down.
> Also, we have tag for this.
> >
> > Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com>
>
> Link: https://bugzilla.tianocore.org/show_bug.cgi?id=4615 # [1]
>
>
> One additional request inline.
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > ---
> > drivers/acpi/apei/einj-core.c | 23 +++++++++++++++++++++++
> > 1 file changed, 23 insertions(+)
> >
> > diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
> > index aee9a7b17313..32b8d102f399 100644
> > --- a/drivers/acpi/apei/einj-core.c
> > +++ b/drivers/acpi/apei/einj-core.c
> > @@ -50,6 +50,28 @@
> > */
> > static int acpi5;
> >
> > +struct syndrome_array {
> > + union {
> > + u32 acpi_id;
> > + u32 device_id;
> > + u32 pcie_sbdf;
> > + u8 vendor_id[16];
> > + } comp_id;
> > + union {
> > + u32 proc_synd;
> > + u32 mem_synd;
> > + u32 pcie_synd;
> > + u8 vendor_synd[16];
> > + } comp_synd;
> > +};
> > +
> > +struct einjv2_extension_struct {
> > + u32 length;
> > + u16 revision;
> > + u16 component_arr_count;
> > + struct syndrome_array component_arr[];
>
> __counted_by(component_arr_count);
> should be fine and marking these is always good to do in
> new code (and old code if you have time!)
I am not sure if __counted_by is appropriate here. Please note that component_arr_count
is set by the user and does NOT represent the size of the component_arr[].
>
>
> > +};
> > +
> > struct set_error_type_with_address {
> > u32 type;
> > u32 vendor_extension;
> > @@ -58,6 +80,7 @@ struct set_error_type_with_address {
> > u64 memory_address;
> > u64 memory_address_range;
> > u32 pcie_sbdf;
> > + struct einjv2_extension_struct einjv2_struct;
> > };
> > enum {
> > SETWA_FLAGS_APICID = 1,
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v4 6/9] ACPI: APEI: EINJ: Add einjv2 extension struct
2025-03-13 20:06 ` Zaid Alali
@ 2025-03-14 9:27 ` Jonathan Cameron
0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2025-03-14 9:27 UTC (permalink / raw)
To: Zaid Alali
Cc: rafael, lenb, james.morse, tony.luck, bp, robert.moore,
dan.j.williams, Benjamin.Cheatham, Avadhut.Naik, viro, arnd,
ira.weiny, dave.jiang, sthanneeru.opensrc, linux-acpi,
linux-kernel, acpica-devel
On Thu, 13 Mar 2025 13:06:07 -0700
Zaid Alali <zaidal@os.amperecomputing.com> wrote:
> On Thu, Mar 13, 2025 at 09:42:30AM +0000, Jonathan Cameron wrote:
> > On Thu, 6 Mar 2025 15:48:07 -0800
> > Zaid Alali <zaidal@os.amperecomputing.com> wrote:
> >
> > > Add einjv2 extension struct and EINJv2 error types to prepare
> > > the driver for EINJv2 support. ACPI specifications(1) enables
> > > EINJv2 by extending set_error_type_with_address struct.
> > >
> > > (1) https://bugzilla.tianocore.org/show_bug.cgi?id=4615
> > Still seems to be down.
> > Also, we have tag for this.
> > >
> > > Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com>
> >
> > Link: https://bugzilla.tianocore.org/show_bug.cgi?id=4615 # [1]
> >
> >
> > One additional request inline.
> > Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > > ---
> > > drivers/acpi/apei/einj-core.c | 23 +++++++++++++++++++++++
> > > 1 file changed, 23 insertions(+)
> > >
> > > diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
> > > index aee9a7b17313..32b8d102f399 100644
> > > --- a/drivers/acpi/apei/einj-core.c
> > > +++ b/drivers/acpi/apei/einj-core.c
> > > @@ -50,6 +50,28 @@
> > > */
> > > static int acpi5;
> > >
> > > +struct syndrome_array {
> > > + union {
> > > + u32 acpi_id;
> > > + u32 device_id;
> > > + u32 pcie_sbdf;
> > > + u8 vendor_id[16];
> > > + } comp_id;
> > > + union {
> > > + u32 proc_synd;
> > > + u32 mem_synd;
> > > + u32 pcie_synd;
> > > + u8 vendor_synd[16];
> > > + } comp_synd;
> > > +};
> > > +
> > > +struct einjv2_extension_struct {
> > > + u32 length;
> > > + u16 revision;
> > > + u16 component_arr_count;
> > > + struct syndrome_array component_arr[];
> >
> > __counted_by(component_arr_count);
> > should be fine and marking these is always good to do in
> > new code (and old code if you have time!)
>
> I am not sure if __counted_by is appropriate here. Please note that component_arr_count
> is set by the user and does NOT represent the size of the component_arr[].
Does it represent the length that should ever be accessed (which is what
the __counted_by() stuff will help us find bugs around).
If not that wins an award for misleading naming :)
Jonathan
> >
> >
> > > +};
> > > +
> > > struct set_error_type_with_address {
> > > u32 type;
> > > u32 vendor_extension;
> > > @@ -58,6 +80,7 @@ struct set_error_type_with_address {
> > > u64 memory_address;
> > > u64 memory_address_range;
> > > u32 pcie_sbdf;
> > > + struct einjv2_extension_struct einjv2_struct;
> > > };
> > > enum {
> > > SETWA_FLAGS_APICID = 1,
> >
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2025-03-14 9:27 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-06 23:48 [PATCH v4 0/9] Enable EINJv2 Support Zaid Alali
2025-03-06 23:48 ` [PATCH v4 1/9] ACPICA: Update values to hex to follow ACPI specs Zaid Alali
2025-03-06 23:48 ` [PATCH v4 2/9] ACPICA: Add EINJv2 get error type action Zaid Alali
2025-03-06 23:48 ` [PATCH v4 3/9] ACPI: APEI: EINJ: Fix kernel test robot sparse warning Zaid Alali
2025-03-08 8:55 ` kernel test robot
2025-03-13 9:37 ` Jonathan Cameron
2025-03-13 9:50 ` Jonathan Cameron
2025-03-06 23:48 ` [PATCH v4 4/9] ACPI: APEI: EINJ: Remove redundant calls to einj_get_available_error_type Zaid Alali
2025-03-06 23:48 ` [PATCH v4 5/9] ACPI: APEI: EINJ: Enable the discovery of EINJv2 capabilities Zaid Alali
2025-03-13 9:39 ` Jonathan Cameron
2025-03-06 23:48 ` [PATCH v4 6/9] ACPI: APEI: EINJ: Add einjv2 extension struct Zaid Alali
2025-03-13 9:42 ` Jonathan Cameron
2025-03-13 20:06 ` Zaid Alali
2025-03-14 9:27 ` Jonathan Cameron
2025-03-06 23:48 ` [PATCH v4 7/9] ACPI: APEI: EINJ: Add debugfs files for EINJv2 support Zaid Alali
2025-03-13 9:46 ` Jonathan Cameron
2025-03-06 23:48 ` [PATCH v4 8/9] ACPI: APEI: EINJ: Enable EINJv2 error injections Zaid Alali
2025-03-13 9:56 ` Jonathan Cameron
2025-03-06 23:48 ` [PATCH v4 9/9] ACPI: APEI: EINJ: Update the documentation for EINJv2 support Zaid Alali
2025-03-13 9:59 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox