2023-03-10 17:56:50

by Alison Schofield

[permalink] [raw]
Subject: [PATCH v8 0/6] CXL Poison List Retrieval & Tracing

From: Alison Schofield <[email protected]>

Changes in v8:

Patch 4: cxl/region: Provide region info to the cxl_poison trace event
- Don't percolate non-error rc in trigger_poison_list_store() (Jonathan)
- Use the entire dpa_res, not pmem_res, when calculating remaining length
after a PMEM decoder. (Jonathan)
- Calculate skip relative to current endpoint. (Jonathan)
- Always use local vars for offset & length (Tidy-up)

Patch 3: cxl/memdev: Add trigger_poison_list sysfs attribute
- Update dates and version in Patch 3: ABI doc (Jonathan)
- Added Jonathan Reviewed-by to Patch 3 (Jonathan)

Link to v7: https://lore.kernel.org/linux-cxl/[email protected]/#r

Add support for retrieving device poison lists and store the returned
error records as kernel trace events.

The handling of the poison list is guided by the CXL 3.0 Specification
Section 8.2.9.8.4.1. [1]

Example:
$ echo 1 > /sys/bus/cxl/devices/mem0/trigger_poison_list
cxl_poison: memdev=mem0 host=cxl_mem.0 serial=0 region=region4 region_uuid=117b2cf4-b160-4090-9361-ba31b9649317 hpa=0xf0d0000000 dpa=0x40000000 length=0x40 source=Internal flags= overflow_time=0

[1]: https://www.computeexpresslink.org/download-the-specification

Alison Schofield (6):
cxl/mbox: Add GET_POISON_LIST mailbox command
cxl/trace: Add TRACE support for CXL media-error records
cxl/memdev: Add trigger_poison_list sysfs attribute
cxl/region: Provide region info to the cxl_poison trace event
cxl/trace: Add an HPA to cxl_poison trace events
tools/testing/cxl: Mock support for Get Poison List

Documentation/ABI/testing/sysfs-bus-cxl | 14 ++++
drivers/cxl/core/core.h | 5 ++
drivers/cxl/core/mbox.c | 74 +++++++++++++++++++
drivers/cxl/core/memdev.c | 71 ++++++++++++++++++
drivers/cxl/core/region.c | 96 +++++++++++++++++++++++++
drivers/cxl/core/trace.c | 94 ++++++++++++++++++++++++
drivers/cxl/core/trace.h | 91 +++++++++++++++++++++++
drivers/cxl/cxlmem.h | 69 +++++++++++++++++-
drivers/cxl/pci.c | 4 ++
tools/testing/cxl/test/mem.c | 42 +++++++++++
10 files changed, 559 insertions(+), 1 deletion(-)


base-commit: e686c32590f40bffc45f105c04c836ffad3e531a
--
2.37.3



2023-03-10 17:57:02

by Alison Schofield

[permalink] [raw]
Subject: [PATCH v8 6/6] tools/testing/cxl: Mock support for Get Poison List

From: Alison Schofield <[email protected]>

Make mock memdevs support the Get Poison List mailbox command.
Return a fake poison error record when the get poison list command
is issued.

This supports testing the kernel tracing and cxl list capabilities
for media errors.

Signed-off-by: Alison Schofield <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
---
tools/testing/cxl/test/mem.c | 42 ++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)

diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c
index 9263b04d35f7..2fa9c18d4c2c 100644
--- a/tools/testing/cxl/test/mem.c
+++ b/tools/testing/cxl/test/mem.c
@@ -7,6 +7,7 @@
#include <linux/delay.h>
#include <linux/sizes.h>
#include <linux/bits.h>
+#include <asm/unaligned.h>
#include <cxlmem.h>

#include "trace.h"
@@ -40,6 +41,10 @@ static struct cxl_cel_entry mock_cel[] = {
.opcode = cpu_to_le16(CXL_MBOX_OP_GET_HEALTH_INFO),
.effect = cpu_to_le16(0),
},
+ {
+ .opcode = cpu_to_le16(CXL_MBOX_OP_GET_POISON),
+ .effect = cpu_to_le16(0),
+ },
};

/* See CXL 2.0 Table 181 Get Health Info Output Payload */
@@ -471,6 +476,8 @@ static int mock_id(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd)
cpu_to_le64(DEV_SIZE / CXL_CAPACITY_MULTIPLIER),
};

+ put_unaligned_le24(CXL_POISON_LIST_MAX, id.poison_list_max_mer);
+
if (cmd->size_out < sizeof(id))
return -EINVAL;

@@ -888,6 +895,34 @@ static int mock_health_info(struct cxl_dev_state *cxlds,
return 0;
}

+static int mock_get_poison(struct cxl_dev_state *cxlds,
+ struct cxl_mbox_cmd *cmd)
+{
+ struct cxl_mbox_poison_payload_in *pi = cmd->payload_in;
+
+ /* Mock one poison record at pi.offset for 64 bytes */
+ struct {
+ struct cxl_mbox_poison_payload_out po;
+ struct cxl_poison_record record;
+ } __packed mock_plist = {
+ .po = {
+ .count = cpu_to_le16(1),
+ },
+ .record = {
+ .length = cpu_to_le32(1),
+ .address = cpu_to_le64(le64_to_cpu(pi->offset) +
+ CXL_POISON_SOURCE_INJECTED),
+ },
+ };
+
+ if (cmd->size_out < sizeof(mock_plist))
+ return -EINVAL;
+
+ memcpy(cmd->payload_out, &mock_plist, sizeof(mock_plist));
+ cmd->size_out = sizeof(mock_plist);
+ return 0;
+}
+
static int cxl_mock_mbox_send(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd)
{
struct device *dev = cxlds->dev;
@@ -942,6 +977,9 @@ static int cxl_mock_mbox_send(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *
case CXL_MBOX_OP_PASSPHRASE_SECURE_ERASE:
rc = mock_passphrase_secure_erase(cxlds, cmd);
break;
+ case CXL_MBOX_OP_GET_POISON:
+ rc = mock_get_poison(cxlds, cmd);
+ break;
default:
break;
}
@@ -1010,6 +1048,10 @@ static int cxl_mock_mem_probe(struct platform_device *pdev)
if (rc)
return rc;

+ rc = cxl_poison_state_init(cxlds);
+ if (rc)
+ return rc;
+
rc = cxl_dev_state_identify(cxlds);
if (rc)
return rc;
--
2.37.3


2023-03-13 23:00:18

by Ira Weiny

[permalink] [raw]
Subject: Re: [PATCH v8 6/6] tools/testing/cxl: Mock support for Get Poison List

alison.schofield@ wrote:
> From: Alison Schofield <[email protected]>
>
> Make mock memdevs support the Get Poison List mailbox command.
> Return a fake poison error record when the get poison list command
> is issued.
>
> This supports testing the kernel tracing and cxl list capabilities
> for media errors.
>
> Signed-off-by: Alison Schofield <[email protected]>
> Reviewed-by: Jonathan Cameron <[email protected]>

Reviewed-by: Ira Weiny <[email protected]>