From: alison.schofield@intel.com
To: 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>,
Steven Rostedt <rostedt@goodmis.org>,
Ingo Molnar <mingo@redhat.com>
Cc: Alison Schofield <alison.schofield@intel.com>,
linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] cxl/core: Add sysfs attribute get_poison for list retrieval
Date: Tue, 14 Jun 2022 17:10:28 -0700 [thread overview]
Message-ID: <57644934bb7af8e1c692735f53c2c415a1ba16d1.1655250669.git.alison.schofield@intel.com> (raw)
In-Reply-To: <cover.1655250669.git.alison.schofield@intel.com>
From: Alison Schofield <alison.schofield@intel.com>
The sysfs attribute, get_poison, allows user space to request the
retrieval of a CXL devices poison list for its persistent memory.
From Documentation/ABI/.../sysfs-bus-cxl
(WO) When a '1' is written to this attribute the memdev
driver retrieves the poison list from the device. The list
includes addresses that are poisoned or would result in
poison if accessed, and the source of the poison. This
attribute is only visible for devices supporting the
capability. The retrieved errors are logged as kernel
trace events with the label: cxl_poison_list.
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---
Documentation/ABI/testing/sysfs-bus-cxl | 13 ++++++++++
drivers/cxl/core/memdev.c | 32 +++++++++++++++++++++++++
2 files changed, 45 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-bus-cxl b/Documentation/ABI/testing/sysfs-bus-cxl
index 7c2b846521f3..9d0c3988fdd2 100644
--- a/Documentation/ABI/testing/sysfs-bus-cxl
+++ b/Documentation/ABI/testing/sysfs-bus-cxl
@@ -163,3 +163,16 @@ Description:
memory (type-3). The 'target_type' attribute indicates the
current setting which may dynamically change based on what
memory regions are activated in this decode hierarchy.
+
+What: /sys/bus/cxl/devices/memX/get_poison
+Date: June, 2022
+KernelVersion: v5.20
+Contact: linux-cxl@vger.kernel.org
+Description:
+ (WO) When a '1' is written to this attribute the memdev
+ driver retrieves the poison list from the device. The list
+ includes addresses that are poisoned or would result in
+ poison if accessed, and the source of the poison. This
+ attribute is only visible for devices supporting the
+ capability. The retrieved errors are logged as kernel
+ trace events with the label: cxl_poison_list.
diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
index f7cdcd33504a..5ef9ffaa934a 100644
--- a/drivers/cxl/core/memdev.c
+++ b/drivers/cxl/core/memdev.c
@@ -106,12 +106,34 @@ static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr,
}
static DEVICE_ATTR_RO(numa_node);
+static ssize_t get_poison_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t len)
+
+{
+ int rc;
+
+ if (!sysfs_streq(buf, "1")) {
+ dev_err(dev, "%s: unknown value: %s\n", attr->attr.name, buf);
+ return -EINVAL;
+ }
+
+ rc = cxl_mem_get_poison_list(dev);
+ if (rc) {
+ dev_err(dev, "Failed to retrieve poison list %d\n", rc);
+ return rc;
+ }
+ return len;
+}
+static DEVICE_ATTR_WO(get_poison);
+
static struct attribute *cxl_memdev_attributes[] = {
&dev_attr_serial.attr,
&dev_attr_firmware_version.attr,
&dev_attr_payload_max.attr,
&dev_attr_label_storage_size.attr,
&dev_attr_numa_node.attr,
+ &dev_attr_get_poison.attr,
NULL,
};
@@ -130,6 +152,16 @@ static umode_t cxl_memdev_visible(struct kobject *kobj, struct attribute *a,
{
if (!IS_ENABLED(CONFIG_NUMA) && a == &dev_attr_numa_node.attr)
return 0;
+
+ if (a == &dev_attr_get_poison.attr) {
+ struct device *dev = container_of(kobj, struct device, kobj);
+ struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
+ struct cxl_dev_state *cxlds = cxlmd->cxlds;
+
+ if (!test_bit(CXL_MEM_COMMAND_ID_GET_POISON,
+ cxlds->enabled_cmds))
+ return 0;
+ }
return a->mode;
}
--
2.31.1
next prev parent reply other threads:[~2022-06-15 0:11 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-15 0:10 [PATCH 0/3] CXL Poison List Retrieval & Tracing alison.schofield
2022-06-15 0:10 ` [PATCH 1/3] trace, cxl: Introduce a TRACE_EVENT for CXL Poison Records alison.schofield
2022-06-15 1:15 ` Steven Rostedt
2022-06-16 19:45 ` Davidlohr Bueso
2022-06-17 16:17 ` Jonathan Cameron
2022-06-17 18:04 ` Dan Williams
2022-06-15 0:10 ` [PATCH 2/3] cxl/mbox: Add GET_POISON_LIST mailbox command support alison.schofield
2022-06-15 3:22 ` Ira Weiny
2022-06-15 5:07 ` Alison Schofield
2022-06-15 15:01 ` Ira Weiny
2022-06-15 17:19 ` Alison Schofield
2022-06-16 19:43 ` Davidlohr Bueso
2022-06-16 20:34 ` Alison Schofield
2022-06-16 21:47 ` Davidlohr Bueso
2022-06-16 22:10 ` Alison Schofield
2022-06-16 22:20 ` Davidlohr Bueso
2022-06-16 22:45 ` Davidlohr Bueso
2022-06-16 23:15 ` Alison Schofield
2022-06-16 23:44 ` Verma, Vishal L
2022-06-17 0:03 ` Davidlohr Bueso
2022-06-17 19:02 ` Dan Williams
2022-06-20 10:53 ` Jonathan Cameron
2022-06-17 13:01 ` Jonathan Cameron
2022-06-17 14:05 ` Jonathan Cameron
2022-06-17 16:29 ` Alison Schofield
2022-06-17 17:29 ` Davidlohr Bueso
2022-06-17 19:32 ` Dan Williams
2022-06-20 10:56 ` Jonathan Cameron
2022-06-17 19:27 ` Dan Williams
2022-06-20 11:30 ` Jonathan Cameron
2022-06-17 18:26 ` Dan Williams
2022-06-15 0:10 ` alison.schofield [this message]
2022-06-15 3:30 ` [PATCH 3/3] cxl/core: Add sysfs attribute get_poison for list retrieval Ira Weiny
2022-06-16 15:04 ` Jonathan Cameron
2022-06-16 20:39 ` Alison Schofield
2022-06-17 18:42 ` Dan Williams
2022-06-18 0:21 ` Alison Schofield
2022-06-18 1:08 ` Dan Williams
2022-06-18 1:35 ` Alison Schofield
2022-06-17 17:52 ` [PATCH 0/3] CXL Poison List Retrieval & Tracing Dan Williams
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=57644934bb7af8e1c692735f53c2c415a1ba16d1.1655250669.git.alison.schofield@intel.com \
--to=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=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.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
all inboxes | Powered by JetHome®