The original port decoder programming algorithm in the kernel failed to
acommodate the corner case of a passthrough port connected to a fan-out
port. Use the 5th cxl_test decoder to regression test this scenario.

Reported-by: Bobo WL <lmw.b...@gmail.com>
Reported-by: Jonathan Cameron <jonathan.came...@huawei.com>
Link: http://lore.kernel.org/r/20221010172057.00001...@huawei.com
Tested-by: Alison Schofield <alison.schofi...@intel.com>
Signed-off-by: Dan Williams <dan.j.willi...@intel.com>
---
 test/cxl-create-region.sh |   28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/test/cxl-create-region.sh b/test/cxl-create-region.sh
index 82aad3a7285a..47aed44848ab 100644
--- a/test/cxl-create-region.sh
+++ b/test/cxl-create-region.sh
@@ -110,6 +110,34 @@ create_subregions()
        done
 }
 
+create_single()
+{
+       # the 5th cxl_test decoder is expected to target a single-port
+       # host-bridge. Older cxl_test implementations may not define it,
+       # so skip the test in that case.
+       decoder=$($CXL list -b cxl_test -D -d root |
+                 jq -r ".[4] |
+                 select(.pmem_capable == true) |
+                 select(.nr_targets == 1) |
+                 .decoder")
+
+        if [[ ! $decoder ]]; then
+                echo "no single-port host-bridge decoder found, skipping"
+                return
+        fi
+
+       region=$($CXL create-region -d "$decoder" | jq -r ".region")
+       if [[ ! $region ]]; then
+               echo "failed to create single-port host-bridge region"
+               err "$LINENO"
+       fi
+
+       destroy_regions "$region"
+}
+
+# test region creation on devices behind a single-port host-bridge
+create_single
+
 # test reading labels directly through cxl-cli
 readarray -t mems < <("$CXL" list -b cxl_test -M | jq -r '.[].memdev')
 


Reply via email to