From: Shuah Khan <skhan@linuxfoundation.org>
To: Linu Cherian <lcherian@marvell.com>,
suzuki.poulose@arm.com, mike.leach@linaro.org,
james.clark@arm.com
Cc: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org,
linux-kernel@vger.kernel.org, shuah@kernel.org,
linux-kselftest@vger.kernel.org, sgoutham@marvell.com,
gcherian@marvell.com, Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH] selftests: arm coresight: sysfsmode testing
Date: Tue, 3 Dec 2024 17:23:56 -0700 [thread overview]
Message-ID: <115bb206-8401-4475-977d-7dd98a2b872c@linuxfoundation.org> (raw)
In-Reply-To: <20241129083813.3056909-1-lcherian@marvell.com>
On 11/29/24 01:38, Linu Cherian wrote:
> Add sysfs mode selftest for ARM Coresight hardware tracer.
Please add details on what this test does in here. Include
the output from the test?
Does this test have dependencies on config? If it does, does
this test detect and skip if config isn't enabled?
>
> Signed-off-by: Linu Cherian <lcherian@marvell.com>
> ---
> .../drivers/hwtracing/coresight/Makefile | 5 +
> .../hwtracing/coresight/sysfs_test_trace.sh | 144 ++++++++++++++++++
> 2 files changed, 149 insertions(+)
> create mode 100644 tools/testing/selftests/drivers/hwtracing/coresight/Makefile
> create mode 100755 tools/testing/selftests/drivers/hwtracing/coresight/sysfs_test_trace.sh
>
> diff --git a/tools/testing/selftests/drivers/hwtracing/coresight/Makefile b/tools/testing/selftests/drivers/hwtracing/coresight/Makefile
> new file mode 100644
> index 000000000000..7dc68ae1c0a9
> --- /dev/null
> +++ b/tools/testing/selftests/drivers/hwtracing/coresight/Makefile
> @@ -0,0 +1,5 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +TEST_PROGS = sysfs_test_trace.sh
> +
> +include ../../../lib.mk
> diff --git a/tools/testing/selftests/drivers/hwtracing/coresight/sysfs_test_trace.sh b/tools/testing/selftests/drivers/hwtracing/coresight/sysfs_test_trace.sh
> new file mode 100755
> index 000000000000..0d6307fff1d2
> --- /dev/null
> +++ b/tools/testing/selftests/drivers/hwtracing/coresight/sysfs_test_trace.sh
> @@ -0,0 +1,144 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (C) 2024 Marvell.
> +
> +# Test Arm CoreSight trace capture in sysfs mode
> +# Based on tools/perf/tests/shell/test_arm_coresight.sh
> +
> +glb_err=0
> +
> +arm_cs_report() {
> + if [ $2 != 0 ]; then
> + echo "$1: FAIL"
> + glb_err=$2
> + else
> + echo "$1: PASS"
> + fi
> +}
> +
> +is_device_sink() {
> + # If the node of "enable_sink" is existed under the device path, this
> + # means the device is a sink device.
> +
> + if [ -e "$1/enable_sink" ]; then
> +
> + return 0
> + else
> + return 1
> + fi
> +}
> +
> +# Configure sink for buffer mode
> +cfg_sink_buf_mode() {
> + sink_dev=$1
> + mode=$2
> + # Set buffer mode if supported
> + if [ -e "$sink_dev/buf_modes_available" ]; then
> + cat $sink_dev/buf_modes_available | grep -E -q $mode
> + if [ $? -eq 0 ]; then
> + echo $mode > $sink_dev/buf_mode_preferred
> + return 0
> + fi
> + fi
> +
> + return 1
> +}
> +
> +run_app() {
> +
> + taskset -c $1 dd if=/dev/urandom of=/dev/null bs=1M count=64
> +}
> +
> +sysfs_trace() {
> + src_dev=$1
> + sink_dev=$2
> + cpu=$3
> +
> + # Enable sink device
> + echo 1 > $sink_dev/enable_sink
> + # Enable source device
> + echo 1 > $src_dev/enable_source
> +
> + # Run app to be traced
> + run_app $cpu
> +
> + # Read back trace data
> + dd if=/dev/$sink_dev_name of=/tmp/tracedata
> +
> + # Verify if read is successful
> + err=$?
> +
> + # Disable source device
> + echo 0 > $src_dev/enable_source
> +
> + # Diskable sink device
> + echo 0 > $sink_dev/enable_sink
> +
> + arm_cs_report "CoreSight path testing (CPU$cpu -> $sink_dev_name)" $err
> +}
> +
> +try_sysfs_trace_resrv_buf() {
> + src_dev=$1
> + sink_dev=$2
> + cpu=$3
> +
> + # Configure the resrved buffer mode if available
> + cfg_sink_buf_mode $sink_dev "resrv"
> + if [ $? -eq 0 ]; then
> + echo "Running sysfs trace with resrv buf mode"
> + sysfs_trace $src_dev $sink_dev $cpu
> + # Restore buffer mode
> + cfg_sink_buf_mode $sink_dev "auto"
> + if [ $? -eq 1 ]; then
> + echo "Failed to restore default buf mode"
> + fi
> + fi
> +}
> +
> +arm_cs_iterate_devices() {
> + src_dev=$1
> + cpu=$3
> + for cdev in $2/connections/out\:*; do
> +
> + # Skip testing if it's not a directory
> + ! [ -d $cdev ] && continue;
> +
> + # Read out its symbol link file name
> + sink_dev=`readlink -f $cdev`
> +
> + # Extract device name from path, e.g.
> + # sink_dev = '/sys/devices/platform/20010000.etf/tmc_etf0'
> + # `> sink_dev_name = 'tmc_etf0'
> + sink_dev_name=$(basename $sink_dev)
> +
> + if is_device_sink $sink_dev; then
> + # Run trace with resrv buf mode (if available)
> + try_sysfs_trace_resrv_buf $src_dev $sink_dev $cpu
> +
> + # Run the default mode
> + echo "Running sysfs trace with default settings"
> + sysfs_trace $src_dev $sink_dev $cpu
> + fi
> +
> + arm_cs_iterate_devices $src_dev $cdev $cpu
> +
> + done
> +}
> +
> +arm_cs_etm_traverse_path_test() {
> + # Iterate for every ETM device
> + 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`
> +
> + # Use depth-first search (DFS) to iterate outputs
> + arm_cs_iterate_devices $dev $dev $cpu
> + done
> +}
> +
> +arm_cs_etm_traverse_path_test
> +
> +exit $glb_err
thanks,
-- Shuah
next prev parent reply other threads:[~2024-12-04 0:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-29 8:38 [PATCH] selftests: arm coresight: sysfsmode testing Linu Cherian
2024-12-04 0:23 ` Shuah Khan [this message]
2024-12-04 11:18 ` James Clark
2024-12-16 5:35 ` Linu Cherian
2024-12-04 11:15 ` James Clark
2024-12-16 5:35 ` Linu Cherian
2024-12-16 5:50 ` Linu Cherian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=115bb206-8401-4475-977d-7dd98a2b872c@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=coresight@lists.linaro.org \
--cc=gcherian@marvell.com \
--cc=james.clark@arm.com \
--cc=lcherian@marvell.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mike.leach@linaro.org \
--cc=sgoutham@marvell.com \
--cc=shuah@kernel.org \
--cc=suzuki.poulose@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox