From bcc9897b38be91df38f81fb3105d2351f7941377 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 5 Aug 2022 13:38:26 -0700 Subject: [PATCH 206/217] cxl/test: Validate switch port settings in cxl-region-sysfs.sh A recent kernel fix to add the missing update of endpoint decoder HPA range settings regressed switch decoder HPA range settings. Add validation for switch port settings to avoid regressions like that going forward. Link: https://lore.kernel.org/r/165973190625.1528532.12244196912617964754.stgit@dwillia2-xfh.jf.intel.com Signed-off-by: Dan Williams Signed-off-by: Vishal Verma --- test/cxl-region-sysfs.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/cxl-region-sysfs.sh b/test/cxl-region-sysfs.sh index 110e037..ae0f556 100644 --- a/test/cxl-region-sysfs.sh +++ b/test/cxl-region-sysfs.sh @@ -112,6 +112,38 @@ do [ $res -ne $region_base ] && err "$LINENO: decoder: $i base: $res region_base: $region_base" done +# validate all switch decoders have the correct settings +nr_switches=$((nr_targets/2)) +nr_host_bridges=$((nr_switches/2)) +nr_switch_decoders=$((nr_switches + nr_host_bridges)) + +json=$($CXL list -D -r $region -d switch) +readarray -t switch_decoders < <(echo $json | jq -r ".[].decoder") + +[ ${#switch_decoders[@]} -ne $nr_switch_decoders ] && err \ +"$LINENO: expected $nr_switch_decoders got ${#switch_decoders[@]} switch decoders" + +for i in ${switch_decoders[@]} +do + decoder=$(echo $json | jq -r ".[] | select(.decoder == \"$i\")") + id=${i#decoder} + port_id=${id%.*} + depth=$($CXL list -p $port_id -S | jq -r ".[].depth") + iw=$(echo $decoder | jq -r ".interleave_ways") + ig=$(echo $decoder | jq -r ".interleave_granularity") + + [ $iw -ne 2 ] && err "$LINENO: decoder: $i iw: $iw targets: 2" + [ $ig -ne $((r_ig << depth)) ] && err \ + "$LINENO: decoder: $i ig: $ig switch_ig: $((r_ig << depth))" + + res=$(echo $decoder | jq -r ".resource") + sz=$(echo $decoder | jq -r ".size") + [ $sz -ne $region_size ] && err \ + "$LINENO: decoder: $i sz: $sz region_size: $region_size" + [ $res -ne $region_base ] && err \ + "$LINENO: decoder: $i base: $res region_base: $region_base" +done + # walk up the topology and commit all decoders echo 1 > /sys/bus/cxl/devices/$region/commit -- 2.27.0