The CXL driver region configuration use to reject valid topologies
containing passthrough decoders beneath a wide parent interleave.
A recent kernel patch fixed that issue and extended cxl-test with
a topology that exercises it.

Add a create-and-destroy region case spanning the two host bridges
beneath the new 2-way 16K root decoder to verify that such
configurations are accepted.

The test case is quietly skipped if the new cxl/test topology is
not found, which also means the kernel fix is not yet present.

Assisted-by: Claude:Opus-4-8
Signed-off-by: Alison Schofield <[email protected]>
---
 test/cxl-create-region.sh | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/test/cxl-create-region.sh b/test/cxl-create-region.sh
index 5941e18f338d..c24e477c4f5c 100644
--- a/test/cxl-create-region.sh
+++ b/test/cxl-create-region.sh
@@ -170,10 +170,12 @@ setup_x1()
 
 setup_x2()
 {
-       # Find an x2 decoder
+       # Find an x2 decoder. Pin to the 256 granularity root to avoid
+       # the 16K root used by the passthrough granularity test.
        decoder=$($CXL list -b cxl_test -D -d root | jq -r ".[] |
                select(.pmem_capable == true) |
                select(.nr_targets == 2) |
+               select(.interleave_granularity == 256) |
                .decoder")
 
        # Find a memdev for each host-bridge interleave position
@@ -184,10 +186,12 @@ setup_x2()
 
 setup_x4()
 {
-       # find an x2 decoder
+       # find an x2 decoder. Pin to the 256 granularity root to avoid
+       # the 16K root used by the passthrough granularity test.
        decoder=$($CXL list -b cxl_test -D -d root | jq -r ".[] |
                select(.pmem_capable == true) |
                select(.nr_targets == 2) |
+               select(.interleave_granularity == 256) |
                .decoder")
 
        # Find a memdev for each host-bridge interleave position
@@ -198,6 +202,23 @@ setup_x4()
        memdevs="$mem0 $mem1 $mem2 $mem3"
 }
 
+setup_passthru_gran()
+{
+       # Find the 2-way 16K root. A region spanning both host bridges
+       # places one endpoint under each. The intermediate switch decoders
+       # are passthrough decoders with 32K granularity.
+       decoder=$($CXL list -b cxl_test -D -d root | jq -r ".[] |
+               select(.pmem_capable == true) |
+               select(.nr_targets == 2) |
+               select(.interleave_granularity == 16384) |
+               .decoder")
+
+       # Find a memdev for each host-bridge interleave position
+       mem0=$(find_memdev "$decoder" 0 0)
+       mem1=$(find_memdev "$decoder" 1 0)
+       memdevs="$mem0 $mem1"
+}
+
 setup_x3()
 {
        # find an x3 decoder
@@ -252,6 +273,11 @@ setup_x3
 if [[ $decoder ]]; then
        create_and_destroy_region
 fi
+# 16K root may not be available in cxl/test topo yet
+setup_passthru_gran
+if [[ $decoder ]]; then
+       create_and_destroy_region
+fi
 
 check_dmesg "$LINENO"
 
-- 
2.37.3


Reply via email to