From: Alison Schofield <alison.schofield@intel.com>
To: Ben Cheatham <Benjamin.Cheatham@amd.com>
Cc: <nvdimm@lists.linux.dev>, <linux-cxl@vger.kernel.org>,
<dave.jiang@intel.com>
Subject: Re: [PATCH v5 2/7] libcxl: Add CXL protocol errors
Date: Thu, 18 Dec 2025 20:38:46 -0800 [thread overview]
Message-ID: <aUTW1pvDvKMRqWPh@aschofie-mobl2.lan> (raw)
In-Reply-To: <20251215213630.8983-3-Benjamin.Cheatham@amd.com>
On Mon, Dec 15, 2025 at 03:36:25PM -0600, Ben Cheatham wrote:
snip
>
> +const struct cxl_protocol_error cxl_protocol_errors[] = {
> + CXL_PROTOCOL_ERROR(12, "cache-correctable"),
> + CXL_PROTOCOL_ERROR(13, "cache-uncorrectable"),
> + CXL_PROTOCOL_ERROR(14, "cache-fatal"),
> + CXL_PROTOCOL_ERROR(15, "mem-correctable"),
> + CXL_PROTOCOL_ERROR(16, "mem-uncorrectable"),
> + CXL_PROTOCOL_ERROR(17, "mem-fatal")
> +};
Can the above 'num' fields be the same nums as sysfs emits?
ie. s/12/0x00001000
Then no BIT(X) needed in the look ups and reads as more obvious
mapping from sysfs, where it looks like this:
0x00001000 CXL.cache Protocol Correctable
0x00002000 CXL.cache Protocol Uncorrectable non-fatal
0x00004000 CXL.cache Protocol Uncorrectable fatal
0x00008000 CXL.mem Protocol Correctable
0x00010000 CXL.mem Protocol Uncorrectable non-fatal
0x00020000 CXL.mem Protocol Uncorrectable fatal
A spec reference for those would be useful too.
I notice that the cxl list emit of einj_types reverses the order that
is presented in sysfs. Would be nice to match.
snip
> +
> +CXL_EXPORT int cxl_dport_protocol_error_inject(struct cxl_dport *dport,
> + unsigned int error)
> +{
> + struct cxl_ctx *ctx = dport->port->ctx;
> + char buf[32] = { 0 };
> + size_t path_len, len;
> + char *path;
> + int rc;
> +
> + if (!ctx->debugfs)
> + return -ENOENT;
> +
> + path_len = strlen(ctx->debugfs) + 100;
> + path = calloc(path_len, sizeof(char));
> + if (!path)
> + return -ENOMEM;
> +
> + len = snprintf(path, path_len, "%s/cxl/%s/einj_inject", ctx->debugfs,
> + cxl_dport_get_devname(dport));
> + if (len >= path_len) {
> + err(ctx, "%s: buffer too small\n", cxl_dport_get_devname(dport));
> + free(path);
> + return -ENOMEM;
> + }
> +
> + rc = access(path, F_OK);
> + if (rc) {
> + err(ctx, "failed to access %s: %s\n", path, strerror(errno));
> + free(path);
> + return -errno;
> + }
> +
> + len = snprintf(buf, sizeof(buf), "0x%lx\n", BIT(error));
> + if (len >= sizeof(buf)) {
> + err(ctx, "%s: buffer too small\n", cxl_dport_get_devname(dport));
> + free(path);
> + return -ENOMEM;
> + }
> +
> + rc = sysfs_write_attr(ctx, path, buf);
> + if (rc) {
> + err(ctx, "failed to write %s: %s\n", path, strerror(-rc));
> + free(path);
> + return -errno;
> + }
Coverity scan reports missing free(path) before return.
> +
> + return 0;
> +}
> +
next prev parent reply other threads:[~2025-12-19 4:39 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-15 21:36 [ndctl PATCH v5 0/7] Add error injection support Ben Cheatham
2025-12-15 21:36 ` [PATCH v5 1/7] libcxl: Add debugfs path to CXL context Ben Cheatham
2025-12-17 4:26 ` Alison Schofield
2025-12-17 19:55 ` Cheatham, Benjamin
2025-12-15 21:36 ` [PATCH v5 2/7] libcxl: Add CXL protocol errors Ben Cheatham
2025-12-17 4:31 ` Alison Schofield
2025-12-17 19:55 ` Cheatham, Benjamin
2025-12-19 4:38 ` Alison Schofield [this message]
2026-01-05 21:00 ` Cheatham, Benjamin
2025-12-15 21:36 ` [PATCH v5 3/7] libcxl: Add poison injection support Ben Cheatham
2025-12-15 21:36 ` [PATCH v5 4/7] cxl: Add inject-error command Ben Cheatham
2025-12-17 4:36 ` Alison Schofield
2025-12-17 19:56 ` Cheatham, Benjamin
2025-12-15 21:36 ` [PATCH v5 5/7] cxl: Add clear-error command Ben Cheatham
2025-12-17 4:39 ` Alison Schofield
2025-12-17 19:56 ` Cheatham, Benjamin
2025-12-15 21:36 ` [PATCH v5 6/7] cxl/list: Add injectable errors in output Ben Cheatham
2025-12-15 21:36 ` [PATCH v5 7/7] Documentation: Add docs for inject/clear-error commands Ben Cheatham
2025-12-17 4:42 ` Alison Schofield
2025-12-17 19:56 ` Cheatham, Benjamin
2025-12-19 4:52 ` Alison Schofield
2026-01-05 21:13 ` Cheatham, Benjamin
2026-01-06 4:41 ` Alison Schofield
2025-12-17 4:47 ` [ndctl PATCH v5 0/7] Add error injection support Alison Schofield
2025-12-17 19:56 ` Cheatham, Benjamin
2025-12-19 5:08 ` Alison Schofield
2026-01-05 21:14 ` Cheatham, Benjamin
2025-12-17 5:00 ` [ndctl PATCH] cxl/test: use inject and clear cmds in cxl-poison.sh Alison Schofield
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=aUTW1pvDvKMRqWPh@aschofie-mobl2.lan \
--to=alison.schofield@intel.com \
--cc=Benjamin.Cheatham@amd.com \
--cc=dave.jiang@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
/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