From: Dave Jiang <dave.jiang@intel.com>
To: alison.schofield@intel.com,
Dan Williams <dan.j.williams@intel.com>,
Ira Weiny <ira.weiny@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Ben Widawsky <bwidawsk@kernel.org>
Cc: linux-cxl@vger.kernel.org,
Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH v5 11/12] tools/testing/cxl: Add a sysfs attr to test poison inject limits
Date: Fri, 31 Mar 2023 12:18:45 -0700 [thread overview]
Message-ID: <9ead63d7-6330-7950-50b8-2a6ada404f69@intel.com> (raw)
In-Reply-To: <8c6a37f71095be970eb04cc1e2ab2cdb08062020.1679892337.git.alison.schofield@intel.com>
On 3/26/23 10:03 PM, alison.schofield@intel.com wrote:
> From: Alison Schofield <alison.schofield@intel.com>
>
> CXL devices may report a maximum number of addresses that a device
> allows to be poisoned using poison injection. When cxl_test creates
> mock CXL memory devices, it defaults to MOCK_INJECT_DEV_MAX==88 for
> all mocked memdevs.
>
> Add a sysfs attribute, poison_inject_max to module cxl_mock_mem so
> that users can set a custom device injection limit. Fail, and return
> -EBUSY, if the mock poison list is not empty.
>
> /sys/bus/platform/drivers/cxl_mock_mem/poison_inject_max
>
> A simple usage model is to set the attribute before running a test in
> order to emulate a device's poison handling.
>
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
> tools/testing/cxl/test/mem.c | 52 +++++++++++++++++++++++++++++++++---
> 1 file changed, 48 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c
> index 9658d95236b7..5c3b3e5a3b4b 100644
> --- a/tools/testing/cxl/test/mem.c
> +++ b/tools/testing/cxl/test/mem.c
> @@ -19,6 +19,8 @@
> #define MOCK_INJECT_DEV_MAX 8
> #define MOCK_INJECT_TEST_MAX 128
>
> +static unsigned int poison_inject_dev_max = MOCK_INJECT_DEV_MAX;
> +
> static struct cxl_cel_entry mock_cel[] = {
> {
> .opcode = cpu_to_le16(CXL_MBOX_OP_GET_SUPPORTED_LOGS),
> @@ -485,7 +487,7 @@ static int mock_id(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd)
> cpu_to_le64(SZ_256M / CXL_CAPACITY_MULTIPLIER),
> .total_capacity =
> cpu_to_le64(DEV_SIZE / CXL_CAPACITY_MULTIPLIER),
> - .inject_poison_limit = cpu_to_le16(MOCK_INJECT_DEV_MAX),
> + .inject_poison_limit = cpu_to_le16(MOCK_INJECT_TEST_MAX),
> };
>
> put_unaligned_le24(CXL_POISON_LIST_MAX, id.poison_list_max_mer);
> @@ -919,7 +921,7 @@ static struct cxl_mbox_poison_payload_out
> int nr_records = 0;
> u64 dpa;
>
> - po = kzalloc(struct_size(po, record, MOCK_INJECT_DEV_MAX), GFP_KERNEL);
> + po = kzalloc(struct_size(po, record, poison_inject_dev_max), GFP_KERNEL);
> if (!po)
> return NULL;
>
> @@ -934,7 +936,7 @@ static struct cxl_mbox_poison_payload_out
> po->record[nr_records].address = cpu_to_le64(dpa);
> po->record[nr_records].length = cpu_to_le32(1);
> nr_records++;
> - if (nr_records == MOCK_INJECT_DEV_MAX)
> + if (nr_records == poison_inject_dev_max)
> break;
> }
>
> @@ -969,7 +971,7 @@ static bool mock_poison_dev_max_injected(struct cxl_dev_state *cxlds)
> if (mock_poison_list[i].cxlds == cxlds)
> count++;
> }
> - return (count >= MOCK_INJECT_DEV_MAX);
> + return (count >= poison_inject_dev_max);
> }
>
> static bool mock_poison_add(struct cxl_dev_state *cxlds, u64 dpa)
> @@ -1051,6 +1053,47 @@ static int mock_clear_poison(struct cxl_dev_state *cxlds,
> return 0;
> }
>
> +static bool mock_poison_list_empty(void)
> +{
> + for (int i = 0; i < MOCK_INJECT_TEST_MAX; i++) {
> + if (mock_poison_list[i].cxlds)
> + return false;
> + }
> + return true;
> +}
> +
> +static ssize_t poison_inject_max_show(struct device_driver *drv, char *buf)
> +{
> + return sysfs_emit(buf, "%u\n", poison_inject_dev_max);
> +}
> +
> +static ssize_t poison_inject_max_store(struct device_driver *drv,
> + const char *buf, size_t len)
> +{
> + int val;
> +
> + if (kstrtoint(buf, 0, &val) < 0)
> + return -EINVAL;
> +
> + if (!mock_poison_list_empty())
> + return -EBUSY;
> +
> + if (val <= MOCK_INJECT_TEST_MAX)
> + poison_inject_dev_max = val;
> + else
> + return -EINVAL;
> +
> + return len;
> +}
> +
> +static DRIVER_ATTR_RW(poison_inject_max);
> +
> +static struct attribute *cxl_mock_mem_core_attrs[] = {
> + &driver_attr_poison_inject_max.attr,
> + NULL
> +};
> +ATTRIBUTE_GROUPS(cxl_mock_mem_core);
> +
> static int cxl_mock_mbox_send(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd)
> {
> struct device *dev = cxlds->dev;
> @@ -1259,6 +1302,7 @@ static struct platform_driver cxl_mock_mem_driver = {
> .driver = {
> .name = KBUILD_MODNAME,
> .dev_groups = cxl_mock_mem_groups,
> + .groups = cxl_mock_mem_core_groups,
> },
> };
>
next prev parent reply other threads:[~2023-03-31 19:18 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-27 5:03 [PATCH v5 0/12] cxl: CXL Inject & Clear Poison alison.schofield
2023-03-27 5:03 ` [PATCH v5 01/12] cxl/memdev: Add support for the Inject Poison mailbox command alison.schofield
2023-03-30 18:47 ` Jonathan Cameron
2023-03-31 18:11 ` Dave Jiang
2023-03-31 18:52 ` Alison Schofield
2023-03-27 5:03 ` [PATCH v5 02/12] cxl/memdev: Add support for the Clear " alison.schofield
2023-03-30 18:50 ` Jonathan Cameron
2023-03-30 20:12 ` Alison Schofield
2023-04-03 14:08 ` Jonathan Cameron
2023-03-31 18:40 ` Dave Jiang
2023-03-31 19:55 ` Alison Schofield
2023-03-31 21:18 ` Dave Jiang
2023-03-27 5:03 ` [PATCH v5 03/12] cxl/memdev: Warn of poison inject or clear to a mapped region alison.schofield
2023-03-30 18:55 ` Jonathan Cameron
2023-04-11 17:43 ` Alison Schofield
2023-04-13 17:07 ` Jonathan Cameron
2023-03-27 5:03 ` [PATCH v5 04/12] cxl/memdev: Trace inject and clear poison as cxl_poison events alison.schofield
2023-03-30 19:03 ` Jonathan Cameron
2023-03-31 18:53 ` Dave Jiang
2023-03-27 5:03 ` [PATCH v5 05/12] cxl/mem: Add debugfs attributes for poison inject and clear alison.schofield
2023-03-30 18:58 ` Jonathan Cameron
2023-03-27 5:03 ` [PATCH v5 06/12] cxl/memdev: Make inject and clear poison cmds kernel exclusive alison.schofield
2023-03-31 19:10 ` Dave Jiang
2023-03-27 5:03 ` [PATCH v5 07/12] cxl/mbox: Block inject and clear poison opcodes in raw mode alison.schofield
2023-03-31 19:10 ` Dave Jiang
2023-03-27 5:03 ` [PATCH v5 08/12] tools/testing/cxl: Mock the Inject Poison mailbox command alison.schofield
2023-03-31 19:13 ` Dave Jiang
2023-03-27 5:03 ` [PATCH v5 09/12] tools/testing/cxl: Mock the Clear " alison.schofield
2023-03-31 19:15 ` Dave Jiang
2023-03-27 5:03 ` [PATCH v5 10/12] tools/testing/cxl: Use injected poison for get poison list alison.schofield
2023-03-31 19:16 ` Dave Jiang
2023-03-27 5:03 ` [PATCH v5 11/12] tools/testing/cxl: Add a sysfs attr to test poison inject limits alison.schofield
2023-03-31 19:18 ` Dave Jiang [this message]
2023-03-27 5:03 ` [PATCH v5 12/12] tools/testing/cxl: Require CONFIG_DEBUG_FS alison.schofield
2023-03-31 19:20 ` Dave Jiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9ead63d7-6330-7950-50b8-2a6ada404f69@intel.com \
--to=dave.jiang@intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=bwidawsk@kernel.org \
--cc=dan.j.williams@intel.com \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).