perf tests: test_arm_coresight: Simplify source iteration
authorJames Clark <james.clark@arm.com>
Mon, 23 Oct 2023 13:15:49 +0000 (14:15 +0100)
committerNamhyung Kim <namhyung@kernel.org>
Thu, 26 Oct 2023 17:58:10 +0000 (10:58 -0700)
There are two reasons to do this, firstly there is a shellcheck warning
in cs_etm_dev_name(), which can be completely deleted. And secondly the
current iteration method doesn't support systems with both ETE and ETM
because it picks one or the other. There isn't a known system with this
configuration, but it could happen in the future.

Iterating over all the sources for each CPU can be done by going through
/sys/bus/event_source/devices/cs_etm/cpu* and following the symlink back
to the Coresight device in /sys/bus/coresight/devices. This will work
whether the device is ETE, ETM or any future name, and is much simpler
and doesn't require any hard coded version numbers

Suggested-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: James Clark <james.clark@arm.com>
Acked-by: Ian Rogers <irogers@google.com>
Tested-by: Leo Yan <leo.yan@linaro.org>
Cc: tianruidong@linux.alibaba.com
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Anushree Mathur <anushree.mathur@linux.vnet.ibm.com>
Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: atrajeev@linux.vnet.ibm.com
Cc: coresight@lists.linaro.org
Link: https://lore.kernel.org/r/20231023131550.487760-1-james.clark@arm.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/tests/shell/test_arm_coresight.sh

index fe78c4626e4513b8e9ca7c7ae33a292fcb011324..65dd852071250a8ef323562112489a06cab6dac0 100755 (executable)
 
 glb_err=0
 
-cs_etm_dev_name() {
-       cs_etm_path=$(find  /sys/bus/event_source/devices/cs_etm/ -name cpu* -print -quit)
-       trcdevarch=$(cat ${cs_etm_path}/mgmt/trcdevarch)
-       archhver=$((($trcdevarch >> 12) & 0xf))
-       archpart=$(($trcdevarch & 0xfff))
-
-       if [ $archhver -eq 5 -a "$(printf "0x%X\n" $archpart)" = "0xA13" ] ; then
-               echo "ete"
-       else
-               echo "etm"
-       fi
-}
-
 skip_if_no_cs_etm_event() {
        perf list | grep -q 'cs_etm//' && return 0
 
@@ -149,7 +136,9 @@ arm_cs_iterate_devices() {
 
 arm_cs_etm_traverse_path_test() {
        # Iterate for every ETM device
-       for dev in /sys/bus/coresight/devices/$(cs_etm_dev_name)*; do
+       for dev in /sys/bus/event_source/devices/cs_etm/cpu*; do
+               # Canonicalize the path
+               dev=`readlink -f $dev`
 
                # Find the ETM device belonging to which CPU
                cpu=`cat $dev/cpu`