[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <63d44b4a9774_ea222294f2@dwillia2-xfh.jf.intel.com.notmuch>
Date: Fri, 27 Jan 2023 14:08:10 -0800
From: Dan Williams <dan.j.williams@...el.com>
To: <alison.schofield@...el.com>,
Dan Williams <dan.j.williams@...el.com>,
Ira Weiny <ira.weiny@...el.com>,
Vishal Verma <vishal.l.verma@...el.com>,
Dave Jiang <dave.jiang@...el.com>,
Ben Widawsky <bwidawsk@...nel.org>,
Steven Rostedt <rostedt@...dmis.org>
CC: Alison Schofield <alison.schofield@...el.com>,
<linux-cxl@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>
Subject: RE: [PATCH v5 5/5] tools/testing/cxl: Mock support for Get Poison
List
alison.schofield@ wrote:
> From: Alison Schofield <alison.schofield@...el.com>
>
> 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.
>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>
> Signed-off-by: Alison Schofield <alison.schofield@...el.com>
> ---
> 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 5e4ecd93f1d2..09dc358bb33b 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>
>
> #define LSA_SIZE SZ_128K
> @@ -38,6 +39,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 */
> @@ -141,6 +146,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;
>
> @@ -558,6 +565,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;
> + } mock_plist = {
...I think this needs to be __packed as well otherwise the compiler
could inject alignment padding between these 2 packed structures.
> + .po = {
> + .count = cpu_to_le16(1),
> + },
> + .record = {
> + .length = cpu_to_le32(1),
> + .address = cpu_to_le64(pi->offset +
sparse says there is a missing le64_to_cpu(pi->offset) here
Powered by blists - more mailing lists