From: Dave Jiang <dave.jiang@intel.com>
To: Dan Williams <dan.j.williams@intel.com>, <linux-cxl@vger.kernel.org>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Subject: Re: [PATCH v3 10/10] tools/testing/cxl: Add 'sanitize notifier' support
Date: Fri, 13 Oct 2023 10:25:32 -0700 [thread overview]
Message-ID: <e8a085fe-303d-41b6-82da-4a79b5e735b0@intel.com> (raw)
In-Reply-To: <169657721756.1491153.17305814762884004365.stgit@dwillia2-xfh.jf.intel.com>
On 10/6/23 00:26, Dan Williams wrote:
> Allow for cxl_test regression of the sanitize notifier. Reuse the core
> setup infrastructure, and trigger notifications upon any sanitize
> submission with a programmable notification delay.
>
> Cc: Davidlohr Bueso <dave@stgolabs.net>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
> tools/testing/cxl/test/mem.c | 68 +++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 67 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c
> index ab311b59899a..76bdb1ac5816 100644
> --- a/tools/testing/cxl/test/mem.c
> +++ b/tools/testing/cxl/test/mem.c
> @@ -89,6 +89,12 @@ static struct cxl_cel_entry mock_cel[] = {
> .effect = cpu_to_le16(EFFECT(CONF_CHANGE_COLD_RESET) |
> EFFECT(CONF_CHANGE_IMMEDIATE)),
> },
> + {
> + .opcode = cpu_to_le16(CXL_MBOX_OP_SANITIZE),
> + .effect = cpu_to_le16(EFFECT(DATA_CHANGE_IMMEDIATE) |
> + EFFECT(SECURITY_CHANGE_IMMEDIATE) |
> + EFFECT(BACKGROUND_OP)),
> + },
> };
>
> /* See CXL 2.0 Table 181 Get Health Info Output Payload */
> @@ -152,6 +158,7 @@ struct cxl_mockmem_data {
> struct cxl_memdev_state *mds;
> u8 event_buf[SZ_4K];
> u64 timestamp;
> + unsigned long sanitize_timeout;
> };
>
> static struct mock_event_log *event_find_log(struct device *dev, int log_type)
> @@ -567,9 +574,26 @@ static int mock_partition_info(struct cxl_mbox_cmd *cmd)
> return 0;
> }
>
> +void cxl_mockmem_sanitize_work(struct work_struct *work)
> +{
> + struct cxl_memdev_state *mds =
> + container_of(work, typeof(*mds), security.poll_dwork.work);
> +
> + mutex_lock(&mds->mbox_mutex);
> + if (mds->security.sanitize_node)
> + sysfs_notify_dirent(mds->security.sanitize_node);
> + mds->security.sanitize_active = false;
> + mutex_unlock(&mds->mbox_mutex);
> +
> + dev_dbg(mds->cxlds.dev, "sanitize complete\n");
> +}
> +
> static int mock_sanitize(struct cxl_mockmem_data *mdata,
> struct cxl_mbox_cmd *cmd)
> {
> + struct cxl_memdev_state *mds = mdata->mds;
> + int rc = 0;
> +
> if (cmd->size_in != 0)
> return -EINVAL;
>
> @@ -585,7 +609,16 @@ static int mock_sanitize(struct cxl_mockmem_data *mdata,
> return -ENXIO;
> }
>
> - return 0; /* assume less than 2 secs, no bg */
> + mutex_lock(&mds->mbox_mutex);
> + if (schedule_delayed_work(&mds->security.poll_dwork,
> + msecs_to_jiffies(mdata->sanitize_timeout))) {
> + mds->security.sanitize_active = true;
> + dev_dbg(mds->cxlds.dev, "sanitize issued\n");
> + } else
> + rc = -EBUSY;
> + mutex_unlock(&mds->mbox_mutex);
> +
> + return rc;
> }
>
> static int mock_secure_erase(struct cxl_mockmem_data *mdata,
> @@ -1419,6 +1452,7 @@ static int cxl_mock_mem_probe(struct platform_device *pdev)
> mds->mbox_send = cxl_mock_mbox_send;
> mds->payload_size = SZ_4K;
> mds->event.buf = (struct cxl_get_event_payload *) mdata->event_buf;
> + INIT_DELAYED_WORK(&mds->security.poll_dwork, cxl_mockmem_sanitize_work);
>
> cxlds = &mds->cxlds;
> cxlds->serial = pdev->id;
> @@ -1458,6 +1492,10 @@ static int cxl_mock_mem_probe(struct platform_device *pdev)
> if (rc)
> return rc;
>
> + rc = devm_cxl_sanitize_setup_notifier(&pdev->dev, cxlmd);
> + if (rc)
> + return rc;
> +
> cxl_mem_get_event_records(mds, CXLDEV_EVENT_STATUS_ALL);
>
> return 0;
> @@ -1526,10 +1564,38 @@ static ssize_t fw_buf_checksum_show(struct device *dev,
>
> static DEVICE_ATTR_RO(fw_buf_checksum);
>
> +static ssize_t sanitize_timeout_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct cxl_mockmem_data *mdata = dev_get_drvdata(dev);
> +
> + return sysfs_emit(buf, "%lu\n", mdata->sanitize_timeout);
> +}
> +
> +static ssize_t sanitize_timeout_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct cxl_mockmem_data *mdata = dev_get_drvdata(dev);
> + unsigned long val;
> + int rc;
> +
> + rc = kstrtoul(buf, 0, &val);
> + if (rc)
> + return rc;
> +
> + mdata->sanitize_timeout = val;
> +
> + return count;
> +}
> +
> +static DEVICE_ATTR_RW(sanitize_timeout);
> +
> static struct attribute *cxl_mock_mem_attrs[] = {
> &dev_attr_security_lock.attr,
> &dev_attr_event_trigger.attr,
> &dev_attr_fw_buf_checksum.attr,
> + &dev_attr_sanitize_timeout.attr,
> NULL
> };
> ATTRIBUTE_GROUPS(cxl_mock_mem);
>
>
prev parent reply other threads:[~2023-10-13 17:25 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-06 7:25 [PATCH v3 00/10] cxl/mem: Fix shutdown order Dan Williams
2023-10-06 7:26 ` [PATCH v3 01/10] cxl/pci: Remove unnecessary device reference management in sanitize work Dan Williams
2023-10-06 7:26 ` [PATCH v3 02/10] cxl/pci: Cleanup 'sanitize' to always poll Dan Williams
2023-10-09 17:19 ` Davidlohr Bueso
2023-10-09 18:39 ` Dan Williams
2023-10-09 20:48 ` Davidlohr Bueso
2023-10-06 7:26 ` [PATCH v3 03/10] cxl/pci: Remove hardirq handler for cxl_request_irq() Dan Williams
2023-10-06 22:06 ` Davidlohr Bueso
2023-10-09 3:29 ` Ira Weiny
2023-10-09 16:36 ` Jonathan Cameron
2023-10-13 16:59 ` Dave Jiang
2023-10-06 7:26 ` [PATCH v3 04/10] cxl/pci: Remove inconsistent usage of dev_err_probe() Dan Williams
2023-10-06 22:10 ` Davidlohr Bueso
2023-10-09 3:42 ` Ira Weiny
2023-10-09 16:38 ` Jonathan Cameron
2023-10-13 17:09 ` Dave Jiang
2023-10-06 7:26 ` [PATCH v3 05/10] cxl/pci: Clarify devm host for memdev relative setup Dan Williams
2023-10-09 3:50 ` Ira Weiny
2023-10-09 16:41 ` Jonathan Cameron
2023-10-13 17:12 ` Dave Jiang
2023-10-06 7:26 ` [PATCH v3 06/10] cxl/pci: Fix sanitize notifier setup Dan Williams
2023-10-09 16:42 ` Jonathan Cameron
2023-10-09 18:08 ` Davidlohr Bueso
2023-10-06 7:26 ` [PATCH v3 07/10] cxl/memdev: Fix sanitize vs decoder setup locking Dan Williams
2023-10-06 10:10 ` kernel test robot
2023-10-09 4:17 ` Ira Weiny
2023-10-09 18:18 ` Dan Williams
2023-10-09 22:32 ` Dan Williams
2023-10-09 16:46 ` Jonathan Cameron
2023-10-09 18:36 ` Dan Williams
2023-10-11 20:44 ` Jonathan Cameron
2023-10-10 20:21 ` Davidlohr Bueso
2023-10-13 17:20 ` Dave Jiang
2023-10-06 7:26 ` [PATCH v3 08/10] cxl/mem: Fix shutdown order Dan Williams
2023-10-06 7:26 ` [PATCH v3 09/10] tools/testing/cxl: Make cxl_memdev_state available to other command emulation Dan Williams
2023-10-09 3:24 ` Ira Weiny
2023-10-13 17:21 ` Dave Jiang
2023-10-06 7:26 ` [PATCH v3 10/10] tools/testing/cxl: Add 'sanitize notifier' support Dan Williams
2023-10-09 4:25 ` Ira Weiny
2023-10-13 17:25 ` Dave Jiang [this message]
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=e8a085fe-303d-41b6-82da-4a79b5e735b0@intel.com \
--to=dave.jiang@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave@stgolabs.net \
--cc=linux-cxl@vger.kernel.org \
/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