Skip to content

Commit b3817be

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 b3817be

File tree

15 files changed

+1377
-0
lines changed

15 files changed

+1377
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
metadata:
2+
name: ETM-Enable-Disable
3+
format: "Lava-Test Test Definition 1.0"
4+
description: "Verifies the activation and deactivation functionality of Embedded
5+
Trace Macrocell (ETM) devices. This test individually enables and disables
6+
each ETM via its sysfs 'enable_source' node, followed by testing bulk enable
7+
and disable operations across all cores simultaneously."
8+
os:
9+
- linux
10+
scope:
11+
- coresight
12+
- kernel
13+
14+
run:
15+
steps:
16+
- REPO_PATH=$PWD || true
17+
- cd Runner/suites/Kernel/DEBUG/ETM-Enable-Disable || true
18+
- ./run.sh || true
19+
- $REPO_PATH/Runner/utils/send-to-lava.sh ETM-Enable-Disable.res || true
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# ETM-Enable-Disable Test
2+
3+
## Overview
4+
5+
This test validates the user-space sysfs interface for activating and deactivating Embedded Trace Macrocells (ETM). It ensures that the kernel properly handles ETM component state transitions by evaluating individual enable/disable cycles, as well as bulk enable and bulk disable sequences.
6+
7+
## Test Goals
8+
9+
Validate the user-space sysfs interface for ETM activation and deactivation.
10+
Ensure the kernel properly handles individual enable/disable cycles for each CoreSight ETM device.
11+
Verify bulk enable sequences (activating all ETMs simultaneously).
12+
Verify bulk disable sequences (deactivating all ETMs simultaneously).
13+
14+
## Prerequisites
15+
16+
Kernel must be built with CoreSight core and ETM drivers.
17+
CoreSight ETM Devices (etm* or coresight-etm*) must be present.
18+
A valid sink like tmc_etf0 (or default tmc_etf) must be available.
19+
sysfs must be mounted and accessible.
20+
Root privileges (to write to sysfs nodes).
21+
22+
## Script Location
23+
24+
```
25+
Runner/suites/Kernel/DEBUG/ETM-Enable-Disable/run.sh
26+
```
27+
28+
## Files
29+
30+
- `run.sh` - Main test script
31+
- `ETM-Enable-Disable.res` - Summary result file with PASS/FAIL based on aggregated results
32+
- `ETM-Enable-Disable.log` - Full execution log (generated if logging is enabled)
33+
34+
## How It Works
35+
36+
1. **Discovery**: The script automatically queries the sysfs coresight bus to build a list of available ETMs.
37+
2. **Individual Testing**: Performs individual enable and disable cycles for each detected CoreSight ETM device.
38+
3. **Bulk Enable**: Executes a sequence to activate all discovered ETMs simultaneously.
39+
4. **Bulk Disable**: Executes a sequence to deactivate all discovered ETMs simultaneously.
40+
5. **Evaluation**: Evaluates the success of both individual and bulk operations, logging the status transitions.
41+
42+
## Usage
43+
44+
The script automatically queries the `sysfs` coresight bus to build a list of available ETMs and performs the transitions without requiring manual arguments.
45+
46+
```bash
47+
./run.sh
48+
```
49+
50+
## Example Output
51+
52+
```
53+
[INFO] 2026-03-17 11:37:15 - -----------------------------------------------------------------------------------------
54+
[INFO] 2026-03-17 11:37:15 - -------------------Starting ETM-Enable-Disable Testcase----------------------------
55+
[INFO] 2026-03-17 11:37:15 - /sys/bus/coresight/devices/etm0 initial status: 0
56+
[INFO] 2026-03-17 11:37:15 - enable /sys/bus/coresight/devices/etm0 PASS
57+
[INFO] 2026-03-17 11:37:15 - disable /sys/bus/coresight/devices/etm0 PASS
58+
......
59+
[INFO] 2026-03-17 11:43:27 - Testing etm_enable_all_cores...
60+
[INFO] 2026-03-17 11:43:28 - Testing etm_disable_all_cores...
61+
[PASS] 2026-03-17 11:43:28 - ETM enable and disable test end: PASS
62+
[INFO] 2026-03-17 11:43:28 - -------------------ETM-Enable-Disable Testcase Finished----------------------------
63+
```
64+
65+
## Return Code
66+
67+
- `0` — All individual and bulk ETM state transitions completed successfully
68+
- `1` — One or more ETM state transitions failed
69+
70+
## Integration in CI
71+
72+
- Can be run standalone or via LAVA
73+
- Result file ETM-Enable-Disable.res will be parsed by result_parse.sh
74+
75+
## Notes
76+
- This test does not require manual arguments as it automatically detects the available CoreSight topology.
77+
78+
## License
79+
SPDX-License-Identifier: BSD-3-Clause-Clear
80+
(c) Qualcomm Technologies, Inc. and/or its subsidiaries.
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
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-Enable-Disable"
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+
log_info "-----------------------------------------------------------------------------------------"
40+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
41+
42+
CS_BASE="/sys/bus/coresight/devices"
43+
44+
find_path() {
45+
for _dir_name in "$@"; do
46+
if [ -d "$CS_BASE/$_dir_name" ]; then
47+
echo "$CS_BASE/$_dir_name"
48+
return 0
49+
fi
50+
done
51+
echo ""
52+
}
53+
54+
ETF_PATH=$(find_path "tmc_etf0" "tmc_etf" "tmc_etf1" "coresight-tmc_etf" "coresight-tmc_etf0")
55+
if [ -z "$ETF_PATH" ]; then
56+
log_fail "TMC-ETF sink not found. Cannot proceed."
57+
echo "$TESTNAME FAIL: No ETF sink found" >> "$res_file"
58+
exit 1
59+
fi
60+
61+
ETM_LIST=""
62+
for _etm in "$CS_BASE"/etm* "$CS_BASE"/coresight-etm* "$CS_BASE"/coresight-ete*; do
63+
[ -d "$_etm" ] || continue
64+
ETM_LIST="$ETM_LIST $_etm"
65+
done
66+
67+
if [ -z "$ETM_LIST" ]; then
68+
log_fail "No Coresight ETM devices found"
69+
echo "$TESTNAME: FAIL" >> "$res_file"
70+
exit 1
71+
fi
72+
73+
fail_count=0
74+
75+
reset_devices() {
76+
for dev in "$CS_BASE"/*; do
77+
[ -d "$dev" ] || continue
78+
if [ -f "$dev/enable_source" ]; then
79+
echo 0 > "$dev/enable_source" 2>/dev/null
80+
fi
81+
if [ -f "$dev/enable_sink" ]; then
82+
echo 0 > "$dev/enable_sink" 2>/dev/null
83+
fi
84+
done
85+
}
86+
87+
reset_devices
88+
89+
log_info "Enabling ETF Sink at $ETF_PATH"
90+
echo 1 > "$ETF_PATH/enable_sink" 2>/dev/null
91+
92+
for etm in $ETM_LIST; do
93+
if [ -f "$etm/enable_source" ]; then
94+
res=$(cat "$etm/enable_source" 2>/dev/null)
95+
log_info "$etm initial status: ${res:-unknown}"
96+
97+
echo 1 > "$etm/enable_source" 2>/dev/null
98+
res=$(cat "$etm/enable_source" 2>/dev/null)
99+
100+
if [ "$res" = "1" ]; then
101+
log_info "enable $etm PASS"
102+
else
103+
log_fail "enable $etm FAIL"
104+
fail_count=$((fail_count + 1))
105+
fi
106+
107+
echo 0 > "$etm/enable_source" 2>/dev/null
108+
res=$(cat "$etm/enable_source" 2>/dev/null)
109+
110+
if [ "$res" = "0" ]; then
111+
log_info "disable $etm PASS"
112+
else
113+
log_fail "disable $etm FAIL"
114+
fail_count=$((fail_count + 1))
115+
fi
116+
fi
117+
done
118+
119+
log_info "Testing etm_enable_all_cores..."
120+
for etm in $ETM_LIST; do
121+
if [ -f "$etm/enable_source" ]; then
122+
echo 1 > "$etm/enable_source" 2>/dev/null
123+
fi
124+
done
125+
126+
for etm in $ETM_LIST; do
127+
if [ -f "$etm/enable_source" ]; then
128+
res=$(cat "$etm/enable_source" 2>/dev/null)
129+
if [ "$res" != "1" ]; then
130+
log_fail "Failed to enable $etm during all_cores test"
131+
fail_count=$((fail_count + 1))
132+
fi
133+
fi
134+
done
135+
136+
log_info "Testing etm_disable_all_cores..."
137+
for etm in $ETM_LIST; do
138+
if [ -f "$etm/enable_source" ]; then
139+
echo 0 > "$etm/enable_source" 2>/dev/null
140+
fi
141+
done
142+
143+
for etm in $ETM_LIST; do
144+
if [ -f "$etm/enable_source" ]; then
145+
res=$(cat "$etm/enable_source" 2>/dev/null)
146+
if [ "$res" != "0" ]; then
147+
log_fail "Failed to disable $etm during all_cores test"
148+
fail_count=$((fail_count + 1))
149+
fi
150+
fi
151+
done
152+
153+
reset_devices
154+
155+
if [ "$fail_count" -eq 0 ]; then
156+
log_pass "ETM enable and disable test end: PASS"
157+
echo "$TESTNAME: PASS" >> "$res_file"
158+
else
159+
log_fail "ETM enable and disable test end: FAIL ($fail_count errors)"
160+
echo "$TESTNAME: FAIL" >> "$res_file"
161+
fi
162+
163+
log_info "-------------------$TESTNAME Testcase Finished----------------------------"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
metadata:
2+
name: ETM-Register
3+
format: "Lava-Test Test Definition 1.0"
4+
description: "Verifies read access to ETM (Embedded Trace Macrocell) registers
5+
located in the sysfs management (mgmt) and base directories. Validates that
6+
the registers can be read without errors while the ETM is active."
7+
os:
8+
- linux
9+
scope:
10+
- coresight
11+
- kernel
12+
13+
run:
14+
steps:
15+
- REPO_PATH=$PWD || true
16+
- cd Runner/suites/Kernel/DEBUG/ETM-Register || true
17+
- ./run.sh || true
18+
- $REPO_PATH/Runner/utils/send-to-lava.sh ETM-Register.res || true
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# ETM-Register Test
2+
3+
## Overview
4+
5+
This test case validates the readability of the CoreSight Embedded Trace Macrocell (ETM) sysfs registers. It iterates through all available ETM devices, temporarily enables them as trace sources with an active sink (ETF), and attempts to read their management (mgmt) and base node configurations to ensure they are accessible without throwing I/O or kernel errors.
6+
7+
## Test Goals
8+
9+
- Validate the readability of CoreSight ETM sysfs registers.
10+
- Ensure management (mgmt) and base node configurations are accessible.
11+
- Verify that reading these registers while the source is active does not cause I/O errors or kernel panics.
12+
- Confirm smooth transition and sequential testing across multiple ETM devices.
13+
14+
## Prerequisites
15+
16+
- Kernel must be built with `CoreSight ETM` and TMC drivers.
17+
- `CoreSight ETM` sources (etm* or coresight-etm*) must be present.
18+
- A valid TMC sink, such as tmc_etf0 (or generic tmc_etf), must be available.
19+
- `sysfs` must be mounted and accessible at `/sys`.
20+
- Root privileges (to write to sysfs nodes and configure sources/sinks).
21+
22+
## Script Location
23+
24+
```
25+
Runner/suites/Kernel/DEBUG/ETM-Register/run.sh
26+
```
27+
28+
## Files
29+
30+
- `run.sh` - Main test script
31+
- `ETM-Register.res` - Summary result file with PASS/FAIL based on whether all mgmt registers were successfully read
32+
- `ETM-Register.log` - Full execution log (generated if logging is enabled)
33+
34+
## How It Works
35+
36+
1. **Discovery**: The script automatically discovers all available ETM devices and the designated ETF sink in the sysfs directory.
37+
2. **Iteration**: For each discovered ETM device:
38+
- **Setup**: Temporarily enables the tmc_etf sink.
39+
- **Enable Source**: Enables the current ETM device as a trace source.
40+
- **Read Registers**: Attempts to read the management (mgmt/) registers and base node configurations for the active ETM.
41+
- **Verification**: Checks that the read operations succeed without throwing I/O errors or kernel issues.
42+
- **Teardown**: Disables the ETM source and the sink before moving to the next device.
43+
44+
## Usage
45+
46+
The script automatically discovers available ETM devices and tests them sequentially. No manual arguments are required.
47+
48+
```bash
49+
./run.sh
50+
```
51+
52+
## Example Output
53+
54+
```
55+
[INFO] 2026-03-17 11:29:22 - -----------------------------------------------------------------------------------------
56+
[INFO] 2026-03-17 11:29:22 - -------------------Starting ETM-Register Testcase----------------------------
57+
[INFO] 2026-03-17 11:29:22 - Found 8 ETM devices
58+
[INFO] 2026-03-17 11:29:22 - Testing ETM node: /sys/bus/coresight/devices/etm0
59+
[INFO] 2026-03-17 11:29:23 - Testing ETM node: /sys/bus/coresight/devices/etm1
60+
[INFO] 2026-03-17 11:29:23 - Testing ETM node: /sys/bus/coresight/devices/etm2
61+
[INFO] 2026-03-17 11:29:23 - Testing ETM node: /sys/bus/coresight/devices/etm3
62+
[INFO] 2026-03-17 11:29:23 - Testing ETM node: /sys/bus/coresight/devices/etm4
63+
[INFO] 2026-03-17 11:29:23 - Testing ETM node: /sys/bus/coresight/devices/etm5
64+
[INFO] 2026-03-17 11:29:23 - Testing ETM node: /sys/bus/coresight/devices/etm6
65+
[INFO] 2026-03-17 11:29:24 - Testing ETM node: /sys/bus/coresight/devices/etm7
66+
[PASS] 2026-03-17 11:29:24 - ETM Register Read Test Successful
67+
[INFO] 2026-03-17 11:29:24 - -------------------ETM-Register Testcase Finished----------------------------
68+
```
69+
70+
## Return Code
71+
72+
- `0` — All management registers across all ETM devices were successfull read without errors
73+
- `1` — One or more register read attempts threw an I/O error or failed
74+
75+
## Integration in CI
76+
77+
- Can be run standalone or via LAVA
78+
- Result file ETM-Register.res will be parsed by result_parse.sh
79+
80+
## Notes
81+
82+
- The test specifically enables the ETM device as an active trace source before reading the registers to ensure access is valid under active tracing conditions.
83+
84+
## License
85+
86+
SPDX-License-Identifier: BSD-3-Clause-Clear
87+
(c) Qualcomm Technologies, Inc. and/or its subsidiaries.

0 commit comments

Comments
 (0)