Skip to content

Commit 4de3cdb

Browse files
Added SMMU Support for Embedded Trace Router scripts
- Coresight-Sink-Source-Test: Validate trace capture across all CoreSight source and sink combinations by enabling sources, routing to sinks, and verifying collected trace data. - Ftrace-Dump-ETF-Base: Verify ftrace-to-STM linkage by capturing scheduler trace events through an ETF sink and validating trace output size. - Reset-All-Sinks-Base: Stress test simultaneous reset of multiple CoreSight sinks and ensure all sinks reliably disable and recover for trace capture. - Reset-Random-Sinks-Base: Randomly enable and reset multiple CoreSight sinks under stress and validate sink disable behavior and post-reset trace functionality. Single-Sink-Reset-Base: Repeatedly enable an active source and a single sink, reset CoreSight, and verify the sink consistently disables under load. - Single-Sink-Reset-Connected-Base: Stress test sink reset behavior with an actively connected STM source and verify recovery via successful trace read. Also a common library helper function coresight_helper.sh is added to prevent duplication of code blocks. Signed-off-by: Rohan Dutta <rohadutt@qti.qualcomm.com>
2 parents 5867b6c + d12c7e0 commit 4de3cdb

File tree

24 files changed

+2724
-24
lines changed

24 files changed

+2724
-24
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
metadata:
2+
name: Coresight-Sink-Source-Test
3+
format: "Lava-Test Test Definition 1.0"
4+
description: "This test iterates through all CoreSight sources and sinks to validate end‑to‑end trace path accessibility. It ensures trace data capture works correctly and that all sources are cleanly disabled after execution."
5+
os:
6+
- linux
7+
scope:
8+
- coresight
9+
- kernel
10+
11+
run:
12+
steps:
13+
- REPO_PATH=$PWD || true
14+
- cd Runner/suites/Kernel/DEBUG/Coresight-Sink-Source-Test || true
15+
- ./run.sh || true
16+
- $REPO_PATH/Runner/utils/send-to-lava.sh Coresight-Sink-Source-Test.res || true
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Coresight-Sink-Source-Test
2+
3+
## Overview
4+
The `Coresight-Sink-Source-Test` test iterates through all CoreSight sources and sinks to validate end‑to‑end trace path accessibility. It ensures trace data capture works correctly and that all sources are cleanly disabled after execution.
5+
6+
## Test Goals
7+
8+
- Verify that the CoreSight sink correctly switches to ETF mode.
9+
- Validate STM trace data routing to ETF via Ftrace integration.
10+
- Ensure sched_switch events are captured and stored in the ETF buffer.
11+
- Confirm valid trace data generation by checking ETF output size.
12+
13+
## Prerequisites
14+
15+
- Coresight framework enabled in the kernel with `sysfs` and `debugfs` accessible
16+
- Multiple Coresight sink and source devices should be present
17+
- Coresight STM, ETM, ETF devices must be included
18+
- Root priviledges
19+
20+
## Script Location
21+
22+
```
23+
Runner/suites/Kernel/DEBUG/Coresight-Sink-Source-Test/run.sh
24+
```
25+
26+
## Files
27+
28+
- `run.sh` - Main test script
29+
- `Coresight-Sink-Source-Test.res` - Summary result file with PASS/FAIL
30+
- `Coresight-Sink-Source-Test.log` - Full execution log.
31+
32+
## How it works
33+
1. Parses input parameters, sources common utilities, gathers all CoreSight devices, and configures the ETR sink to memory output mode.
34+
2. Loops over all valid CoreSight sinks and sources, optionally skipping remote ETMs and unsupported TPDM sources.
35+
3. Resets all sources and sinks, enables one sink at a time, then enables each applicable source to form a complete trace path.
36+
4. Reads trace data from each sink device and verifies successful data capture based on output file size.
37+
5. Resets the system again and checks that all sources are properly disabled before reporting pass or fail status.
38+
39+
## Usage
40+
41+
Run the script directly. No iterations or special arguments are required for this basic test.
42+
43+
```bash
44+
./run.sh
45+
```
46+
47+
## Example Output
48+
49+
```
50+
[INFO] 2026-04-06 05:17:08 - ---------------------------Coresight-Sink-Source-Test Starting---------------------------
51+
[INFO] 2026-04-06 05:17:08 - Starting iteration: 1
52+
[INFO] 2026-04-06 05:17:08 - Sink Active:- tmc_etf0
53+
[INFO] 2026-04-06 05:17:09 - Source: etm0 with trace captured of size 65536 bytes
54+
[INFO] 2026-04-06 05:17:10 - Source: etm1 with trace captured of size 65536 bytes
55+
[INFO] 2026-04-06 05:17:11 - Source: etm2 with trace captured of size 65536 bytes
56+
.........
57+
[INFO] 2026-04-06 05:20:15 - Source: tpdm7 with trace captured of size 96 bytes
58+
[INFO] 2026-04-06 05:20:16 - Source: tpdm8 with trace captured of size 96 bytes
59+
[INFO] 2026-04-06 05:20:17 - Source: tpdm9 with trace captured of size 80 bytes
60+
[INFO] 2026-04-06 05:20:17 - PASS: coresight source/sink path test
61+
[INFO] 2026-04-06 05:20:17 - ---------------------------Coresight-Sink-Source-Test Finished---------------------------
62+
```
63+
64+
## Return Code
65+
66+
- `0` — All test cases passed
67+
- `1` — One or more test cases failed
68+
69+
## Integration in CI
70+
71+
- Can be run standalone or via LAVA
72+
- Result file `Coresight-Sink-Source-Test.res` will be parsed by `result_parse.sh`
73+
74+
## Notes
75+
76+
- Remote ETM sources and unsupported TPDM sources are conditionally skipped during testing.
77+
- Trace validity is confirmed by checking a minimum output file size from each sink.
78+
79+
## License
80+
81+
SPDX-License-Identifier: BSD-3-Clause.
82+
(c) Qualcomm Technologies, Inc. and/or its subsidiaries.
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
#!/bin/sh
2+
3+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
7+
INIT_ENV=""
8+
SEARCH="$SCRIPT_DIR"
9+
while [ "$SEARCH" != "/" ]; do
10+
if [ -f "$SEARCH/init_env" ]; then
11+
INIT_ENV="$SEARCH/init_env"
12+
break
13+
fi
14+
SEARCH=$(dirname "$SEARCH")
15+
done
16+
17+
if [ -z "$INIT_ENV" ]; then
18+
echo "[ERROR] Could not find init_env" >&2
19+
exit 1
20+
fi
21+
22+
if [ -z "$__INIT_ENV_LOADED" ]; then
23+
# shellcheck disable=SC1090
24+
. "$INIT_ENV"
25+
__INIT_ENV_LOADED=1
26+
fi
27+
28+
# shellcheck disable=SC1090,SC1091
29+
. "$TOOLS/functestlib.sh"
30+
# shellcheck disable=SC1090,SC1091
31+
. "$TOOLS/coresight_helper.sh"
32+
33+
TESTNAME="Coresight-Sink-Source-Test"
34+
test_path=$(find_test_case_by_name "$TESTNAME")
35+
cd "$test_path" || exit 1
36+
res_file="./$TESTNAME.res"
37+
log_info "---------------------------$TESTNAME Starting---------------------------"
38+
39+
no_remote_etm=0
40+
if [ "$#" -eq 1 ]; then
41+
no_remote_etm=1
42+
fi
43+
44+
cs_base="/sys/bus/coresight/devices"
45+
fail=0
46+
47+
if [ ! -d "$cs_base" ]; then
48+
log_warn "Coresight directory $cs_base not found. Skipping test."
49+
echo "$TESTNAME SKIP" > "$res_file"
50+
exit 0
51+
fi
52+
53+
trap cleanup EXIT HUP INT TERM
54+
55+
reset_coresight
56+
57+
sinks=""
58+
sources=""
59+
60+
for node in "$cs_base"/*; do
61+
[ ! -d "$node" ] && continue
62+
node_name=$(basename "$node")
63+
64+
if [ -f "$node/enable_sink" ]; then
65+
[ "$node_name" = "tmc_etf1" ] && continue
66+
sinks="$sinks $node"
67+
68+
if [ -f "$node/out_mode" ]; then
69+
echo mem > "$node/out_mode" 2>/dev/null || true
70+
fi
71+
fi
72+
73+
if [ -f "$node/enable_source" ]; then
74+
sources="$sources $node"
75+
fi
76+
done
77+
78+
sinks=${sinks# }
79+
sources=${sources# }
80+
81+
if [ -z "$sinks" ]; then
82+
log_warn "No Coresight sinks found. Skipping test."
83+
echo "$TESTNAME SKIP" > "$res_file"
84+
exit 0
85+
fi
86+
87+
if [ -z "$sources" ]; then
88+
log_warn "No Coresight sources found. Skipping test."
89+
echo "$TESTNAME SKIP" > "$res_file"
90+
exit 0
91+
fi
92+
93+
i=0
94+
while [ "$i" -le 2 ]; do
95+
log_info "Starting iteration: $((i+1))"
96+
97+
for sink_node in $sinks; do
98+
sink_dev=$(basename "$sink_node")
99+
log_info "Sink Active:- $sink_dev"
100+
101+
for source_node in $sources; do
102+
dev_name=$(basename "$source_node")
103+
104+
case "$dev_name" in
105+
*etm*)
106+
if [ "$no_remote_etm" -eq 1 ]; then
107+
continue
108+
fi
109+
;;
110+
*tpdm-vsense* | *tpdm-qm*)
111+
continue
112+
;;
113+
esac
114+
115+
reset_coresight
116+
117+
[ -f "$sink_node/enable_sink" ] && echo 1 > "$sink_node/enable_sink" 2>/dev/null
118+
119+
if [ -f "$source_node/enable_source" ]; then
120+
echo 1 > "$source_node/enable_source" 2>/dev/null
121+
ret=$(tr -d ' ' < "$source_node/enable_source")
122+
if [ "$ret" = "0" ]; then
123+
log_fail "FAIL: enable source in $dev_name"
124+
fail=1
125+
continue
126+
fi
127+
fi
128+
129+
sleep 1
130+
131+
reset_coresight
132+
133+
rm -f "/tmp/$sink_dev.bin"
134+
135+
if [ -c "/dev/$sink_dev" ]; then
136+
cat "/dev/$sink_dev" > "/tmp/$sink_dev.bin" 2>/dev/null
137+
outfilesize=$(wc -c < "/tmp/$sink_dev.bin" 2>/dev/null | tr -d ' ')
138+
else
139+
log_warn "Character device /dev/$sink_dev not found! Skipping read."
140+
outfilesize=0
141+
fi
142+
143+
if [ -n "$outfilesize" ] && [ "$outfilesize" -ge 64 ]; then
144+
log_info "Source: $dev_name with trace captured of size $outfilesize bytes"
145+
else
146+
log_fail "Source: $dev_name with no traces captured of size ${outfilesize:-0}"
147+
fail=1
148+
fi
149+
done
150+
done
151+
152+
i=$((i + 1))
153+
done
154+
155+
reset_coresight
156+
157+
for source_node in $sources; do
158+
dev_name=$(basename "$source_node")
159+
if [ -f "$source_node/enable_source" ]; then
160+
ret=$(tr -d ' ' < "$source_node/enable_source")
161+
if [ "$ret" = "1" ]; then
162+
log_fail "fail to disable source in $dev_name during final verification"
163+
fail=1
164+
fi
165+
fi
166+
done
167+
168+
if [ "$fail" -eq 0 ]; then
169+
log_pass "$TESTNAME : Test Passed"
170+
echo "$TESTNAME PASS" > "$res_file"
171+
else
172+
log_fail "$TESTNAME : Test Failed"
173+
echo "$TESTNAME FAIL" > "$res_file"
174+
fi
175+
176+
log_info "---------------------------$TESTNAME Finished---------------------------"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
metadata:
2+
name: Ftrace-Dump-ETF-Base
3+
format: "Lava-Test Test Definition 1.0"
4+
description: "Validates STM trace data flow to an ETF sink through Ftrace. It ensures correct sink selection and verifies successful trace capture by reading ETF output."
5+
os:
6+
- linux
7+
scope:
8+
- coresight
9+
- kernel
10+
11+
run:
12+
steps:
13+
- REPO_PATH=$PWD || true
14+
- cd Runner/suites/Kernel/DEBUG/Ftrace-Dump-ETF-Base || true
15+
- ./run.sh || true
16+
- $REPO_PATH/Runner/utils/send-to-lava.sh Ftrace-Dump-ETF-Base.res || true
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Ftrace-Dump-ETF-Base
2+
3+
## Overview
4+
The `Ftrace-Dump-ETF-Base` test case validates STM trace data flow to an ETF sink through Ftrace. It ensures correct sink selection and verifies successful trace capture by reading ETF output.
5+
6+
## Test Goals
7+
8+
- Verify that the CoreSight sink correctly switches to ETF mode.
9+
- Validate STM trace data routing to ETF via Ftrace integration.
10+
- Ensure sched_switch events are captured and stored in the ETF buffer.
11+
- Confirm valid trace data generation by checking ETF output size.
12+
13+
## Prerequisites
14+
15+
- Coresight framework enabled in the kernel
16+
- Multiple Coresight sink devices should be present
17+
- Coresight STM and ETM device nodes for post-test data generation
18+
19+
## Script Location
20+
21+
```
22+
Runner/suites/Kernel/DEBUG/Ftrace-Dump-ETF-Base/run.sh
23+
```
24+
25+
## Files
26+
27+
- `run.sh` - Main test script
28+
- `Ftrace-Dump-ETF-Base.res` - Summary result file with PASS/FAIL
29+
- `Ftrace-Dump-ETF-Base.log` - Full execution log.
30+
31+
## How it works
32+
1. Mounts required filesystems, resets all CoreSight sources and sinks, and disables any existing tracing.
33+
2. Enables the ETF sink and verifies that the sink switch to ETF is successful.
34+
3. Connects the STM source to Ftrace and enables sched_switch events as the trace input.
35+
4. Starts tracing, allows the system to run for a fixed duration, then stops tracing.
36+
5. Reads trace data from the ETF device and verifies successful capture by checking the output size.
37+
38+
## Usage
39+
40+
Run the script directly. No iterations or special arguments are required for this basic test.
41+
42+
```bash
43+
./run.sh
44+
```
45+
46+
## Example Output
47+
48+
```
49+
[INFO] 2026-04-06 06:19:42 - ---------------------------Ftrace-Dump-ETF-Base Starting---------------------------
50+
[INFO] 2026-04-06 06:19:42 - Using Source: stm0, Sink: tmc_etf0
51+
[INFO] 2026-04-06 06:19:42 - PASS: sink switch to tmc_etf0 successful
52+
[INFO] 2026-04-06 06:19:42 - Linking Ftrace to stm0...
53+
[INFO] 2026-04-06 06:20:03 - Collected bin size: 65536 bytes
54+
[INFO] 2026-04-06 06:20:03 - PASS: tmc_etf0 sink data through Ftrace verified
55+
[INFO] 2026-04-06 06:20:03 - ---------------------------Ftrace-Dump-ETF-Base Finished---------------------------
56+
```
57+
58+
## Return Code
59+
60+
- `0` — All stress test cases passed
61+
- `1` — One or more stress test cases failed
62+
63+
## Integration in CI
64+
65+
- Can be run standalone or via LAVA
66+
- Result file `Ftrace-Dump-ETF-Base.res` will be parsed by `result_parse.sh`
67+
68+
## Notes
69+
70+
- The test relies on Ftrace sched_switch events as the trace data source.
71+
- The test will stop and flag a failure as soon as any sink remains enabled after reset, ensuring strict correctness.
72+
73+
## License
74+
75+
SPDX-License-Identifier: BSD-3-Clause.
76+
(c) Qualcomm Technologies, Inc. and/or its subsidiaries.

0 commit comments

Comments
 (0)