Skip to content

Commit 67f4f04

Browse files
Added CoreSight TPDM automated Scripts
This patch adds/updates a suite of automated scripts to validate the functionality and stability of CoreSight TPDM Hardware: * TPDM-Interface-Access: Validates sysfs read/write accessibility for various TPDM dataset modes (DSB, CMB, TC, BC, GPR) to ensure the driver exposes and handles attributes correctly. * TPDM-Enable-Disable: Stress-tests the hardware and driver state machine by repeatedly toggling the TPDM source nodes on and off. * utils/coresight_helper.sh: Common helper functions Signed-off-by: Rohan Dutta <rohadutt@qti.qualcomm.com>
2 parents 5867b6c + d12c7e0 commit 67f4f04

File tree

12 files changed

+1519
-24
lines changed

12 files changed

+1519
-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/DEBUG/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: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
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="TPDM-Integration-Test"
34+
res_file="./$TESTNAME.res"
35+
log_info "-----------------------------------------------------------------------------------------"
36+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
37+
cs_base="/sys/bus/coresight/devices"
38+
39+
etf_path=$(find_path "tmc_etf0" "tmc_etf" "tmc_etf1" "coresight-tmc_etf" "coresight-tmc_etf0")
40+
if [ -z "$etf_path" ]; then
41+
log_fail "TMC-ETF sink not found. Cannot proceed with integration test."
42+
echo "$TESTNAME FAIL" > "$res_file"
43+
exit 1
44+
fi
45+
46+
# shellcheck disable=SC2329
47+
cleanup() {
48+
reset_devices
49+
disable_npu_clocks
50+
}
51+
52+
trap cleanup EXIT INT TERM
53+
54+
reset_devices
55+
enable_npu_clocks
56+
57+
if [ -f "$etf_path/enable_sink" ]; then
58+
echo 1 > "$etf_path/enable_sink" 2>/dev/null
59+
fi
60+
61+
retval=0
62+
tpdm_found=0
63+
64+
for tpdm_path in "$cs_base"/tpdm* "$cs_base"/coresight-tpdm*; do
65+
[ ! -d "$tpdm_path" ] && continue
66+
tpdm_found=1
67+
68+
tpdm_name=$(basename "$tpdm_path")
69+
70+
if [ ! -f "$tpdm_path/integration_test" ]; then
71+
continue
72+
fi
73+
74+
log_info "$tpdm_name Integration Test Start"
75+
76+
if [ -f "$tpdm_path/enable_source" ]; then
77+
echo 1 > "$tpdm_path/enable_source" 2>/dev/null
78+
fi
79+
80+
pre_rwp=""
81+
if [ -f "$etf_path/mgmt/rwp" ]; then
82+
# shellcheck disable=SC2162
83+
read -r pre_rwp < "$etf_path/mgmt/rwp"
84+
fi
85+
86+
i=1
87+
while [ "$i" -le 10 ]; do
88+
echo 1 > "$tpdm_path/integration_test" 2>/dev/null
89+
echo 2 > "$tpdm_path/integration_test" 2>/dev/null
90+
i=$((i+1))
91+
done
92+
93+
curr_rwp=""
94+
if [ -f "$etf_path/mgmt/rwp" ]; then
95+
# shellcheck disable=SC2162
96+
read -r curr_rwp < "$etf_path/mgmt/rwp"
97+
fi
98+
99+
if [ -n "$curr_rwp" ] && [ "$curr_rwp" != "$pre_rwp" ]; then
100+
log_info "$tpdm_name Integration Test PASS"
101+
else
102+
log_fail "$tpdm_name Integration Test FAIL"
103+
retval=1
104+
fi
105+
106+
if [ -f "$tpdm_path/enable_source" ]; then
107+
echo 0 > "$tpdm_path/enable_source" 2>/dev/null
108+
fi
109+
done
110+
111+
if [ "$tpdm_found" -eq 0 ]; then
112+
log_fail "FAIL: No TPDM device found"
113+
echo "$TESTNAME FAIL" > "$res_file"
114+
retval=1
115+
fi
116+
117+
if [ "$retval" -eq 0 ]; then
118+
log_pass "-----PASS: All TPDM devices integration test-----"
119+
echo "$TESTNAME PASS" > "$res_file"
120+
else
121+
log_fail "----FAIL: Some TPDM devices integration test fail----"
122+
echo "$TESTNAME FAIL" > "$res_file"
123+
fi
124+
125+
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 captured from the sink's character device node by validating the generation of a non-empty trace file.
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/DEBUG/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)