Linux CXL
 help / color / mirror / Atom feed
* [ndctl PATCH] test/cxl-region-sysfs.sh: test a repeat write of a region target
@ 2026-10-01  5:15 Alison Schofield
  0 siblings, 0 replies; only message in thread
From: Alison Schofield @ 2026-10-01  5:15 UTC (permalink / raw)
  To: nvdimm, linux-cxl; +Cc: Alison Schofield

A CXL driver fix making its way upstream [1] rejects a repeat write of
an endpoint decoder to the region targetN attribute that already holds
it. Without the fix, that write 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 fails and leaves the
region's decoders attached.

[1] https://lore.kernel.org/all/94e9157aac2e99df1251d733769d539b914fdefc.1790829690.git.alison.schofield@intel.com/


Assisted-by: LLM
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---
 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..957a1792fbd7 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 fail 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" 2>/dev/null; then
+	err "$LINENO: repeat write of ${endpoint[0]} to target0 succeeded"
+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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-01  5:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-01  5:15 [ndctl PATCH] test/cxl-region-sysfs.sh: test a repeat write of a region target Alison Schofield

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox