Skip to contentSkip to conversation

test/cxl-topology.sh: test zero-sized decoders

PATCH In review Richard Cheng 2 participants 2 messages Jul 9 – Jul 31 libnvdimm: non-volatile memory device

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test/cxl-topology.sh: test zero-sized decoders

The kernel series [1] teaches the CXL core to enumerate committed zero-sized HDM decoders and adds the opt-in mock_zero_size_decoders cxl_test topology. Since the param defaults off, the existing ndctl suite never exercises that path, leaving the series without userspace regression coverage.

After the existing default-topology checks, detect the module param with modinfo. When available, reload cxl_test with mock_zero_size_decoders=1, discover both endpoint decoders through the auto-region mapping, and verify that decoder IDs 1 and 2 exist with size 0 and locked set. Unsupported kernels retain the existing baseline coverage.

Tested on arm64. The focused test passed. The full CXL suite passed and 1 unrelated cxl-security skip. Four zero-sized endpoint decoders were validated, cxl_test unloaded cleanly, and no relevant dmesg errors were shown.

[1]:
https://lore.kernel.org/linux-cxl/[email protected]/

---
 test/cxl-topology.sh | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
test/cxl-topology.sh +32 -0
index 170c9ca..3345cd8 100644
@@ -276,3 +276,35 @@ $CXL disable-bus $root -f
 check_dmesg "$LINENO"
 
 modprobe -r cxl_test
+
+if ! modinfo cxl_test | grep -q '^parm:.*mock_zero_size_decoders'; then
+	exit 0
+fi
+
+modprobe cxl_test mock_zero_size_decoders=1
+
+region_json=$("$CXL" list -b cxl_test -R -T -u)
+[ -n "$region_json" ] || err "$LINENO"
+mapfile -t endpoint_decoders < <(
+	jq -r '.mappings[]?.decoder // empty' <<<"$region_json"
+)
+((${#endpoint_decoders[@]} == 2)) || err "$LINENO"
+
+for decoder in "${endpoint_decoders[@]}"; do
+	[[ "$decoder" == *.0 ]] || err "$LINENO"
+
+	for id in 1 2; do
+		empty_decoder="${decoder%.*}.$id"
+		decoder_path="/sys/bus/cxl/devices/$empty_decoder"
+		[ -d "$decoder_path" ] || err "$LINENO"
+
+		size=$(cat "$decoder_path/size")
+		locked=$(cat "$decoder_path/locked")
+		((size == 0)) || err "$LINENO"
+		((locked == 1)) || err "$LINENO"
+	done
+done
+
+check_dmesg "$LINENO"
+
+modprobe -r cxl_test

base-commit: 15e932c4e1318a9608ad9b799ad83a32a8b5970d
prerequisite-patch-id: 96641092f7122fa9b6a894ab56f71c4d50c02650

Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 12 lines · Richard Cheng

The kernel series [1] teaches the CXL core to enumerate committed zero-sized HDM decoders and adds the opt-in mock_zero_size_decoders cxl_test topology. Since the param defaults off, the existing ndctl suite never exercises that path, leaving the series without userspace regression coverage.

After the existing default-topology checks, detect the module param with modinfo. When available, reload cxl_test with mock_zero_size_decoders=1, discover both endpoint decoders through the auto-region mapping, and verify that decoder IDs 1 and 2 exist with size 0 and locked set. Unsupported kernels retain the existing baseline coverage.

Quoted 8 lines

Tested on arm64. The focused test passed. The full CXL suite passed and 1 unrelated cxl-security skip. Four zero-sized endpoint decoders were validated, cxl_test unloaded cleanly, and no relevant dmesg errors were shown.

[1]:
https://lore.kernel.org/linux-cxl/[email protected]/

Applied w some minor edits:
[as: move new work to a function and add code comments]
https://github.com/pmem/ndctl/commit/02754b5c4b60

Richard - This got me thinking about how we display these with 'cxl list'. Please take a look at my follow patches.