Skip to content

Commit 19876b4

Browse files
Added QDSS-QPMDA / HW Events automated scripts
This patch adds/updates a suite of automated scripts to validate the functionality of QDSS_QPMDA / HW Events. * TPDM-Integration-Test: Verifies that TPDM nodes can be successfully linked to CoreSight sinks and that the overarching trace path is correctly established. * TPDM-Trace-Sink: Validates end-to-end data generation and routing by enabling TPDMs, generating trace data, and verifying that the data can be successfully extracted from the /dev/ node of the targeted sink. Signed-off-by: Rohan Dutta <rohadutt@qti.qualcomm.com>
2 parents 5867b6c + d12c7e0 commit 19876b4

File tree

11 files changed

+1497
-24
lines changed

11 files changed

+1497
-24
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# TPDM Integration Test
2+
3+
## Overview
4+
5+
This test acts as an integration validation for the Coresight Trace Port Debug Module (TPDM). It verifies actual trace data generation and routing by artificially injecting data into the TPDM's `integration_test` nodes and confirming that the data successfully reaches the trace sink (ETF) by monitoring its internal Read/Write Pointer (`mgmt/rwp`).
6+
7+
## Test Goals
8+
9+
- Verify the end-to-end trace generation and routing capabilities of TPDM devices.
10+
- Inject artificial trace data using the Coresight `integration_test` sysfs nodes.
11+
- Validate that the injected trace data successfully reaches the TMC-ETF sink.
12+
- Confirm success by observing a change in the ETF's `mgmt/rwp` (Read/Write Pointer) register value, which indicates data was written to the FIFO.
13+
14+
## Prerequisites
15+
16+
- Kernel must be built with Coresight TPDM and TMC (ETF) support.
17+
- `sysfs` access to `/sys/bus/coresight/devices/`.
18+
- Root privileges (to configure devices and write to `integration_test` nodes).
19+
20+
## Script Location
21+
22+
```
23+
Runner/suites/Kernel/FunctionalArea/coresight/TPDM-Integration-Test/run.sh
24+
```
25+
26+
## Files
27+
28+
- `run.sh` - Main test script
29+
- `TPDM-Integration-Test.res` - Summary result file with PASS/FAIL
30+
- `TPDM-Integration-Test.log` - Full execution log (generated if logging is enabled)
31+
32+
## How It Works
33+
34+
1. **Setup**: Resets the Coresight topology to a clean state.
35+
2. **Enable**: Activates the `tmc_etf0` (or available ETF) sink and the target TPDM source.
36+
3. **Baseline**: Reads and stores the initial value of the ETF's `mgmt/rwp` register.
37+
4. **Injection**: Writes dummy/test data to the TPDM's `integration_test` sysfs node to force trace generation.
38+
5. **Verification**: Reads the ETF's `mgmt/rwp` register again. The test passes if the new value is different from the baseline value (proving data flowed into the sink).
39+
6. **Teardown**: Disables the TPDM and ETF devices.
40+
41+
## Example Output
42+
43+
```
44+
[INFO] 2026-03-23 05:33:24 - ------------------------------------------------------
45+
[INFO] 2026-03-23 05:33:24 - ----- Coresight TPDM integration Test Starting -----
46+
[INFO] 2026-03-23 05:33:24 - tpdm0 Integration Test Start
47+
[INFO] 2026-03-23 05:33:24 - tpdm0 Integration Test PASS
48+
[INFO] 2026-03-23 05:33:24 - tpdm1 Integration Test Start
49+
[INFO] 2026-03-23 05:33:24 - tpdm1 Integration Test PASS
50+
....
51+
[INFO] 2026-03-23 05:33:24 - tpdm9 Integration Test Start
52+
[INFO] 2026-03-23 05:33:24 - tpdm9 Integration Test PASS
53+
[PASS] 2026-03-23 05:33:24 - -----PASS: All TPDM devices integration test-----
54+
[INFO] 2026-03-23 05:33:24 - -------------------TPDM-Integration-Test Testcase Finished----------------------------
55+
```
56+
57+
## Return Code
58+
59+
- `0` — The `mgmt/rwp` value changed successfully after data injection (PASS)
60+
- `1` — The `mgmt/rwp` value did not change, indicating trace data was lost or not generated (FAIL)
61+
62+
## Integration in CI
63+
64+
- Can be run standalone or via LAVA
65+
- Result file `TPDM-Integration-Test.res` will be parsed by `result_parse.sh`
66+
67+
## Notes
68+
69+
- The `mgmt/rwp` (Read/Write Pointer) is a hardware register in the Trace Memory Controller (TMC) that increments as trace data is written into its SRAM/FIFO. Checking this register is a reliable, lightweight way to verify data flow without needing to dump and parse the entire binary trace buffer.
70+
71+
## License
72+
73+
SPDX-License-Identifier: BSD-3-Clause-Clear
74+
(c) Qualcomm Technologies, Inc. and/or its subsidiaries.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
metadata:
2+
name: TPDM-Integration-Test
3+
format: "Lava-Test Test Definition 1.0"
4+
description: "Coresight TPDM integration test script to verify trace generation by writing to integration_test nodes and verifying the ETF mgmt/rwp changes."
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/TPDM-Integration-Test || true
15+
- ./run.sh || true
16+
- $REPO_PATH/Runner/utils/send-to-lava.sh TPDM-Integration-Test.res || true
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
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="TPDM-Integration-Test"
31+
res_file="./$TESTNAME.res"
32+
log_info "-----------------------------------------------------------------------------------------"
33+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
34+
CS_BASE="/sys/bus/coresight/devices"
35+
36+
find_path() {
37+
for _dir_name in "$@"; do
38+
if [ -d "$CS_BASE/$_dir_name" ]; then
39+
echo "$CS_BASE/$_dir_name"
40+
return 0
41+
fi
42+
done
43+
echo ""
44+
}
45+
46+
ETF_PATH=$(find_path "tmc_etf0" "tmc_etf" "tmc_etf1" "coresight-tmc_etf" "coresight-tmc_etf0")
47+
if [ -z "$ETF_PATH" ]; then
48+
log_fail "TMC-ETF sink not found. Cannot proceed with integration test."
49+
echo "$TESTNAME FAIL" > "$res_file"
50+
exit 1
51+
fi
52+
53+
NPU_CLK="/d/npu/ctrl"
54+
[ ! -f "$NPU_CLK" ] && NPU_CLK="/sys/kernel/debug/npu/ctrl"
55+
56+
reset_devices() {
57+
for node in "$CS_BASE"/*; do
58+
[ -d "$node" ] || continue
59+
[ -f "$node/enable_source" ] && echo 0 > "$node/enable_source" 2>/dev/null
60+
[ -f "$node/enable_sink" ] && echo 0 > "$node/enable_sink" 2>/dev/null
61+
done
62+
}
63+
64+
# shellcheck disable=SC2329
65+
cleanup() {
66+
reset_devices
67+
if [ -f "$NPU_CLK" ]; then
68+
echo off > "$NPU_CLK" 2>/dev/null
69+
fi
70+
}
71+
72+
trap cleanup EXIT INT TERM
73+
74+
reset_devices
75+
76+
if [ -f "$NPU_CLK" ]; then
77+
echo on > "$NPU_CLK" 2>/dev/null
78+
fi
79+
80+
if [ -f "$ETF_PATH/enable_sink" ]; then
81+
echo 1 > "$ETF_PATH/enable_sink" 2>/dev/null
82+
fi
83+
84+
retval=0
85+
tpdm_found=0
86+
87+
for tpdm_path in "$CS_BASE"/tpdm* "$CS_BASE"/coresight-tpdm*; do
88+
[ ! -d "$tpdm_path" ] && continue
89+
tpdm_found=1
90+
91+
tpdm_name=$(basename "$tpdm_path")
92+
93+
if [ ! -f "$tpdm_path/integration_test" ]; then
94+
continue
95+
fi
96+
97+
log_info "$tpdm_name Integration Test Start"
98+
99+
if [ -f "$tpdm_path/enable_source" ]; then
100+
echo 1 > "$tpdm_path/enable_source" 2>/dev/null
101+
fi
102+
103+
pre_rwp=""
104+
if [ -f "$ETF_PATH/mgmt/rwp" ]; then
105+
# shellcheck disable=SC2162
106+
read -r pre_rwp < "$ETF_PATH/mgmt/rwp"
107+
fi
108+
109+
i=1
110+
while [ "$i" -le 10 ]; do
111+
echo 1 > "$tpdm_path/integration_test" 2>/dev/null
112+
echo 2 > "$tpdm_path/integration_test" 2>/dev/null
113+
i=$((i+1))
114+
done
115+
116+
curr_rwp=""
117+
if [ -f "$ETF_PATH/mgmt/rwp" ]; then
118+
# shellcheck disable=SC2162
119+
read -r curr_rwp < "$ETF_PATH/mgmt/rwp"
120+
fi
121+
122+
if [ -n "$curr_rwp" ] && [ "$curr_rwp" != "$pre_rwp" ]; then
123+
log_info "$tpdm_name Integration Test PASS"
124+
else
125+
log_fail "$tpdm_name Integration Test FAIL"
126+
retval=1
127+
fi
128+
129+
if [ -f "$tpdm_path/enable_source" ]; then
130+
echo 0 > "$tpdm_path/enable_source" 2>/dev/null
131+
fi
132+
done
133+
134+
if [ "$tpdm_found" -eq 0 ]; then
135+
log_fail "FAIL: No TPDM device found"
136+
echo "$TESTNAME FAIL" > "$res_file"
137+
fi
138+
139+
if [ "$retval" -eq 0 ]; then
140+
log_pass "-----PASS: All TPDM devices integration test-----"
141+
echo "$TESTNAME PASS" > "$res_file"
142+
else
143+
log_fail "----FAIL: Some TPDM devices integration test fail----"
144+
echo "$TESTNAME FAIL" > "$res_file"
145+
fi
146+
147+
log_info "-------------------$TESTNAME Testcase Finished----------------------------"
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# TPDM-Trace-Sink Test
2+
3+
## Overview
4+
5+
This test script evaluates the enabling and disabling sequence of all available Coresight TPDM sources against all available TMC trace sinks. It automatically dumps the raw binary trace data generated by the sink `/dev/` nodes into the `/tmp` directory. It purposefully ignores the `tmc_etf1` sink and `tpdm-turing-llm` source.
6+
7+
## Test Goals
8+
9+
- Evaluate the enabling and disabling sequence of Coresight TPDM sources against TMC sinks.
10+
- Verify that `enable_source` sysfs nodes accurately reflect read/write state transitions.
11+
- Ensure raw binary trace data can be successfully read from the sink's character device node.
12+
- Validate stability across multiple iterations for all compatible source/sink device pairs.
13+
14+
## Prerequisites
15+
16+
- Kernel must be built with Coresight TPDM and TMC support.
17+
- `sysfs` access to `/sys/bus/coresight/devices/`.
18+
- Access to read from sink character devices (e.g., `/dev/tmc_etf0`).
19+
- Root privileges (to configure Coresight devices and read trace data).
20+
21+
## Script Location
22+
23+
```
24+
Runner/suites/Kernel/FunctionalArea/coresight/TPDM-Trace-Sink/run.sh
25+
```
26+
27+
## Files
28+
29+
- `run.sh` - Main test script
30+
- `TPDM-Trace-Sink.res` - Summary result file with PASS/FAIL
31+
- `TPDM-Trace-Sink.log` - Full execution log (generated if logging is enabled)
32+
33+
## How It Works
34+
35+
1. **Iterations**: Runs the entire evaluation loop 2 times (loop 0 and 1).
36+
2. **Discovery**:
37+
- Discovers all TMC sinks (`/sys/bus/coresight/devices/tmc_et*`), explicitly ignoring `tmc_etf1`.
38+
- Discovers all TPDM sources (`/sys/bus/coresight/devices/tpdm*`), explicitly ignoring `tpdm-turing-llm`.
39+
3. **Execution Loop** (For each compatible Sink <-> Source pair):
40+
- Executes `reset_source_sink` to cleanly clear out active sources and sinks.
41+
- Enables the current TMC trace sink by writing `1` to `enable_sink`.
42+
- Enables the current TPDM source by writing `1` to `enable_source`.
43+
- Verifies that reading from the TPDM's `enable_source` returns `1`.
44+
- Reads the trace payload from `/dev/<sink_dev>` and redirects it to `/tmp/<sink_dev>.bin`.
45+
- Disables the current TPDM source by writing `0` to `enable_source`.
46+
- Verifies that reading from the TPDM's `enable_source` returns `0`.
47+
4. **Teardown**: Performs a final `reset_source_sink` to clean up the environment post-testing.
48+
49+
## Example Output
50+
51+
```
52+
[INFO] 2026-03-23 06:16:46 - -----------------------------------------------------------------------------------------
53+
[INFO] 2026-03-23 06:16:46 - -------------------Starting TPDM-Trace-Sink Testcase----------------------------
54+
[INFO] 2026-03-23 06:16:46 - Performing initial device reset...
55+
[INFO] 2026-03-23 06:16:46 - [Iteration 0] Starting sink evaluation...
56+
[INFO] 2026-03-23 06:16:46 - Testing Sink: tmc_etf0
57+
[INFO] 2026-03-23 06:16:46 - Enabled source: tpdm0
58+
[INFO] 2026-03-23 06:16:47 - Enabled source: tpdm1
59+
[INFO] 2026-03-23 06:16:48 - Enabled source: tpdm10
60+
[INFO] 2026-03-23 06:16:49 - Enabled source: tpdm2
61+
[INFO] 2026-03-23 06:16:50 - Enabled source: tpdm3
62+
.......
63+
[INFO] 2026-03-23 06:17:50 - Enabled source: tpdm5
64+
[INFO] 2026-03-23 06:17:51 - Enabled source: tpdm6
65+
[INFO] 2026-03-23 06:17:52 - Enabled source: tpdm7
66+
[INFO] 2026-03-23 06:17:53 - Enabled source: tpdm8
67+
[INFO] 2026-03-23 06:17:54 - Enabled source: tpdm9
68+
[PASS] 2026-03-23 06:17:55 - TPDM-Trace-Sink: PASS
69+
[INFO] 2026-03-23 06:17:55 - -------------------TPDM-Trace-Sink Testcase Finished----------------------------
70+
```
71+
72+
## Return Code
73+
74+
- `0` — All iterations and compatible device pairs successfully wrote/verified states and the fail flag remained `0`
75+
- `1` — A failure occurred during enablement, disablement, verification, or trace data capture
76+
77+
## Integration in CI
78+
79+
- Can be run standalone or via LAVA
80+
- Result file `TPDM-Trace-Sink.res` will be parsed by `result_parse.sh`
81+
82+
## Notes
83+
84+
- `tmc_etf1` and `tpdm-turing-llm` are hardcoded to be ignored in this specific test script to prevent known incompatibilities or access violations.
85+
86+
## License
87+
88+
SPDX-License-Identifier: BSD-3-Clause-Clear
89+
(c) Qualcomm Technologies, Inc. and/or its subsidiaries.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
metadata:
2+
name: TPDM-Trace-Sink
3+
format: "Lava-Test Test Definition 1.0"
4+
description: "Iterates over available TMC trace sinks (excluding tmc_etf1) and TPDM sources (excluding turing-llm), enables them, dumps sink trace data to /tmp, and safely disables them."
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/TPDM-Trace-Sink || true
15+
- ./run.sh || true
16+
- $REPO_PATH/Runner/utils/send-to-lava.sh TPDM-Trace-Sink.res || true

0 commit comments

Comments
 (0)