public inbox for nvdimm@lists.linux.dev
 help / color / mirror / Atom feed
* [NDCTL PATCH 0/5] cxl: Add tests for extended linear cache support
@ 2025-10-31 17:39 Dave Jiang
  2025-10-31 17:39 ` [NDCTL PATCH 1/5] cxl/test: Add test " Dave Jiang
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Dave Jiang @ 2025-10-31 17:39 UTC (permalink / raw)
  To: linux-cxl, nvdimm
  Cc: dave, jonathan.cameron, alison.schofield, vishal.l.verma,
	ira.weiny, dan.j.williams

The series adds unit tests to verify the kernel support for extended
linear cache (ELC). Added a test to check if the ELC region is setup
correctly, and another test to go through the poison handling flow
via the poison injection testing.


Dave Jiang (5):
  cxl/test: Add test for extended linear cache support
  cxl/test: Fix cxl-poison.sh to detect the correct elc sysfs attrib
  cxl/test: Move cxl-poison.sh to use cxl_test auto region
  cxl/test: Move common part of poison unit test to common file
  cxl/test: Add support for poison test for ELC

 test/common-poison     | 202 ++++++++++++++++++++++++++++++++++++++++
 test/cxl-elc.sh        |  89 ++++++++++++++++++
 test/cxl-poison-elc.sh |  41 +++++++++
 test/cxl-poison.sh     | 203 +----------------------------------------
 test/meson.build       |   4 +
 5 files changed, 338 insertions(+), 201 deletions(-)
 create mode 100644 test/common-poison
 create mode 100755 test/cxl-elc.sh
 create mode 100755 test/cxl-poison-elc.sh


base-commit: 01c90830d65b6b331986f5996dcf6ad73c1579f4
-- 
2.51.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [NDCTL PATCH 1/5] cxl/test: Add test for extended linear cache support
  2025-10-31 17:39 [NDCTL PATCH 0/5] cxl: Add tests for extended linear cache support Dave Jiang
@ 2025-10-31 17:39 ` Dave Jiang
  2025-11-15  1:00   ` Alison Schofield
  2025-11-15  2:54   ` Alison Schofield
  2025-10-31 17:40 ` [NDCTL PATCH 2/5] cxl/test: Fix cxl-poison.sh to detect the correct elc sysfs attrib Dave Jiang
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 12+ messages in thread
From: Dave Jiang @ 2025-10-31 17:39 UTC (permalink / raw)
  To: linux-cxl, nvdimm
  Cc: dave, jonathan.cameron, alison.schofield, vishal.l.verma,
	ira.weiny, dan.j.williams

Add a unit test that verifies the extended linear cache setup paths
in the kernel driver. cxl_test provides a mock'd version. The test
verifies the sysfs attribute that indicates extended linear cache support
is correctly reported. It also verifies the sizing and offset of the
regions and decoders.

The expecation is that CFMWS covers the entire extended linear cache
region. The first part is DRAM and second part is CXL memory in a 1:1
setup. The start base for hardware decoders should be offsetted by the
DRAM size.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 test/cxl-elc.sh  | 89 ++++++++++++++++++++++++++++++++++++++++++++++++
 test/meson.build |  2 ++
 2 files changed, 91 insertions(+)
 create mode 100755 test/cxl-elc.sh

diff --git a/test/cxl-elc.sh b/test/cxl-elc.sh
new file mode 100755
index 000000000000..632e859c21f3
--- /dev/null
+++ b/test/cxl-elc.sh
@@ -0,0 +1,89 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2025 Intel Corporation. All rights reserved.
+
+. "$(dirname "$0")"/common
+
+rc=77
+
+set -ex
+[ -d "/sys/kernel/tracing" ] || do_skip "test requires CONFIG_TRACING"
+
+trap 'err $LINENO' ERR
+
+check_prereq "jq"
+
+modprobe -r cxl_test
+modprobe cxl_test extended_linear_cache=1
+
+rc=1
+
+find_region()
+{
+	json="$($CXL list -b cxl_test -R)"
+	region=$(echo "$json" | jq -r '.[] | select(has("extended_linear_cache_size") and .extended_linear_cache_size != null) | .region')
+	[[ -n "$region" && "$region" != "null" ]] || do_skip "no test extended linear cache region found"
+}
+
+retrieve_info()
+{
+	# Root decoder name
+	cxlrd="$($CXL list -r$region -D | jq -r '.[] | select(has("root decoders")) | ."root decoders"[0].decoder')"
+	# Root decoder (CFMWS) window size
+	cxlrd_size="$($CXL list -b cxl_test -d $cxlrd | jq '.[0]."decoders:root0"[0].size')"
+	# Root decoder (CFMWS) window address base
+	cxlrd_hpa="$($CXL list -b cxl_test -r $region | jq '.[0]."regions:root0"[0].resource')"
+
+	# Region size
+	region_size="$($CXL list -b cxl_test -r $region | jq '.[0]."regions:root0"[0].size')"
+
+	# switch port 0 size
+	swp0_size="$($CXL list -r $region -D | jq '.[] | select(has("port decoders")) | ."port decoders"[0] | .size')"
+	# switch port 0 base address
+	swp0_hpa="$($CXL list -r $region -D | jq '.[] | select(has("port decoders")) | ."port decoders"[0] | .resource')"
+
+	# switch port 1 size
+	swp1_size="$($CXL list -r $region -D | jq '.[] | select(has("port decoders")) | ."port decoders"[1] | .size')"
+	# switch port 1 base address
+	swp1_hpa="$($CXL list -r $region -D | jq '.[] | select(has("port decoders")) | ."port decoders"[1] | .resource')"
+
+	# endpoint port 0 size
+	ep0_size="$($CXL list -r $region -D | jq '.[] | select(has("endpoint decoders")) | ."endpoint decoders"[0] | .size')"
+	# endpoint port 0 base address
+	ep0_hpa="$($CXL list -r $region -D | jq '.[] | select(has("endpoint decoders")) | ."endpoint decoders"[0] | .resource')"
+
+	# endpoint port 1 size
+	ep1_size="$($CXL list -r $region -D | jq '.[] | select(has("endpoint decoders")) | ."endpoint decoders"[1] | .size')"
+	# endpoint port 1 base address
+	ep1_hpa="$($CXL list -r $region -D | jq '.[] | select(has("endpoint decoders")) | ."endpoint decoders"[1] | .resource')"
+}
+
+compare_sizes()
+{
+	# The CXL region size should equal to the CFMWS size.
+	# It should be DRAM+CXL size combined
+	((cxlrd_size == region_size)) || err "$LINENO"
+
+	# The switch decoder size should be half of CFMWS size.
+	((cxlrd_size == swp0_size * 2)) || err "$LINENO"
+	((cxlrd_size == swp1_size * 2)) || err "$LINENO"
+
+	# The endpoint decoder size should be half of CFMWS size
+	((cxlrd_size == ep0_size * 2)) || err "$LINENO"
+	((cxlrd_size == ep1_size * 2)) || err "$LINENO"
+}
+
+# The extended linear cache is expected to be DRAM:CXL of 1:1 size
+# The CXL region occupies the second half of the CFMWS
+compare_bases()
+{
+	((cxlrd_hpa == swp0_hpa - swp0_size)) || err "$LINENO"
+	((cxlrd_hpa == swp1_hpa - swp1_size)) || err "$LINENO"
+
+	((cxlrd_hpa == ep0_hpa - ep0_size)) || err "$LINENO"
+	((cxlrd_hpa == ep1_hpa - ep1_size)) || err "$LINENO"
+}
+
+retrieve_info
+compare_sizes
+compare_bases
diff --git a/test/meson.build b/test/meson.build
index 615376ea635a..710a15850e2b 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -167,6 +167,7 @@ cxl_events = find_program('cxl-events.sh')
 cxl_sanitize = find_program('cxl-sanitize.sh')
 cxl_destroy_region = find_program('cxl-destroy-region.sh')
 cxl_qos_class = find_program('cxl-qos-class.sh')
+cxl_elc = find_program('cxl-elc.sh')
 
 tests = [
   [ 'libndctl',               libndctl,		  'ndctl' ],
@@ -199,6 +200,7 @@ tests = [
   [ 'cxl-sanitize.sh',        cxl_sanitize,       'cxl'   ],
   [ 'cxl-destroy-region.sh',  cxl_destroy_region, 'cxl'   ],
   [ 'cxl-qos-class.sh',       cxl_qos_class,      'cxl'   ],
+  [ 'cxl-elc.sh',             cxl_elc,            'cxl'   ],
 ]
 
 if get_option('destructive').enabled()
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [NDCTL PATCH 2/5] cxl/test: Fix cxl-poison.sh to detect the correct elc sysfs attrib
  2025-10-31 17:39 [NDCTL PATCH 0/5] cxl: Add tests for extended linear cache support Dave Jiang
  2025-10-31 17:39 ` [NDCTL PATCH 1/5] cxl/test: Add test " Dave Jiang
@ 2025-10-31 17:40 ` Dave Jiang
  2025-11-15  0:54   ` Alison Schofield
  2025-10-31 17:40 ` [NDCTL PATCH 3/5] cxl/test: Move cxl-poison.sh to use cxl_test auto region Dave Jiang
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Dave Jiang @ 2025-10-31 17:40 UTC (permalink / raw)
  To: linux-cxl, nvdimm
  Cc: dave, jonathan.cameron, alison.schofield, vishal.l.verma,
	ira.weiny, dan.j.williams

The cxl-poison.sh script attempts to read the extended linear cache
size sysfs attribute but is using the incorrect attribute name.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 test/cxl-poison.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/cxl-poison.sh b/test/cxl-poison.sh
index 231a0733f096..8e81baceeb24 100644
--- a/test/cxl-poison.sh
+++ b/test/cxl-poison.sh
@@ -197,8 +197,8 @@ test_poison_by_region_offset_negative()
 
 	# This case is a no-op until cxl-test ELC mocking arrives
 	# Try to get cache_size if the attribute exists
-	if [ -f "/sys/bus/cxl/devices/$region/cache_size" ]; then
-		cache_size=$(cat /sys/bus/cxl/devices/"$region"/cache_size)
+	if [ -f "/sys/bus/cxl/devices/$region/extended_linear_cache_size" ]; then
+		cache_size=$(cat /sys/bus/cxl/devices/"$region"/extended_linear_cache_size)
 	fi
 
 	# Offset within extended linear cache (if cache_size > 0)
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [NDCTL PATCH 3/5] cxl/test: Move cxl-poison.sh to use cxl_test auto region
  2025-10-31 17:39 [NDCTL PATCH 0/5] cxl: Add tests for extended linear cache support Dave Jiang
  2025-10-31 17:39 ` [NDCTL PATCH 1/5] cxl/test: Add test " Dave Jiang
  2025-10-31 17:40 ` [NDCTL PATCH 2/5] cxl/test: Fix cxl-poison.sh to detect the correct elc sysfs attrib Dave Jiang
@ 2025-10-31 17:40 ` Dave Jiang
  2025-11-15  1:07   ` Alison Schofield
  2025-10-31 17:40 ` [NDCTL PATCH 4/5] cxl/test: Move common part of poison unit test to common file Dave Jiang
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Dave Jiang @ 2025-10-31 17:40 UTC (permalink / raw)
  To: linux-cxl, nvdimm
  Cc: dave, jonathan.cameron, alison.schofield, vishal.l.verma,
	ira.weiny, dan.j.williams

Move cxl-poison.sh to use the cxl_test auto region instead of manually
create an additional region. This is in preparation to allow utilize
the existing poison unit tests to also test the extended linear cache
region.

The offset has been changed due to the auto region starts at 0 and pmem
region starts at 0x40000000. The original test was creating a pmem
region. It makes no difference what type of region is being used for
testing.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 test/cxl-poison.sh | 38 ++++++++++++--------------------------
 1 file changed, 12 insertions(+), 26 deletions(-)

diff --git a/test/cxl-poison.sh b/test/cxl-poison.sh
index 8e81baceeb24..430780cf7128 100644
--- a/test/cxl-poison.sh
+++ b/test/cxl-poison.sh
@@ -35,28 +35,14 @@ find_memdev()
 	memdev=${capable_mems[0]}
 }
 
-create_x2_region()
+find_auto_region()
 {
-	# Find an x2 decoder
-	decoder="$($CXL list -b "$CXL_TEST_BUS" -D -d root | jq -r ".[] |
-		select(.pmem_capable == true) |
-		select(.nr_targets == 2) |
-		.decoder")"
-
-	# Find a memdev for each host-bridge interleave position
-	port_dev0="$($CXL list -T -d "$decoder" | jq -r ".[] |
-		.targets | .[] | select(.position == 0) | .target")"
-	port_dev1="$($CXL list -T -d "$decoder" | jq -r ".[] |
-		.targets | .[] | select(.position == 1) | .target")"
-	mem0="$($CXL list -M -p "$port_dev0" | jq -r ".[0].memdev")"
-	mem1="$($CXL list -M -p "$port_dev1" | jq -r ".[0].memdev")"
-
-	region="$($CXL create-region -d "$decoder" -m "$mem0" "$mem1" |
-		jq -r ".region")"
-	if [[ ! $region ]]; then
-		echo "create-region failed for $decoder"
-		err "$LINENO"
-	fi
+	region="$($CXL list -b "$CXL_TEST_BUS" -R | jq -r ".[0].region")"
+	[[ -n "$region" && "$region" != "null" ]] || do_skip "no test region found"
+	mem0="$($CXL list -r "$region" --targets | jq -r ".[0].mappings[0].memdev")"
+	[[ -n "$mem0" && "$mem0" != "null" ]] || do_skip "no region target0 found"
+	mem1="$($CXL list -r "$region" --targets | jq -r ".[0].mappings[1].memdev")"
+	[[ -n "$mem1" && "$mem1" != "null" ]] || do_skip "no region target1 found"
 	echo "$region"
 }
 
@@ -153,12 +139,12 @@ test_poison_by_memdev_by_dpa()
 
 test_poison_by_region_by_dpa()
 {
-	inject_poison_sysfs "$mem0" "0x40000000"
-	inject_poison_sysfs "$mem1" "0x40000000"
+	inject_poison_sysfs "$mem0" "0"
+	inject_poison_sysfs "$mem1" "0"
 	validate_poison_found "-r $region" 2
 
-	clear_poison_sysfs "$mem0" "0x40000000"
-	clear_poison_sysfs "$mem1" "0x40000000"
+	clear_poison_sysfs "$mem0" "0"
+	clear_poison_sysfs "$mem1" "0"
 	validate_poison_found "-r $region" 0
 }
 
@@ -228,7 +214,7 @@ echo 1 > /sys/kernel/tracing/events/cxl/cxl_poison/enable
 echo 1 > /sys/kernel/tracing/tracing_on
 
 test_poison_by_memdev_by_dpa
-create_x2_region
+find_auto_region
 test_poison_by_region_by_dpa
 [ -f "/sys/kernel/debug/cxl/$region/inject_poison" ] ||
        do_skip "test cases requires inject by region kernel support"
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [NDCTL PATCH 4/5] cxl/test: Move common part of poison unit test to common file
  2025-10-31 17:39 [NDCTL PATCH 0/5] cxl: Add tests for extended linear cache support Dave Jiang
                   ` (2 preceding siblings ...)
  2025-10-31 17:40 ` [NDCTL PATCH 3/5] cxl/test: Move cxl-poison.sh to use cxl_test auto region Dave Jiang
@ 2025-10-31 17:40 ` Dave Jiang
  2025-10-31 17:40 ` [NDCTL PATCH 5/5] cxl/test: Add support for poison test for ELC Dave Jiang
  2025-11-15  1:20 ` [NDCTL PATCH 0/5] cxl: Add tests for extended linear cache support Alison Schofield
  5 siblings, 0 replies; 12+ messages in thread
From: Dave Jiang @ 2025-10-31 17:40 UTC (permalink / raw)
  To: linux-cxl, nvdimm
  Cc: dave, jonathan.cameron, alison.schofield, vishal.l.verma,
	ira.weiny, dan.j.williams

To allow extended linear cache to also utilize the poison test, move
the common helper functions to a common file for sourcing.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 test/common-poison | 190 +++++++++++++++++++++++++++++++++++++++++++++
 test/cxl-poison.sh | 187 +-------------------------------------------
 2 files changed, 191 insertions(+), 186 deletions(-)
 create mode 100644 test/common-poison

diff --git a/test/common-poison b/test/common-poison
new file mode 100644
index 000000000000..15a091e41dc3
--- /dev/null
+++ b/test/common-poison
@@ -0,0 +1,190 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2025 Intel Corporation. All rights reserved.
+
+find_memdev()
+{
+	readarray -t capable_mems < <("$CXL" list -b "$CXL_TEST_BUS" -M |
+		jq -r ".[] | select(.pmem_size != null) |
+		select(.ram_size != null) | .memdev")
+
+	if [ ${#capable_mems[@]} == 0 ]; then
+		echo "no memdevs found for test"
+		err "$LINENO"
+	fi
+
+	memdev=${capable_mems[0]}
+}
+
+find_auto_region()
+{
+	region="$($CXL list -b "$CXL_TEST_BUS" -R | jq -r ".[0].region")"
+	[[ -n "$region" && "$region" != "null" ]] || do_skip "no test region found"
+	mem0="$($CXL list -r "$region" --targets | jq -r ".[0].mappings[0].memdev")"
+	[[ -n "$mem0" && "$mem0" != "null" ]] || do_skip "no region target0 found"
+	mem1="$($CXL list -r "$region" --targets | jq -r ".[0].mappings[1].memdev")"
+	[[ -n "$mem1" && "$mem1" != "null" ]] || do_skip "no region target1 found"
+	echo "$region"
+}
+
+# When cxl-cli support for inject and clear arrives, replace
+# the writes to /sys/kernel/debug with the new cxl commands.
+
+_do_poison_sysfs()
+{
+	local action="$1" dev="$2" addr="$3"
+	local expect_fail=${4:-false}
+
+	if "$expect_fail"; then
+		if echo "$addr" > "/sys/kernel/debug/cxl/$dev/${action}_poison"; then
+			echo "Expected ${action}_poison to fail for $addr"
+			err "$LINENO"
+		fi
+	else
+		echo "$addr" > "/sys/kernel/debug/cxl/$dev/${action}_poison"
+	fi
+}
+
+inject_poison_sysfs()
+{
+	_do_poison_sysfs 'inject' "$@"
+}
+
+clear_poison_sysfs()
+{
+	_do_poison_sysfs 'clear' "$@"
+}
+
+check_trace_entry()
+{
+	local expected_region="$1"
+	local expected_hpa="$2"
+
+	local trace_line
+	trace_line=$(grep "cxl_poison" /sys/kernel/tracing/trace | tail -n 1)
+	if [[ -z "$trace_line" ]]; then
+		echo "No cxl_poison trace event found"
+		err "$LINENO"
+	fi
+
+	local trace_region trace_hpa
+	trace_region=$(echo "$trace_line" | grep -o 'region=[^ ]*' | cut -d= -f2)
+	trace_hpa=$(echo "$trace_line" | grep -o 'hpa=0x[0-9a-fA-F]\+' | cut -d= -f2)
+
+	if [[ "$trace_region" != "$expected_region" ]]; then
+		echo "Expected region $expected_region not found in trace"
+		echo "$trace_line"
+		err "$LINENO"
+	fi
+
+	if [[ "$trace_hpa" != "$expected_hpa" ]]; then
+		echo "Expected HPA $expected_hpa not found in trace"
+		echo "$trace_line"
+		err "$LINENO"
+	fi
+}
+
+validate_poison_found()
+{
+	list_by="$1"
+	nr_expect="$2"
+
+	poison_list="$($CXL list "$list_by" --media-errors |
+		jq -r '.[].media_errors')"
+	if [[ ! $poison_list ]]; then
+		nr_found=0
+	else
+		nr_found=$(jq "length" <<< "$poison_list")
+	fi
+	if [ "$nr_found" -ne "$nr_expect" ]; then
+		echo "$nr_expect poison records expected, $nr_found found"
+		err "$LINENO"
+	fi
+}
+
+test_poison_by_memdev_by_dpa()
+{
+	find_memdev
+	inject_poison_sysfs "$memdev" "0x40000000"
+	inject_poison_sysfs "$memdev" "0x40001000"
+	inject_poison_sysfs "$memdev" "0x600"
+	inject_poison_sysfs "$memdev" "0x0"
+	validate_poison_found "-m $memdev" 4
+
+	clear_poison_sysfs "$memdev" "0x40000000"
+	clear_poison_sysfs "$memdev" "0x40001000"
+	clear_poison_sysfs "$memdev" "0x600"
+	clear_poison_sysfs "$memdev" "0x0"
+	validate_poison_found "-m $memdev" 0
+}
+
+test_poison_by_region_by_dpa()
+{
+	inject_poison_sysfs "$mem0" "0"
+	inject_poison_sysfs "$mem1" "0"
+	validate_poison_found "-r $region" 2
+
+	clear_poison_sysfs "$mem0" "0"
+	clear_poison_sysfs "$mem1" "0"
+	validate_poison_found "-r $region" 0
+}
+
+test_poison_by_region_offset()
+{
+	local base gran hpa1 hpa2
+	base=$(cat /sys/bus/cxl/devices/"$region"/resource)
+	gran=$(cat /sys/bus/cxl/devices/"$region"/interleave_granularity)
+
+	# Test two HPA addresses: base and base + granularity
+	# This hits the two memdevs in the region interleave.
+	hpa1=$(printf "0x%x" $((base)))
+	hpa2=$(printf "0x%x" $((base + gran)))
+
+	# Inject at the offset and check result using the hpa
+	# ABI takes an offset, but recall the hpa to check trace event
+
+	inject_poison_sysfs "$region" 0
+	check_trace_entry "$region" "$hpa1"
+	inject_poison_sysfs "$region" "$gran"
+	check_trace_entry "$region" "$hpa2"
+	validate_poison_found "-r $region" 2
+
+	clear_poison_sysfs "$region" 0
+	check_trace_entry "$region" "$hpa1"
+	clear_poison_sysfs "$region" "$gran"
+	check_trace_entry "$region" "$hpa2"
+	validate_poison_found "-r $region" 0
+}
+
+test_poison_by_region_offset_negative()
+{
+	local region_size cache_size cache_offset exceed_offset large_offset
+	region_size=$(cat /sys/bus/cxl/devices/"$region"/size)
+	cache_size=0
+
+	# This case is a no-op until cxl-test ELC mocking arrives
+	# Try to get cache_size if the attribute exists
+	if [ -f "/sys/bus/cxl/devices/$region/extended_linear_cache_size" ]; then
+		cache_size=$(cat /sys/bus/cxl/devices/"$region"/extended_linear_cache_size)
+	fi
+
+	# Offset within extended linear cache (if cache_size > 0)
+	if [[ $cache_size -gt 0 ]]; then
+		cache_offset=$((cache_size - 1))
+		echo "Testing offset within cache: $cache_offset (cache_size: $cache_size)"
+		inject_poison_sysfs "$region" "$cache_offset" true
+		clear_poison_sysfs "$region" "$cache_offset" true
+	else
+		echo "Skipping cache test - cache_size is 0"
+	fi
+
+	# Offset exceeds region size
+	exceed_offset=$((region_size))
+	inject_poison_sysfs "$region" "$exceed_offset" true
+	clear_poison_sysfs "$region" "$exceed_offset" true
+
+	# Offset exceeds region size by a lot
+	large_offset=$((region_size * 2))
+	inject_poison_sysfs "$region" "$large_offset" true
+	clear_poison_sysfs "$region" "$large_offset" true
+}
+
diff --git a/test/cxl-poison.sh b/test/cxl-poison.sh
index 430780cf7128..b4caec0af12a 100644
--- a/test/cxl-poison.sh
+++ b/test/cxl-poison.sh
@@ -21,192 +21,7 @@ rc=1
 # THEORY OF OPERATION: Exercise cxl-cli and cxl driver ability to
 # inject, clear, and get the poison list. Do it by memdev and by region.
 
-find_memdev()
-{
-	readarray -t capable_mems < <("$CXL" list -b "$CXL_TEST_BUS" -M |
-		jq -r ".[] | select(.pmem_size != null) |
-		select(.ram_size != null) | .memdev")
-
-	if [ ${#capable_mems[@]} == 0 ]; then
-		echo "no memdevs found for test"
-		err "$LINENO"
-	fi
-
-	memdev=${capable_mems[0]}
-}
-
-find_auto_region()
-{
-	region="$($CXL list -b "$CXL_TEST_BUS" -R | jq -r ".[0].region")"
-	[[ -n "$region" && "$region" != "null" ]] || do_skip "no test region found"
-	mem0="$($CXL list -r "$region" --targets | jq -r ".[0].mappings[0].memdev")"
-	[[ -n "$mem0" && "$mem0" != "null" ]] || do_skip "no region target0 found"
-	mem1="$($CXL list -r "$region" --targets | jq -r ".[0].mappings[1].memdev")"
-	[[ -n "$mem1" && "$mem1" != "null" ]] || do_skip "no region target1 found"
-	echo "$region"
-}
-
-# When cxl-cli support for inject and clear arrives, replace
-# the writes to /sys/kernel/debug with the new cxl commands.
-
-_do_poison_sysfs()
-{
-	local action="$1" dev="$2" addr="$3"
-	local expect_fail=${4:-false}
-
-	if "$expect_fail"; then
-		if echo "$addr" > "/sys/kernel/debug/cxl/$dev/${action}_poison"; then
-			echo "Expected ${action}_poison to fail for $addr"
-			err "$LINENO"
-		fi
-	else
-		echo "$addr" > "/sys/kernel/debug/cxl/$dev/${action}_poison"
-	fi
-}
-
-inject_poison_sysfs()
-{
-	_do_poison_sysfs 'inject' "$@"
-}
-
-clear_poison_sysfs()
-{
-	_do_poison_sysfs 'clear' "$@"
-}
-
-check_trace_entry()
-{
-	local expected_region="$1"
-	local expected_hpa="$2"
-
-	local trace_line
-	trace_line=$(grep "cxl_poison" /sys/kernel/tracing/trace | tail -n 1)
-	if [[ -z "$trace_line" ]]; then
-		echo "No cxl_poison trace event found"
-		err "$LINENO"
-	fi
-
-	local trace_region trace_hpa
-	trace_region=$(echo "$trace_line" | grep -o 'region=[^ ]*' | cut -d= -f2)
-	trace_hpa=$(echo "$trace_line" | grep -o 'hpa=0x[0-9a-fA-F]\+' | cut -d= -f2)
-
-	if [[ "$trace_region" != "$expected_region" ]]; then
-		echo "Expected region $expected_region not found in trace"
-		echo "$trace_line"
-		err "$LINENO"
-	fi
-
-	if [[ "$trace_hpa" != "$expected_hpa" ]]; then
-		echo "Expected HPA $expected_hpa not found in trace"
-		echo "$trace_line"
-		err "$LINENO"
-	fi
-}
-
-validate_poison_found()
-{
-	list_by="$1"
-	nr_expect="$2"
-
-	poison_list="$($CXL list "$list_by" --media-errors |
-		jq -r '.[].media_errors')"
-	if [[ ! $poison_list ]]; then
-		nr_found=0
-	else
-		nr_found=$(jq "length" <<< "$poison_list")
-	fi
-	if [ "$nr_found" -ne "$nr_expect" ]; then
-		echo "$nr_expect poison records expected, $nr_found found"
-		err "$LINENO"
-	fi
-}
-
-test_poison_by_memdev_by_dpa()
-{
-	find_memdev
-	inject_poison_sysfs "$memdev" "0x40000000"
-	inject_poison_sysfs "$memdev" "0x40001000"
-	inject_poison_sysfs "$memdev" "0x600"
-	inject_poison_sysfs "$memdev" "0x0"
-	validate_poison_found "-m $memdev" 4
-
-	clear_poison_sysfs "$memdev" "0x40000000"
-	clear_poison_sysfs "$memdev" "0x40001000"
-	clear_poison_sysfs "$memdev" "0x600"
-	clear_poison_sysfs "$memdev" "0x0"
-	validate_poison_found "-m $memdev" 0
-}
-
-test_poison_by_region_by_dpa()
-{
-	inject_poison_sysfs "$mem0" "0"
-	inject_poison_sysfs "$mem1" "0"
-	validate_poison_found "-r $region" 2
-
-	clear_poison_sysfs "$mem0" "0"
-	clear_poison_sysfs "$mem1" "0"
-	validate_poison_found "-r $region" 0
-}
-
-test_poison_by_region_offset()
-{
-	local base gran hpa1 hpa2
-	base=$(cat /sys/bus/cxl/devices/"$region"/resource)
-	gran=$(cat /sys/bus/cxl/devices/"$region"/interleave_granularity)
-
-	# Test two HPA addresses: base and base + granularity
-	# This hits the two memdevs in the region interleave.
-	hpa1=$(printf "0x%x" $((base)))
-	hpa2=$(printf "0x%x" $((base + gran)))
-
-	# Inject at the offset and check result using the hpa
-	# ABI takes an offset, but recall the hpa to check trace event
-
-	inject_poison_sysfs "$region" 0
-	check_trace_entry "$region" "$hpa1"
-	inject_poison_sysfs "$region" "$gran"
-	check_trace_entry "$region" "$hpa2"
-	validate_poison_found "-r $region" 2
-
-	clear_poison_sysfs "$region" 0
-	check_trace_entry "$region" "$hpa1"
-	clear_poison_sysfs "$region" "$gran"
-	check_trace_entry "$region" "$hpa2"
-	validate_poison_found "-r $region" 0
-}
-
-test_poison_by_region_offset_negative()
-{
-	local region_size cache_size cache_offset exceed_offset large_offset
-	region_size=$(cat /sys/bus/cxl/devices/"$region"/size)
-	cache_size=0
-
-	# This case is a no-op until cxl-test ELC mocking arrives
-	# Try to get cache_size if the attribute exists
-	if [ -f "/sys/bus/cxl/devices/$region/extended_linear_cache_size" ]; then
-		cache_size=$(cat /sys/bus/cxl/devices/"$region"/extended_linear_cache_size)
-	fi
-
-	# Offset within extended linear cache (if cache_size > 0)
-	if [[ $cache_size -gt 0 ]]; then
-		cache_offset=$((cache_size - 1))
-		echo "Testing offset within cache: $cache_offset (cache_size: $cache_size)"
-		inject_poison_sysfs "$region" "$cache_offset" true
-		clear_poison_sysfs "$region" "$cache_offset" true
-	else
-		echo "Skipping cache test - cache_size is 0"
-	fi
-
-	# Offset exceeds region size
-	exceed_offset=$((region_size))
-	inject_poison_sysfs "$region" "$exceed_offset" true
-	clear_poison_sysfs "$region" "$exceed_offset" true
-
-	# Offset exceeds region size by a lot
-	large_offset=$((region_size * 2))
-	inject_poison_sysfs "$region" "$large_offset" true
-	clear_poison_sysfs "$region" "$large_offset" true
-}
+. "$(dirname "$0")"/common-poison
 
 # Clear old trace events, enable cxl_poison, enable global tracing
 echo "" > /sys/kernel/tracing/trace
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [NDCTL PATCH 5/5] cxl/test: Add support for poison test for ELC
  2025-10-31 17:39 [NDCTL PATCH 0/5] cxl: Add tests for extended linear cache support Dave Jiang
                   ` (3 preceding siblings ...)
  2025-10-31 17:40 ` [NDCTL PATCH 4/5] cxl/test: Move common part of poison unit test to common file Dave Jiang
@ 2025-10-31 17:40 ` Dave Jiang
  2025-11-15  1:20 ` [NDCTL PATCH 0/5] cxl: Add tests for extended linear cache support Alison Schofield
  5 siblings, 0 replies; 12+ messages in thread
From: Dave Jiang @ 2025-10-31 17:40 UTC (permalink / raw)
  To: linux-cxl, nvdimm
  Cc: dave, jonathan.cameron, alison.schofield, vishal.l.verma,
	ira.weiny, dan.j.williams

Add a unit test for extended linear cache (ELC) poison handling testing.
The common code needs to be adjusted in order to handle the offset created
by ELC. The caculations are not impacted for normal region testing since
ELC size would be 0.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 test/common-poison     | 22 +++++++++++++++++-----
 test/cxl-poison-elc.sh | 41 +++++++++++++++++++++++++++++++++++++++++
 test/meson.build       |  2 ++
 3 files changed, 60 insertions(+), 5 deletions(-)
 create mode 100755 test/cxl-poison-elc.sh

diff --git a/test/common-poison b/test/common-poison
index 15a091e41dc3..3926e2fef4c4 100644
--- a/test/common-poison
+++ b/test/common-poison
@@ -130,9 +130,21 @@ test_poison_by_region_by_dpa()
 
 test_poison_by_region_offset()
 {
-	local base gran hpa1 hpa2
+	local base gran hpa1 hpa2 cache_size cache_offset
 	base=$(cat /sys/bus/cxl/devices/"$region"/resource)
 	gran=$(cat /sys/bus/cxl/devices/"$region"/interleave_granularity)
+	cache_size=0
+
+	# This case is a no-op until cxl-test ELC mocking arrives
+	# Try to get cache_size if the attribute exists
+	if [ -f "/sys/bus/cxl/devices/$region/extended_linear_cache_size" ]; then
+		cache_size=$(cat /sys/bus/cxl/devices/"$region"/extended_linear_cache_size)
+	fi
+
+	# Offset within extended linear cache (if cache_size > 0)
+	if [[ $cache_size -gt 0 ]]; then
+		base=$((base + cache_size))
+	fi
 
 	# Test two HPA addresses: base and base + granularity
 	# This hits the two memdevs in the region interleave.
@@ -142,15 +154,15 @@ test_poison_by_region_offset()
 	# Inject at the offset and check result using the hpa
 	# ABI takes an offset, but recall the hpa to check trace event
 
-	inject_poison_sysfs "$region" 0
+	inject_poison_sysfs "$region" $cache_size
 	check_trace_entry "$region" "$hpa1"
-	inject_poison_sysfs "$region" "$gran"
+	inject_poison_sysfs "$region" "$((gran + cache_size))"
 	check_trace_entry "$region" "$hpa2"
 	validate_poison_found "-r $region" 2
 
-	clear_poison_sysfs "$region" 0
+	clear_poison_sysfs "$region" $cache_size
 	check_trace_entry "$region" "$hpa1"
-	clear_poison_sysfs "$region" "$gran"
+	clear_poison_sysfs "$region" "$((gran + cache_size))"
 	check_trace_entry "$region" "$hpa2"
 	validate_poison_found "-r $region" 0
 }
diff --git a/test/cxl-poison-elc.sh b/test/cxl-poison-elc.sh
new file mode 100755
index 000000000000..25f54fb99171
--- /dev/null
+++ b/test/cxl-poison-elc.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2025 Intel Corporation. All rights reserved.
+
+. "$(dirname "$0")"/common
+
+rc=77
+
+set -ex
+[ -d "/sys/kernel/tracing" ] || do_skip "test requires CONFIG_TRACING"
+
+trap 'err $LINENO' ERR
+
+check_prereq "jq"
+
+modprobe -r cxl_test
+modprobe cxl_test extended_linear_cache=1
+
+rc=1
+
+# THEORY OF OPERATION: Exercise cxl-cli and cxl driver ability to
+# inject, clear, and get the poison list. Do it by memdev and by region.
+
+. "$(dirname "$0")"/common-poison
+
+# Clear old trace events, enable cxl_poison, enable global tracing
+echo "" > /sys/kernel/tracing/trace
+echo 1 > /sys/kernel/tracing/events/cxl/cxl_poison/enable
+echo 1 > /sys/kernel/tracing/tracing_on
+
+test_poison_by_memdev_by_dpa
+find_auto_region
+test_poison_by_region_by_dpa
+[ -f "/sys/kernel/debug/cxl/$region/inject_poison" ] ||
+       do_skip "test cases requires inject by region kernel support"
+test_poison_by_region_offset
+test_poison_by_region_offset_negative
+
+check_dmesg "$LINENO"
+
+modprobe -r cxl-test
diff --git a/test/meson.build b/test/meson.build
index 710a15850e2b..248917fd1edd 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -255,8 +255,10 @@ endif
 
 if get_option('libtracefs').enabled()
   cxl_poison = find_program('cxl-poison.sh')
+  cxl_poison_elc = find_program('cxl-poison-elc.sh')
   tests += [
     [ 'cxl-poison.sh', cxl_poison, 'cxl' ],
+    [ 'cxl-poison-elc.sh', cxl_poison_elc, 'cxl' ],
   ]
 endif
 
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [NDCTL PATCH 2/5] cxl/test: Fix cxl-poison.sh to detect the correct elc sysfs attrib
  2025-10-31 17:40 ` [NDCTL PATCH 2/5] cxl/test: Fix cxl-poison.sh to detect the correct elc sysfs attrib Dave Jiang
@ 2025-11-15  0:54   ` Alison Schofield
  0 siblings, 0 replies; 12+ messages in thread
From: Alison Schofield @ 2025-11-15  0:54 UTC (permalink / raw)
  To: Dave Jiang
  Cc: linux-cxl, nvdimm, dave, jonathan.cameron, vishal.l.verma,
	ira.weiny, dan.j.williams

On Fri, Oct 31, 2025 at 10:40:00AM -0700, Dave Jiang wrote:
> The cxl-poison.sh script attempts to read the extended linear cache
> size sysfs attribute but is using the incorrect attribute name.
> 
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>

Reviewed, tested and updated to the no-op comment
[ alisons: update the no-op attribute comment ]

Applied: https://github.com/pmem/ndctl/commits/pending

Thanks!

> ---
>  test/cxl-poison.sh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/test/cxl-poison.sh b/test/cxl-poison.sh
> index 231a0733f096..8e81baceeb24 100644
> --- a/test/cxl-poison.sh
> +++ b/test/cxl-poison.sh
> @@ -197,8 +197,8 @@ test_poison_by_region_offset_negative()
>  
>  	# This case is a no-op until cxl-test ELC mocking arrives
>  	# Try to get cache_size if the attribute exists
> -	if [ -f "/sys/bus/cxl/devices/$region/cache_size" ]; then
> -		cache_size=$(cat /sys/bus/cxl/devices/"$region"/cache_size)
> +	if [ -f "/sys/bus/cxl/devices/$region/extended_linear_cache_size" ]; then
> +		cache_size=$(cat /sys/bus/cxl/devices/"$region"/extended_linear_cache_size)
>  	fi
>  
>  	# Offset within extended linear cache (if cache_size > 0)
> -- 
> 2.51.0
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [NDCTL PATCH 1/5] cxl/test: Add test for extended linear cache support
  2025-10-31 17:39 ` [NDCTL PATCH 1/5] cxl/test: Add test " Dave Jiang
@ 2025-11-15  1:00   ` Alison Schofield
  2025-11-15  2:54   ` Alison Schofield
  1 sibling, 0 replies; 12+ messages in thread
From: Alison Schofield @ 2025-11-15  1:00 UTC (permalink / raw)
  To: Dave Jiang
  Cc: linux-cxl, nvdimm, dave, jonathan.cameron, vishal.l.verma,
	ira.weiny, dan.j.williams

On Fri, Oct 31, 2025 at 10:39:59AM -0700, Dave Jiang wrote:
> Add a unit test that verifies the extended linear cache setup paths
> in the kernel driver. cxl_test provides a mock'd version. The test
> verifies the sysfs attribute that indicates extended linear cache support
> is correctly reported. It also verifies the sizing and offset of the
> regions and decoders.
> 
> The expecation is that CFMWS covers the entire extended linear cache
> region. The first part is DRAM and second part is CXL memory in a 1:1
> setup. The start base for hardware decoders should be offsetted by the
> DRAM size.
> 
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  test/cxl-elc.sh  | 89 ++++++++++++++++++++++++++++++++++++++++++++++++
>  test/meson.build |  2 ++
>  2 files changed, 91 insertions(+)
>  create mode 100755 test/cxl-elc.sh
> 
> diff --git a/test/cxl-elc.sh b/test/cxl-elc.sh
> new file mode 100755
> index 000000000000..632e859c21f3
> --- /dev/null
> +++ b/test/cxl-elc.sh
> @@ -0,0 +1,89 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (C) 2025 Intel Corporation. All rights reserved.
> +
> +. "$(dirname "$0")"/common
> +
> +rc=77
> +
> +set -ex
> +[ -d "/sys/kernel/tracing" ] || do_skip "test requires CONFIG_TRACING"
> +
> +trap 'err $LINENO' ERR
> +
> +check_prereq "jq"
> +
> +modprobe -r cxl_test
> +modprobe cxl_test extended_linear_cache=1

With 6.18, this reports a false pass when it should skip.
Make sure that param exist w something like this:

modprobe cxl_test extended_linear_cache=1
[ -f /sys/module/cxl_test/parameters/extended_linear_cache ] || \
    do_skip "extended_linear_cache cxl_test param not available"

snip

> +retrieve_info
> +compare_sizes
> +compare_bases

check_dmesg and remove module before exit.

Please fixup the shellcheck complaints about needing double quotes.


snip to end

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [NDCTL PATCH 3/5] cxl/test: Move cxl-poison.sh to use cxl_test auto region
  2025-10-31 17:40 ` [NDCTL PATCH 3/5] cxl/test: Move cxl-poison.sh to use cxl_test auto region Dave Jiang
@ 2025-11-15  1:07   ` Alison Schofield
  0 siblings, 0 replies; 12+ messages in thread
From: Alison Schofield @ 2025-11-15  1:07 UTC (permalink / raw)
  To: Dave Jiang
  Cc: linux-cxl, nvdimm, dave, jonathan.cameron, vishal.l.verma,
	ira.weiny, dan.j.williams

On Fri, Oct 31, 2025 at 10:40:01AM -0700, Dave Jiang wrote:
> Move cxl-poison.sh to use the cxl_test auto region instead of manually
> create an additional region. This is in preparation to allow utilize
> the existing poison unit tests to also test the extended linear cache
> region.
> 
> The offset has been changed due to the auto region starts at 0 and pmem
> region starts at 0x40000000. The original test was creating a pmem
> region. It makes no difference what type of region is being used for
> testing.

Reviewed, tested, and applied: https://github.com/pmem/ndctl/commits/pending

Thanks!

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [NDCTL PATCH 0/5] cxl: Add tests for extended linear cache support
  2025-10-31 17:39 [NDCTL PATCH 0/5] cxl: Add tests for extended linear cache support Dave Jiang
                   ` (4 preceding siblings ...)
  2025-10-31 17:40 ` [NDCTL PATCH 5/5] cxl/test: Add support for poison test for ELC Dave Jiang
@ 2025-11-15  1:20 ` Alison Schofield
  5 siblings, 0 replies; 12+ messages in thread
From: Alison Schofield @ 2025-11-15  1:20 UTC (permalink / raw)
  To: Dave Jiang
  Cc: linux-cxl, nvdimm, dave, jonathan.cameron, vishal.l.verma,
	ira.weiny, dan.j.williams

On Fri, Oct 31, 2025 at 10:39:58AM -0700, Dave Jiang wrote:
> The series adds unit tests to verify the kernel support for extended
> linear cache (ELC). Added a test to check if the ELC region is setup
> correctly, and another test to go through the poison handling flow
> via the poison injection testing.
> 
> 
> Dave Jiang (5):
>   cxl/test: Add test for extended linear cache support
>   cxl/test: Fix cxl-poison.sh to detect the correct elc sysfs attrib
>   cxl/test: Move cxl-poison.sh to use cxl_test auto region

The next 2 patches may add more complexity than is needed by splitting
the work among a common file and 2 test scripts. Consider keeping the
work in one file and wrapping the test execution in a 'run_poison_tests'
function. Then call it that after each load of the module, like -

run_poison_tests
.
.
.
modprobe -r cxl_test
modprobe cxl_test
run_poison_tests
modprobe -r cxl_test

modprobe cxl_test extended_linear_cache=1
run_poison_tests
modprobe -r cxl_test

>   cxl/test: Move common part of poison unit test to common file
>   cxl/test: Add support for poison test for ELC
> 
>  test/common-poison     | 202 ++++++++++++++++++++++++++++++++++++++++
>  test/cxl-elc.sh        |  89 ++++++++++++++++++
>  test/cxl-poison-elc.sh |  41 +++++++++
>  test/cxl-poison.sh     | 203 +----------------------------------------
>  test/meson.build       |   4 +
>  5 files changed, 338 insertions(+), 201 deletions(-)
>  create mode 100644 test/common-poison
>  create mode 100755 test/cxl-elc.sh
>  create mode 100755 test/cxl-poison-elc.sh
> 
> 
> base-commit: 01c90830d65b6b331986f5996dcf6ad73c1579f4
> -- 
> 2.51.0
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [NDCTL PATCH 1/5] cxl/test: Add test for extended linear cache support
  2025-10-31 17:39 ` [NDCTL PATCH 1/5] cxl/test: Add test " Dave Jiang
  2025-11-15  1:00   ` Alison Schofield
@ 2025-11-15  2:54   ` Alison Schofield
  2025-11-16  1:49     ` Alison Schofield
  1 sibling, 1 reply; 12+ messages in thread
From: Alison Schofield @ 2025-11-15  2:54 UTC (permalink / raw)
  To: Dave Jiang
  Cc: linux-cxl, nvdimm, dave, jonathan.cameron, vishal.l.verma,
	ira.weiny, dan.j.williams

On Fri, Oct 31, 2025 at 10:39:59AM -0700, Dave Jiang wrote:
> Add a unit test that verifies the extended linear cache setup paths
> in the kernel driver. cxl_test provides a mock'd version. The test
> verifies the sysfs attribute that indicates extended linear cache support
> is correctly reported. It also verifies the sizing and offset of the
> regions and decoders.
> 
> The expecation is that CFMWS covers the entire extended linear cache
> region. The first part is DRAM and second part is CXL memory in a 1:1
> setup. The start base for hardware decoders should be offsetted by the
> DRAM size.
> 
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  test/cxl-elc.sh  | 89 ++++++++++++++++++++++++++++++++++++++++++++++++
>  test/meson.build |  2 ++
>  2 files changed, 91 insertions(+)
>  create mode 100755 test/cxl-elc.sh

snip
>

The call to this:

> +find_region()
> +{
> +	json="$($CXL list -b cxl_test -R)"
> +	region=$(echo "$json" | jq -r '.[] | select(has("extended_linear_cache_size") and .extended_linear_cache_size != null) | .region')
> +	[[ -n "$region" && "$region" != "null" ]] || do_skip "no test extended linear cache region found"
> +}
> +

is missing from here. Just found while testing w patches supporting the
parameter. So you can fix this and ignore my review comment about
looking up the parameter.

> +retrieve_info
> +compare_sizes
> +compare_bases



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [NDCTL PATCH 1/5] cxl/test: Add test for extended linear cache support
  2025-11-15  2:54   ` Alison Schofield
@ 2025-11-16  1:49     ` Alison Schofield
  0 siblings, 0 replies; 12+ messages in thread
From: Alison Schofield @ 2025-11-16  1:49 UTC (permalink / raw)
  To: Dave Jiang
  Cc: linux-cxl, nvdimm, dave, jonathan.cameron, vishal.l.verma,
	ira.weiny, dan.j.williams

On Fri, Nov 14, 2025 at 06:54:05PM -0800, Alison Schofield wrote:
> On Fri, Oct 31, 2025 at 10:39:59AM -0700, Dave Jiang wrote:
> > Add a unit test that verifies the extended linear cache setup paths
> > in the kernel driver. cxl_test provides a mock'd version. The test
> > verifies the sysfs attribute that indicates extended linear cache support
> > is correctly reported. It also verifies the sizing and offset of the
> > regions and decoders.
> > 
> > The expecation is that CFMWS covers the entire extended linear cache
> > region. The first part is DRAM and second part is CXL memory in a 1:1
> > setup. The start base for hardware decoders should be offsetted by the
> > DRAM size.
> > 
> > Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> > ---
> >  test/cxl-elc.sh  | 89 ++++++++++++++++++++++++++++++++++++++++++++++++
> >  test/meson.build |  2 ++
> >  2 files changed, 91 insertions(+)
> >  create mode 100755 test/cxl-elc.sh
> 
> snip
> >
> 
> The call to this:
> 
> > +find_region()
> > +{
> > +	json="$($CXL list -b cxl_test -R)"
> > +	region=$(echo "$json" | jq -r '.[] | select(has("extended_linear_cache_size") and .extended_linear_cache_size != null) | .region')
> > +	[[ -n "$region" && "$region" != "null" ]] || do_skip "no test extended linear cache region found"
> > +}
> > +
> 
> is missing from here. Just found while testing w patches supporting the
> parameter. So you can fix this and ignore my review comment about
> looking up the parameter.

I got that wrong, we do need both checks:
Skip if the param is missing
Fail if the ELC region is not found since that signals cxl-test breakage


> 
> > +retrieve_info
> > +compare_sizes
> > +compare_bases
> 
> 
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-11-16  1:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-31 17:39 [NDCTL PATCH 0/5] cxl: Add tests for extended linear cache support Dave Jiang
2025-10-31 17:39 ` [NDCTL PATCH 1/5] cxl/test: Add test " Dave Jiang
2025-11-15  1:00   ` Alison Schofield
2025-11-15  2:54   ` Alison Schofield
2025-11-16  1:49     ` Alison Schofield
2025-10-31 17:40 ` [NDCTL PATCH 2/5] cxl/test: Fix cxl-poison.sh to detect the correct elc sysfs attrib Dave Jiang
2025-11-15  0:54   ` Alison Schofield
2025-10-31 17:40 ` [NDCTL PATCH 3/5] cxl/test: Move cxl-poison.sh to use cxl_test auto region Dave Jiang
2025-11-15  1:07   ` Alison Schofield
2025-10-31 17:40 ` [NDCTL PATCH 4/5] cxl/test: Move common part of poison unit test to common file Dave Jiang
2025-10-31 17:40 ` [NDCTL PATCH 5/5] cxl/test: Add support for poison test for ELC Dave Jiang
2025-11-15  1:20 ` [NDCTL PATCH 0/5] cxl: Add tests for extended linear cache support Alison Schofield

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