linux-cxl.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: <alison.schofield@intel.com>
Cc: 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>,
	Dave Jiang <dave.jiang@intel.com>, <linux-cxl@vger.kernel.org>
Subject: Re: [PATCH v5 05/12] cxl/mem: Add debugfs attributes for poison inject and clear
Date: Thu, 30 Mar 2023 19:58:07 +0100	[thread overview]
Message-ID: <20230330195807.00007404@Huawei.com> (raw)
In-Reply-To: <b3844e5e940a100f32363f4a2e722ab6e415a96e.1679892337.git.alison.schofield@intel.com>

On Sun, 26 Mar 2023 22:03:11 -0700
alison.schofield@intel.com wrote:

> From: Alison Schofield <alison.schofield@intel.com>
> 
> Inject and Clear Poison commands are optionally supported by CXL
> memdev devices and are intended for use in debug environments only.
> Add debugfs attributes for user access.
> 
> Documentation/ABI/testing/debugfs-cxl describes the usage.
> 
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
> ---
>  Documentation/ABI/testing/debugfs-cxl | 36 +++++++++++++++++++++++++++
>  drivers/cxl/mem.c                     | 26 +++++++++++++++++++
>  2 files changed, 62 insertions(+)
>  create mode 100644 Documentation/ABI/testing/debugfs-cxl
> 
> diff --git a/Documentation/ABI/testing/debugfs-cxl b/Documentation/ABI/testing/debugfs-cxl
> new file mode 100644
> index 000000000000..3f1624f95f11
> --- /dev/null
> +++ b/Documentation/ABI/testing/debugfs-cxl
> @@ -0,0 +1,36 @@
> +What:		/sys/kernel/debug/cxl/memX/inject_poison
> +Date:		April, 2023
> +KernelVersion:	v6.4
> +Contact:	linux-cxl@vger.kernel.org
> +Description:
> +		(WO) When a Device Physical Address (DPA) is written to this
> +		attribute, the memdev driver sends an inject poison command to
> +		the device for the specified address. The DPA must be 64-byte
> +		aligned and the length of the injected poison is 64-bytes. If
> +		successful, the device returns poison when the address is
> +		accessed through the CXL.mem bus. Injecting poison adds the
> +		address to the device's Poison List and the error source is set
> +		to Injected. In addition, the device adds a poison creation
> +		event to its internal Informational Event log, updates the
> +		Event Status register, and if configured, interrupts the host.
> +		It is not an error to inject poison into an address that
> +		already has poison present and no error is returned. The
> +		inject_poison attribute is only visible for devices supporting
> +		the capability.
> +
> +
> +What:		/sys/kernel/debug/memX/clear_poison
> +Date:		April, 2023
> +KernelVersion:	v6.4
> +Contact:	linux-cxl@vger.kernel.org
> +Description:
> +		(WO) When a Device Physical Address (DPA) is written to this
> +		attribute, the memdev driver sends a clear poison command to
> +		the device for the specified address. Clearing poison removes
> +		the address from the device's Poison List and writes 0 (zero)
> +		for 64 bytes starting at address. It is not an error to clear
> +		poison from an address that does not have poison set, and if
> +		poison was not set, the address is not overwritten. If the
As in earlier patch. I don't think this statement is true.  The 64 bytes
at the address are always overwritten, whether or not there is poison.

Otherwise makes sense to hide these in debugfs given they are definitely for debug.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> +		device cannot clear poison from the address, -ENXIO is returned.
> +		The clear_poison attribute is only visible for devices
> +		supporting the capability.
> diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c
> index 576f5b691589..ff67ecf07001 100644
> --- a/drivers/cxl/mem.c
> +++ b/drivers/cxl/mem.c
> @@ -94,6 +94,22 @@ static int devm_cxl_add_endpoint(struct device *host, struct cxl_memdev *cxlmd,
>  	return 0;
>  }
>  
> +static int cxl_debugfs_poison_inject(void *data, u64 dpa)
> +{
> +	return cxl_inject_poison(data, dpa);
> +}
> +
> +DEFINE_DEBUGFS_ATTRIBUTE(cxl_poison_inject_fops, NULL,
> +			 cxl_debugfs_poison_inject, "%llx\n");
> +
> +static int cxl_debugfs_poison_clear(void *data, u64 dpa)
> +{
> +	return cxl_clear_poison(data, dpa);
> +}
> +
> +DEFINE_DEBUGFS_ATTRIBUTE(cxl_poison_clear_fops, NULL,
> +			 cxl_debugfs_poison_clear, "%llx\n");
> +
>  static int cxl_mem_probe(struct device *dev)
>  {
>  	struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
> @@ -117,6 +133,16 @@ static int cxl_mem_probe(struct device *dev)
>  
>  	dentry = cxl_debugfs_create_dir(dev_name(dev));
>  	debugfs_create_devm_seqfile(dev, "dpamem", dentry, cxl_mem_dpa_show);
> +
> +	if (test_bit(CXL_MEM_COMMAND_ID_INJECT_POISON,
> +		     to_cxl_memdev(dev)->cxlds->enabled_cmds))
> +		debugfs_create_file("inject_poison", 0200, dentry, dev,
> +				    &cxl_poison_inject_fops);
> +	if (test_bit(CXL_MEM_COMMAND_ID_CLEAR_POISON,
> +		     to_cxl_memdev(dev)->cxlds->enabled_cmds))
> +		debugfs_create_file("clear_poison", 0200, dentry, dev,
> +				    &cxl_poison_clear_fops);
> +
>  	rc = devm_add_action_or_reset(dev, remove_debugfs, dentry);
>  	if (rc)
>  		return rc;


  reply	other threads:[~2023-03-30 18:58 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 [this message]
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
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=20230330195807.00007404@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=alison.schofield@intel.com \
    --cc=bwidawsk@kernel.org \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@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).