From: Alison Schofield <alison.schofield@intel.com>
To: nvdimm@lists.linux.dev
Cc: Alison Schofield <alison.schofield@intel.com>, linux-cxl@vger.kernel.org
Subject: [ndctl PATCH v2] test/cxl-region-sysfs.sh: test a repeat write of a region target
Date: Mon, 26 Oct 2026 09:24:15 -0700 [thread overview]
Message-ID: <20261026162419.584201-1-alison.schofield@intel.com> (raw)
A CXL driver fix making its way upstream[1], makes a repeat write of an
endpoint decoder to the region targetN attribute that already holds it
succeed without changing the region. Without the fix, that write fails,
leaves the region half detached from the endpoint's ports, and a later
write can crash the kernel.
Add a test case to backstop that fix. Write target0 twice on a partially
populated region and check that the second write succeeds and leaves the
region's decoders attached.
[1] https://lore.kernel.org/linux-cxl/920d80735a449f93a1f17a8bca4c25e4b302cb42.1792989098.git.alison.schofield@intel.com/
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---
Changes since v1:
- Expect a repeat write to succeed, as the v2 kernel fix makes it a no-op
test/cxl-region-sysfs.sh | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/test/cxl-region-sysfs.sh b/test/cxl-region-sysfs.sh
index db1a163efb30..cb5e6ba53e71 100644
--- a/test/cxl-region-sysfs.sh
+++ b/test/cxl-region-sysfs.sh
@@ -87,9 +87,19 @@ do
select(.mode == \"pmem\") | .decoder")
done
-# attach all endpoint decoders to the region
-pos=0
-for i in ${endpoint[@]}
+# a repeat write of an attached endpoint decoder must succeed and leave
+# every decoder between it and the root attached
+echo "${endpoint[0]}" > "/sys/bus/cxl/devices/$region/target0"
+nr_attached=$(cat /sys/bus/cxl/devices/decoder*/region | grep -cx "$region")
+if ! echo "${endpoint[0]}" > "/sys/bus/cxl/devices/$region/target0"; then
+ err "$LINENO: repeat write of ${endpoint[0]} to target0 failed"
+fi
+nr=$(cat /sys/bus/cxl/devices/decoder*/region | grep -cx "$region")
+[ "$nr" -ne "$nr_attached" ] && err "$LINENO: $nr of $nr_attached decoders still attached"
+
+# attach the remaining endpoint decoders to the region
+pos=1
+for i in ${endpoint[@]:1}
do
echo $i > /sys/bus/cxl/devices/$region/target$pos
pos=$((pos+1))
--
2.37.3
reply other threads:[~2026-10-26 16:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261026162419.584201-1-alison.schofield@intel.com \
--to=alison.schofield@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