Skip to content

Commit 2245cb4

Browse files
Added ETM Test Mode and ETM Trace test suites for QDSS
- ETM-Test-Mode: validates ETM programming and test mode configuration - ETM-Trace: verifies ETM trace capture and data integrity Signed-off-by: Rohan Dutta <rohadutt@qti.qualcomm.com>
1 parent 89e3067 commit 2245cb4

File tree

6 files changed

+449
-0
lines changed

6 files changed

+449
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
metadata:
2+
name: ETM-Test-Mode
3+
description: "Validates ETM functionality by setting the 'mode' attribute to high (0xFFFFFFF) and enabling the cores."
4+
5+
os:
6+
- linux
7+
devices:
8+
- qcm6490
9+
- qcs9100
10+
scope:
11+
- coresight
12+
- kernel
13+
timeout: 60
14+
15+
run:
16+
steps:
17+
- REPO_PATH=$PWD
18+
- cd Runner/suites/Kernel/DEBUG/ETM-Test-Mode
19+
- ./run.sh || true
20+
- $REPO_PATH/Runner/utils/send-to-lava.sh ETM-Test-Mode.res || true
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# ETM Test Mode
2+
3+
## Overview
4+
This test verifies the stability and write-access of the **ETM (Embedded Trace Macrocell)** `mode` attribute. It sets the mode to `0XFFFFFFF` (enabling various mode bits like cycle-accurate tracing, etc., depending on the hardware revision) and attempts to enable the ETM sources.
5+
6+
## Execution
7+
1. **Discovery**: Scans `/sys/bus/coresight/devices/` for ETM devices (`etm*` or `coresight-etm*`).
8+
2. **Setup**:
9+
* Resets all Coresight sources and sinks.
10+
* Enables `tmc_etr0` as the trace sink.
11+
3. **Test**:
12+
* Iterates through all detected ETM devices.
13+
* Writes `0XFFFFFFF` to the `mode` sysfs attribute.
14+
* Enables the ETM source.
15+
4. **Teardown**:
16+
* Writes `0x0` to the `mode` sysfs attribute (restoring defaults).
17+
* Disables all sources and sinks.
18+
19+
## Output
20+
* Console logs showing detection and configuration of each core.
21+
* `ETM-Test-Mode.res` containing the final Pass/Fail status.
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
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+
fi
26+
27+
# shellcheck disable=SC1090,SC1091
28+
. "$TOOLS/functestlib.sh"
29+
30+
TESTNAME="ETM-Test-Mode"
31+
if command -v find_test_case_by_name >/dev/null 2>&1; then
32+
test_path=$(find_test_case_by_name "$TESTNAME")
33+
cd "$test_path" || exit 1
34+
else
35+
cd "$SCRIPT_DIR" || exit 1
36+
fi
37+
38+
res_file="./$TESTNAME.res"
39+
rm -f "$res_file"
40+
touch "$res_file"
41+
42+
log_info "-----------------------------------------------------------------------------------------"
43+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
44+
45+
CS_BASE="/sys/bus/coresight/devices"
46+
ETR_PATH="$CS_BASE/tmc_etr0"
47+
[ ! -d "$ETR_PATH" ] && ETR_PATH="$CS_BASE/tmc_etr"
48+
49+
reset_source_sink() {
50+
if [ -f "$CS_BASE/stm0/enable_source" ]; then
51+
echo 0 > "$CS_BASE/stm0/enable_source"
52+
fi
53+
54+
# shellcheck disable=SC2086
55+
for etm in $ETM_LIST; do
56+
if [ -f "$etm/enable_source" ]; then
57+
echo 0 > "$etm/enable_source"
58+
fi
59+
done
60+
61+
if [ -f "$ETR_PATH/enable_sink" ]; then
62+
echo 0 > "$ETR_PATH/enable_sink"
63+
fi
64+
if [ -f "$CS_BASE/tmc_etf0/enable_sink" ]; then
65+
echo 0 > "$CS_BASE/tmc_etf0/enable_sink"
66+
fi
67+
}
68+
69+
# shellcheck disable=SC2010
70+
ETM_LIST=$(ls -d "$CS_BASE"/etm* "$CS_BASE"/coresight-etm* 2>/dev/null)
71+
72+
if [ -z "$ETM_LIST" ]; then
73+
log_fail "No Coresight ETM devices found"
74+
echo "$TESTNAME FAIL" > "$res_file"
75+
exit 1
76+
fi
77+
78+
log_info "Found ETM devices: $(echo "$ETM_LIST" | tr '\n' ' ')"
79+
80+
reset_source_sink
81+
82+
if [ -d "$ETR_PATH" ]; then
83+
log_info "Enabling Sink: $ETR_PATH"
84+
echo 1 > "$ETR_PATH/enable_sink"
85+
else
86+
log_fail "TMC-ETR sink not found"
87+
echo "$TESTNAME FAIL" > "$res_file"
88+
exit 1
89+
fi
90+
91+
fail_count=0
92+
no_mode_count=0
93+
etm_total=0
94+
95+
# shellcheck disable=SC2086
96+
for etm in $ETM_LIST; do
97+
etm_total=$((etm_total + 1))
98+
log_info "Configuring $etm"
99+
100+
if [ ! -f "$etm/mode" ]; then
101+
log_fail "$etm does not have 'mode' attribute - required for this test"
102+
fail_count=$((fail_count + 1))
103+
no_mode_count=$((no_mode_count + 1))
104+
continue
105+
fi
106+
107+
echo 0xFFFFFFF > "$etm/mode"
108+
actual_mode=$(cat "$etm/mode" 2>/dev/null)
109+
if [ -z "$actual_mode" ]; then
110+
log_fail "Failed to read back mode from $etm after write"
111+
fail_count=$((fail_count + 1))
112+
continue
113+
fi
114+
actual_dec=$(printf "%d" "$actual_mode" 2>/dev/null)
115+
expect_dec=$(printf "%d" "0xFFFFFFF" 2>/dev/null)
116+
if [ "$actual_dec" != "$expect_dec" ]; then
117+
log_fail "$etm mode readback mismatch: wrote 0xFFFFFFF, read back $actual_mode"
118+
fail_count=$((fail_count + 1))
119+
continue
120+
fi
121+
log_info "$etm mode set and verified: $actual_mode"
122+
123+
if [ -f "$etm/enable_source" ]; then
124+
echo 1 > "$etm/enable_source"
125+
readback=$(cat "$etm/enable_source" 2>/dev/null)
126+
if [ "$readback" != "1" ]; then
127+
log_fail "Failed to enable $etm: enable_source readback=$readback (expected 1)"
128+
fail_count=$((fail_count + 1))
129+
else
130+
log_info "$etm enabled and verified (enable_source=1)"
131+
fi
132+
else
133+
log_warn "$etm has no enable_source attribute, skipping enable step"
134+
fi
135+
done
136+
137+
if [ "$no_mode_count" -eq "$etm_total" ]; then
138+
log_fail "No ETM devices had a 'mode' attribute - test cannot validate ETM mode"
139+
echo "$TESTNAME FAIL" > "$res_file"
140+
elif [ "$fail_count" -eq 0 ]; then
141+
log_pass "ETM Mode Configuration Successful"
142+
echo "$TESTNAME PASS" > "$res_file"
143+
else
144+
log_fail "ETM Mode Configuration Failed ($fail_count errors)"
145+
echo "$TESTNAME FAIL" > "$res_file"
146+
fi
147+
148+
# shellcheck disable=SC2086
149+
for etm in $ETM_LIST; do
150+
if [ -f "$etm/mode" ]; then
151+
echo 0x0 > "$etm/mode"
152+
fi
153+
done
154+
155+
reset_source_sink
156+
157+
# log_info "-------------------$TESTNAME Testcase Finished----------------------------"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
metadata:
2+
name: ETM-Trace-Enable-Disable
3+
description: "Validates the stability of enabling and disabling ETM sources repeatedly and verifies trace data generation."
4+
5+
os:
6+
- linux
7+
devices:
8+
- qcm6490
9+
- qcs9100
10+
scope:
11+
- coresight
12+
- kernel
13+
timeout: 300
14+
15+
run:
16+
steps:
17+
- REPO_PATH=$PWD
18+
- cd Runner/suites/Kernel/DEBUG/ETM-Trace
19+
- ./run.sh || true
20+
- $REPO_PATH/Runner/utils/send-to-lava.sh ETM-Trace.res || true
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# ETM Trace Test
2+
3+
## Overview
4+
This test validates the reliability of the ETM (Embedded Trace Macrocell) drivers by repeatedly enabling and disabling trace sources and verifying that data is successfully written to the sinks.
5+
6+
## Execution Logic
7+
The test iterates through **every available sink** (excluding `tmc_etf1`) and **every available ETM source**.
8+
9+
For each Sink $\leftrightarrow$ Source pair, it performs `N` iterations (default: 2):
10+
1. **Reset**: Disable all Coresight devices.
11+
2. **Enable Sink**: Activate the current sink (e.g., `tmc_etr0`).
12+
3. **Enable Source**: Activate the current ETM (e.g., `etm0`).
13+
4. **Capture**: Sleep for 3 seconds to generate trace data, then dump the content of `/dev/<sink_name>` to a temporary binary file.
14+
5. **Verify**:
15+
* Check if the captured binary file size is $\ge$ 64 bytes.
16+
* Check if the source disabled correctly.
17+
18+
## Usage
19+
Run the script directly or via the runner.
20+
Optional argument: Number of iterations per device pair.
21+
```
22+
./run.sh 5
23+
```
24+
25+
## Output
26+
* Console logs for each iteration.
27+
* `ETM-Trace.res` containing the final Pass/Fail status.

0 commit comments

Comments
 (0)