@@ -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
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. Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- test/cxl-region-sysfs.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)