From: Alison Schofield <alison.schofi...@intel.com> Test cxl-region-sysfs.sh assumes Modulo arithmetic. XOR arithmetic is being introduced and requires a different ordering of the memdevs in the region.
Update the test to sort the memdevs based on interleave arithmetic. If the interleave arithmetic attribute for the root decoder is not visible in sysfs, driver support for XOR math is not present. Default to Modulo sorting order. Signed-off-by: Alison Schofield <alison.schofi...@intel.com> --- test/cxl-region-sysfs.sh | 44 ++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/test/cxl-region-sysfs.sh b/test/cxl-region-sysfs.sh index ae0f55653814..1af0ae7e632c 100644 --- a/test/cxl-region-sysfs.sh +++ b/test/cxl-region-sysfs.sh @@ -58,15 +58,43 @@ readarray -t mem_sort1 < <($CXL list -M -p $port_dev1 | jq -r ".[] | .memdev") # TODO: add a cxl list option to list memdevs in valid region provisioning # order, hardcode for now. + +# Sort based on root decoder interleave arithmetic. +# Default to Modulo if the sysfs attribute is not emitted. +if [ ! -e /sys/bus/cxl/devices/$decoder/interleave_arithmetic ]; then + ia="0" +else + ia=$(cat /sys/bus/cxl/devices/$decoder/interleave_arithmetic) +fi + mem_sort=() -mem_sort[0]=${mem_sort0[0]} -mem_sort[1]=${mem_sort1[0]} -mem_sort[2]=${mem_sort0[2]} -mem_sort[3]=${mem_sort1[2]} -mem_sort[4]=${mem_sort0[1]} -mem_sort[5]=${mem_sort1[1]} -mem_sort[6]=${mem_sort0[3]} -mem_sort[7]=${mem_sort1[3]} +if [ $ia == "0" ]; then + # Modulo Arithmetic + mem_sort[0]=${mem_sort0[0]} + mem_sort[1]=${mem_sort1[0]} + mem_sort[2]=${mem_sort0[2]} + mem_sort[3]=${mem_sort1[2]} + mem_sort[4]=${mem_sort0[1]} + mem_sort[5]=${mem_sort1[1]} + mem_sort[6]=${mem_sort0[3]} + mem_sort[7]=${mem_sort1[3]} + +elif [ $ia == "1" ]; then + # XOR Arithmetic + mem_sort[0]=${mem_sort1[0]} + mem_sort[1]=${mem_sort0[0]} + mem_sort[2]=${mem_sort1[2]} + mem_sort[3]=${mem_sort0[2]} + mem_sort[4]=${mem_sort1[1]} + mem_sort[5]=${mem_sort0[1]} + mem_sort[6]=${mem_sort1[3]} + mem_sort[7]=${mem_sort0[3]} +else + # Unknown Arithmetic + echo "Unknown interleave arithmetic: $ia for $decoder" + modprobe -r cxl-test + exit 1 +fi # TODO: use this alternative memdev ordering to validate a negative test for # specifying invalid positions of memdevs base-commit: c9c9db39354ea0c3f737378186318e9b7908e3a7 -- 2.31.1