From: Junhyeok Im <junhyeok.im@samsung.com>
To: linux-cxl@vger.kernel.org
Cc: dan.j.williams@intel.com, vishal.l.verma@intel.com,
bwidawsk@kernel.org, alison.schofield@intel.com,
Junhyeok Im <junhyeok.im@samsung.com>
Subject: [ndctl 1/3] libcxl: add memdev inject poison support
Date: Mon, 20 Feb 2023 13:57:07 +0900 [thread overview]
Message-ID: <20230220045709.94027-2-junhyeok.im@samsung.com> (raw)
In-Reply-To: <20230220045709.94027-1-junhyeok.im@samsung.com>
Add ability to inject poison based on the kernel inject poison sysfs interface.
This interface trigger inject poison function by writing DPA to the memory device
sysfs attribute ('inject_poison').
Link to corresponding kernel patchset:
https://lore.kernel.org/linux-cxl/cover.1674101475.git.alison.schofield@intel.com/
Signed-off-by: Junhyeok Im <junhyeok.im@samsung.com>
---
cxl/lib/libcxl.c | 26 ++++++++++++++++++++++++++
cxl/lib/libcxl.sym | 5 +++++
cxl/libcxl.h | 1 +
3 files changed, 32 insertions(+)
diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
index 4859bd5..d2b8e19 100644
--- a/cxl/lib/libcxl.c
+++ b/cxl/lib/libcxl.c
@@ -1407,6 +1407,32 @@ CXL_EXPORT int cxl_memdev_enable(struct cxl_memdev *memdev)
return 0;
}
+CXL_EXPORT int cxl_memdev_inject_poison(struct cxl_memdev *memdev,
+ const char *address)
+{
+ struct cxl_ctx *ctx = cxl_memdev_get_ctx(memdev);
+ char *path = memdev->dev_buf;
+ int len = memdev->buf_len, rc;
+
+ if (snprintf(path, len, "%s/inject_poison",
+ memdev->dev_path) >= len) {
+ err(ctx, "%s: buffer too small\n",
+ cxl_memdev_get_devname(memdev));
+ return -ENXIO;
+ }
+ rc = sysfs_write_attr(ctx, path, address);
+ if (rc < 0) {
+ fprintf(stderr, "%s: Failed write sysfs attr inject_poison\n",
+ cxl_memdev_get_devname(memdev));
+ return rc;
+ }
+
+ dbg(ctx, "%s: poison injected at %s\n", cxl_memdev_get_devname(memdev),
+ address);
+
+ return 0;
+}
+
static struct cxl_endpoint *cxl_port_find_endpoint(struct cxl_port *parent_port,
struct cxl_memdev *memdev)
{
diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym
index 6bc0810..c6ba248 100644
--- a/cxl/lib/libcxl.sym
+++ b/cxl/lib/libcxl.sym
@@ -242,3 +242,8 @@ global:
cxl_target_get_firmware_node;
cxl_dport_get_firmware_node;
} LIBCXL_3;
+
+LIBCXL_5 {
+global:
+ cxl_memdev_inject_poison;
+} LIBCXL_4;
diff --git a/cxl/libcxl.h b/cxl/libcxl.h
index d699af8..7a2cc5f 100644
--- a/cxl/libcxl.h
+++ b/cxl/libcxl.h
@@ -68,6 +68,7 @@ int cxl_memdev_read_label(struct cxl_memdev *memdev, void *buf, size_t length,
size_t offset);
int cxl_memdev_write_label(struct cxl_memdev *memdev, void *buf, size_t length,
size_t offset);
+int cxl_memdev_inject_poison(struct cxl_memdev *memdev, const char *address);
#define cxl_memdev_foreach(ctx, memdev) \
for (memdev = cxl_memdev_get_first(ctx); \
--
2.34.1
next prev parent reply other threads:[~2023-02-20 4:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20230220045604epcas2p3bc0b1fb688c48ec0b8ae2512adba3513@epcas2p3.samsung.com>
2023-02-20 4:57 ` [ndctl 0/3] Support for inject poison Junhyeok Im
2023-02-20 4:57 ` Junhyeok Im [this message]
2023-02-27 2:43 ` [ndctl 1/3] libcxl: add memdev inject poison support Alison Schofield
2023-02-20 4:57 ` [ndctl 2/3] cxl: add inject-poison command to cxl tool Junhyeok Im
2023-02-27 3:21 ` Alison Schofield
2023-02-28 9:43 ` Junhyeok Im
2023-03-01 19:01 ` Verma, Vishal L
2023-02-27 3:25 ` Alison Schofield
2023-02-28 9:45 ` Junhyeok Im
2023-02-20 4:57 ` [ndctl 3/3] Documentation: add man page documentation for inject-poison Junhyeok Im
2023-02-27 2:38 ` [ndctl 0/3] Support for inject poison Alison Schofield
2023-02-28 9:31 ` Junhyeok Im
2023-05-08 18:39 ` Verma, Vishal L
2023-05-09 9:19 ` Junhyeok Im
[not found] <CGME20230220013605epcas2p414e4f0c0c3c82bc5a004d19f4f02f15f@epcas2p4.samsung.com>
2023-02-20 1:37 ` [ndctl 1/3] libcxl: add memdev inject poison support junhyeok.im
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=20230220045709.94027-2-junhyeok.im@samsung.com \
--to=junhyeok.im@samsung.com \
--cc=alison.schofield@intel.com \
--cc=bwidawsk@kernel.org \
--cc=dan.j.williams@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