From: "Cheatham, Benjamin" <benjamin.cheatham@amd.com>
To: Alison Schofield <alison.schofield@intel.com>
Cc: <nvdimm@lists.linux.dev>, <linux-cxl@vger.kernel.org>,
<dave.jiang@intel.com>
Subject: Re: [PATCH v5 4/7] cxl: Add inject-error command
Date: Wed, 17 Dec 2025 13:56:02 -0600 [thread overview]
Message-ID: <474e2821-7ab4-4092-9376-87f311fab25b@amd.com> (raw)
In-Reply-To: <aUIzVWxpu_nHBKVo@aschofie-mobl2.lan>
On 12/16/2025 10:36 PM, Alison Schofield wrote:
> On Mon, Dec 15, 2025 at 03:36:27PM -0600, Ben Cheatham wrote:
>> Add the 'cxl-inject-error' command. This command will provide CXL
>> protocol error injection for CXL VH root ports and CXL RCH downstream
>> ports, as well as poison injection for CXL memory devices.
>>
>> Add util_cxl_dport_filter() to find downstream ports by either dport id
>> or device name.
>
> Does above comment match code? Does util_cxl_dport_filter() match by
> 'id' or 'name' ?
It should just be 'name'; I forgot to update the commit message from v4.
>
>
> snip
>
>> +#define EINJ_TYPES_BUF_SIZE 512
>
> above appears unused
It is, I replaced it with SYSFS_ATTR_SIZE IIRC. I'll remove it.
>
>
> snip
>
>> +static int poison_action(struct cxl_ctx *ctx, const char *filter,
>> + const char *addr_str)
>> +{
>> + struct cxl_memdev *memdev;
>> + size_t addr;
>> + int rc;
>> +
>> + memdev = find_cxl_memdev(ctx, filter);
>> + if (!memdev)
>> + return -ENODEV;
>> +
>> + if (!cxl_memdev_has_poison_injection(memdev)) {
>> + log_err(&iel, "%s does not support error injection\n",
>> + cxl_memdev_get_devname(memdev));
>> + return -EINVAL;
>> + }
>> +
>> + if (!addr_str) {
>> + log_err(&iel, "no address provided\n");
>> + return -EINVAL;
>> + }
>> +
>> + addr = strtoull(addr_str, NULL, 0);
>> + if (addr == ULLONG_MAX && errno == ERANGE) {
>> + log_err(&iel, "invalid address %s", addr_str);
>> + return -EINVAL;
>> + }
>
> errno best set to 0 before strtoull
> there is a type mismatch btw addr of size_t and strtoull
Got it, I'll fix those.
>
> snip
>
>> +static int inject_action(int argc, const char **argv, struct cxl_ctx *ctx,
>> + const struct option *options, const char *usage)
>> +{
>> + struct cxl_protocol_error *perr;
>> + const char * const u[] = {
>> + usage,
>> + NULL
>> + };
>> + int rc = -EINVAL;
>> +
>> + log_init(&iel, "cxl inject-error", "CXL_INJECT_LOG");
>> + argc = parse_options(argc, argv, options, u, 0);
>> +
>> + if (debug) {
>> + cxl_set_log_priority(ctx, LOG_DEBUG);
>> + iel.log_priority = LOG_DEBUG;
>> + } else {
>> + iel.log_priority = LOG_INFO;
>> + }
>> +
>> + if (argc != 1) {
>> + usage_with_options(u, options);
>> + return rc;
>> + }
>
> The above catches bad syntax like this where I omit type:
> # cxl inject-error mem10 -t -a 0x0
>
> We also need to catch this where I omit the option altogether:
> # cxl inject-error mem10 -a 0x0
> Segmentation fault (core dumped)
Good point. I'll change it to catch omitted required options as well.
>
>> +
>> + if (strcmp(inj_param.type, "poison") == 0) {
>> + rc = poison_action(ctx, argv[0], inj_param.address);
>> + return rc;
>> + }
>
> snip
>
next prev parent reply other threads:[~2025-12-17 21:29 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
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 [this message]
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=474e2821-7ab4-4092-9376-87f311fab25b@amd.com \
--to=benjamin.cheatham@amd.com \
--cc=alison.schofield@intel.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