Skip to content

Commit ba8af8e

Browse files
fdefrancrafaeljw
authored andcommitted
ACPI: APEI: GHES: Add helper to copy CPER CXL protocol error info to work struct
Make a helper out of cxl_cper_post_prot_err() that checks the CXL agent type and copy the CPER CXL protocol errors information to a work data structure. Export the new symbol for reuse by ELOG. Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Reviewed-by: Hanjun Guo <guohanjun@huawei.com> Signed-off-by: Fabio M. De Francesco <fabio.m.de.francesco@linux.intel.com> [ rjw: Subject tweak ] Link: https://patch.msgid.link/20260114101543.85926-5-fabio.m.de.francesco@linux.intel.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 7020586 commit ba8af8e

3 files changed

Lines changed: 44 additions & 21 deletions

File tree

drivers/acpi/apei/ghes.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,6 @@ static void cxl_cper_post_prot_err(struct cxl_cper_sec_prot_err *prot_err,
739739
{
740740
#ifdef CONFIG_ACPI_APEI_PCIEAER
741741
struct cxl_cper_prot_err_work_data wd;
742-
u8 *dvsec_start, *cap_start;
743742

744743
if (cxl_cper_sec_prot_err_valid(prot_err))
745744
return;
@@ -749,27 +748,8 @@ static void cxl_cper_post_prot_err(struct cxl_cper_sec_prot_err *prot_err,
749748
if (!cxl_cper_prot_err_work)
750749
return;
751750

752-
switch (prot_err->agent_type) {
753-
case RCD:
754-
case DEVICE:
755-
case LD:
756-
case FMLD:
757-
case RP:
758-
case DSP:
759-
case USP:
760-
memcpy(&wd.prot_err, prot_err, sizeof(wd.prot_err));
761-
762-
dvsec_start = (u8 *)(prot_err + 1);
763-
cap_start = dvsec_start + prot_err->dvsec_len;
764-
765-
memcpy(&wd.ras_cap, cap_start, sizeof(wd.ras_cap));
766-
wd.severity = cper_severity_to_aer(severity);
767-
break;
768-
default:
769-
pr_err_ratelimited("CXL CPER invalid agent type: %d\n",
770-
prot_err->agent_type);
751+
if (cxl_cper_setup_prot_err_work_data(&wd, prot_err, severity))
771752
return;
772-
}
773753

774754
if (!kfifo_put(&cxl_cper_prot_err_fifo, wd)) {
775755
pr_err_ratelimited("CXL CPER kfifo overflow\n");

drivers/acpi/apei/ghes_helpers.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Copyright(c) 2025 Intel Corporation. All rights reserved
33

44
#include <linux/printk.h>
5+
#include <linux/aer.h>
56
#include <cxl/event.h>
67

78
int cxl_cper_sec_prot_err_valid(struct cxl_cper_sec_prot_err *prot_err)
@@ -31,3 +32,35 @@ int cxl_cper_sec_prot_err_valid(struct cxl_cper_sec_prot_err *prot_err)
3132
return 0;
3233
}
3334
EXPORT_SYMBOL_GPL(cxl_cper_sec_prot_err_valid);
35+
36+
int cxl_cper_setup_prot_err_work_data(struct cxl_cper_prot_err_work_data *wd,
37+
struct cxl_cper_sec_prot_err *prot_err,
38+
int severity)
39+
{
40+
u8 *dvsec_start, *cap_start;
41+
42+
switch (prot_err->agent_type) {
43+
case RCD:
44+
case DEVICE:
45+
case LD:
46+
case FMLD:
47+
case RP:
48+
case DSP:
49+
case USP:
50+
memcpy(&wd->prot_err, prot_err, sizeof(wd->prot_err));
51+
52+
dvsec_start = (u8 *)(prot_err + 1);
53+
cap_start = dvsec_start + prot_err->dvsec_len;
54+
55+
memcpy(&wd->ras_cap, cap_start, sizeof(wd->ras_cap));
56+
wd->severity = cper_severity_to_aer(severity);
57+
break;
58+
default:
59+
pr_err_ratelimited("CXL CPER invalid agent type: %d\n",
60+
prot_err->agent_type);
61+
return -EINVAL;
62+
}
63+
64+
return 0;
65+
}
66+
EXPORT_SYMBOL_GPL(cxl_cper_setup_prot_err_work_data);

include/cxl/event.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,22 @@ static inline int cxl_cper_prot_err_kfifo_get(struct cxl_cper_prot_err_work_data
322322

323323
#ifdef CONFIG_ACPI_APEI_PCIEAER
324324
int cxl_cper_sec_prot_err_valid(struct cxl_cper_sec_prot_err *prot_err);
325+
int cxl_cper_setup_prot_err_work_data(struct cxl_cper_prot_err_work_data *wd,
326+
struct cxl_cper_sec_prot_err *prot_err,
327+
int severity);
325328
#else
326329
static inline int
327330
cxl_cper_sec_prot_err_valid(struct cxl_cper_sec_prot_err *prot_err)
328331
{
329332
return -EOPNOTSUPP;
330333
}
334+
static inline int
335+
cxl_cper_setup_prot_err_work_data(struct cxl_cper_prot_err_work_data *wd,
336+
struct cxl_cper_sec_prot_err *prot_err,
337+
int severity)
338+
{
339+
return -EOPNOTSUPP;
340+
}
331341
#endif
332342

333343
#endif /* _LINUX_CXL_EVENT_H */

0 commit comments

Comments
 (0)