[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v2 3/6] cxl/core: add report option for cxl_mem_get_poison()
From: |
Shiyang Ruan |
Subject: |
[RFC PATCH v2 3/6] cxl/core: add report option for cxl_mem_get_poison() |
Date: |
Fri, 29 Mar 2024 14:36:11 +0800 |
The GMER only has "Physical Address" field, no such one indicates length.
So, when a poison event is received, we could use GET_POISON_LIST command
to get the poison list. Now driver has cxl_mem_get_poison(), so
reuse it and add a parameter 'bool report', report poison record to MCE
if set true.
Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
---
drivers/cxl/core/mbox.c | 8 ++++++--
drivers/cxl/core/memdev.c | 4 ++--
drivers/cxl/core/region.c | 8 ++++----
drivers/cxl/cxlmem.h | 2 +-
4 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
index 31b1b8711256..19b46fb06ed6 100644
--- a/drivers/cxl/core/mbox.c
+++ b/drivers/cxl/core/mbox.c
@@ -1309,7 +1309,7 @@ void cxl_mem_report_poison(struct cxl_memdev *cxlmd,
EXPORT_SYMBOL_NS_GPL(cxl_mem_report_poison, CXL);
int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len,
- struct cxl_region *cxlr)
+ struct cxl_region *cxlr, bool report)
{
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds);
struct cxl_mbox_poison_out *po;
@@ -1340,10 +1340,14 @@ int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64
offset, u64 len,
if (rc)
break;
- for (int i = 0; i < le16_to_cpu(po->count); i++)
+ for (int i = 0; i < le16_to_cpu(po->count); i++) {
trace_cxl_poison(cxlmd, cxlr, &po->record[i],
po->flags, po->overflow_ts,
CXL_POISON_TRACE_LIST);
+ if (report)
+ cxl_mem_report_poison(cxlmd, cxlr,
+ &po->record[i]);
+ }
/* Protect against an uncleared _FLAG_MORE */
nr_records = nr_records + le16_to_cpu(po->count);
diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
index d4e259f3a7e9..e976141ca4a9 100644
--- a/drivers/cxl/core/memdev.c
+++ b/drivers/cxl/core/memdev.c
@@ -200,14 +200,14 @@ static int cxl_get_poison_by_memdev(struct cxl_memdev
*cxlmd)
if (resource_size(&cxlds->pmem_res)) {
offset = cxlds->pmem_res.start;
length = resource_size(&cxlds->pmem_res);
- rc = cxl_mem_get_poison(cxlmd, offset, length, NULL);
+ rc = cxl_mem_get_poison(cxlmd, offset, length, NULL, false);
if (rc)
return rc;
}
if (resource_size(&cxlds->ram_res)) {
offset = cxlds->ram_res.start;
length = resource_size(&cxlds->ram_res);
- rc = cxl_mem_get_poison(cxlmd, offset, length, NULL);
+ rc = cxl_mem_get_poison(cxlmd, offset, length, NULL, false);
/*
* Invalid Physical Address is not an error for
* volatile addresses. Device support is optional.
diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 5c186e0a39b9..e83c46cb4dea 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -2585,7 +2585,7 @@ static int cxl_get_poison_unmapped(struct cxl_memdev
*cxlmd,
if (ctx->mode == CXL_DECODER_RAM) {
offset = ctx->offset;
length = resource_size(&cxlds->ram_res) - offset;
- rc = cxl_mem_get_poison(cxlmd, offset, length, NULL);
+ rc = cxl_mem_get_poison(cxlmd, offset, length, NULL, false);
if (rc == -EFAULT)
rc = 0;
if (rc)
@@ -2603,7 +2603,7 @@ static int cxl_get_poison_unmapped(struct cxl_memdev
*cxlmd,
return 0;
}
- return cxl_mem_get_poison(cxlmd, offset, length, NULL);
+ return cxl_mem_get_poison(cxlmd, offset, length, NULL, false);
}
static int poison_by_decoder(struct device *dev, void *arg)
@@ -2637,7 +2637,7 @@ static int poison_by_decoder(struct device *dev, void
*arg)
if (cxled->skip) {
offset = cxled->dpa_res->start - cxled->skip;
length = cxled->skip;
- rc = cxl_mem_get_poison(cxlmd, offset, length, NULL);
+ rc = cxl_mem_get_poison(cxlmd, offset, length, NULL, false);
if (rc == -EFAULT && cxled->mode == CXL_DECODER_RAM)
rc = 0;
if (rc)
@@ -2646,7 +2646,7 @@ static int poison_by_decoder(struct device *dev, void
*arg)
offset = cxled->dpa_res->start;
length = cxled->dpa_res->end - offset + 1;
- rc = cxl_mem_get_poison(cxlmd, offset, length, cxled->cxld.region);
+ rc = cxl_mem_get_poison(cxlmd, offset, length, cxled->cxld.region,
false);
if (rc == -EFAULT && cxled->mode == CXL_DECODER_RAM)
rc = 0;
if (rc)
diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h
index 82f80eb381fb..1f03130b9d6a 100644
--- a/drivers/cxl/cxlmem.h
+++ b/drivers/cxl/cxlmem.h
@@ -832,7 +832,7 @@ void cxl_mem_report_poison(struct cxl_memdev *cxlmd,
struct cxl_region *cxlr,
struct cxl_poison_record *poison);
int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len,
- struct cxl_region *cxlr);
+ struct cxl_region *cxlr, bool report);
int cxl_trigger_poison_list(struct cxl_memdev *cxlmd);
int cxl_inject_poison(struct cxl_memdev *cxlmd, u64 dpa);
int cxl_clear_poison(struct cxl_memdev *cxlmd, u64 dpa);
--
2.34.1
- [RFC PATCH v2 0/6] cxl: add poison event handler, Shiyang Ruan, 2024/03/29
- [RFC PATCH v2 2/6] cxl/core: introduce cxl_mem_report_poison(), Shiyang Ruan, 2024/03/29
- [RFC PATCH v2 4/6] cxl/core: report poison when injecting from debugfs, Shiyang Ruan, 2024/03/29
- [RFC PATCH v2 3/6] cxl/core: add report option for cxl_mem_get_poison(),
Shiyang Ruan <=
- [RFC PATCH v2 1/6] cxl/core: correct length of DPA field masks, Shiyang Ruan, 2024/03/29
- [RFC PATCH v2 5/6] cxl: add definition for transaction types, Shiyang Ruan, 2024/03/29
- [RFC PATCH v2 6/6] cxl/core: add poison injection event handler, Shiyang Ruan, 2024/03/29
- Re: [RFC PATCH v2 0/6] cxl: add poison event handler, Alison Schofield, 2024/03/29