Skip to content

Commit 6ca0019

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 (Trace, Profiling, and Diagnostics Monitor) 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. * 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 6ca0019

File tree

17 files changed

+2056
-24
lines changed

17 files changed

+2056
-24
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# TPDM-Enable-Disable Test
2+
3+
## Overview
4+
5+
This test acts as a stress test for the Coresight Trace Port Debug Module (TPDM) drivers. It repeatedly enables and disables all available TPDM sources to verify the stability and correctness of the toggling mechanism under repeated stress.
6+
7+
## Test Goals
8+
9+
- Validate the stability of the TPDM drivers under repeated enable/disable cycles.
10+
- Ensure all TPDM sources can be successfully toggled without causing system hangs or crashes.
11+
- Verify that sysfs states correctly reflect the enabled/disabled status across multiple rapid transitions.
12+
- Ensure 100% success rate across 50 iterations for pass criteria.
13+
14+
## Prerequisites
15+
16+
- Kernel must be built with Coresight TPDM support.
17+
- `sysfs` access to `/sys/bus/coresight/devices/`.
18+
- Root privileges (to configure source enables).
19+
20+
## Script Location
21+
22+
Runner/suites/Kernel/DEBUG/TPDM-Enable-Disable/run.sh
23+
24+
25+
## Files
26+
27+
- `run.sh` - Main test script
28+
- `TPDM-Enable-Disable.res` - Summary result file with PASS/FAIL
29+
- `TPDM-Enable-Disable.log` - Full execution log (generated if logging is enabled)
30+
31+
## How It Works
32+
33+
1. **Discovery**: Scans `/sys/bus/coresight/devices/` for all available TPDM devices (e.g., `tpdm*`).
34+
2. **Setup**: Resets all Coresight devices to ensure a clean state.
35+
3. **Loop (50 Iterations)**:
36+
- **Enable**: Attempts to enable each discovered TPDM device.
37+
- **Verify**: Confirms the device successfully transitioned to the enabled state.
38+
- **Disable**: Attempts to disable each TPDM device.
39+
- **Verify**: Confirms the device successfully transitioned to the disabled state.
40+
4. **Teardown**: Ensures all devices are left in a disabled, clean state.
41+
42+
## Usage
43+
44+
Run the script directly via the framework:
45+
46+
```bash
47+
./run.sh
48+
```
49+
50+
## Example Output
51+
52+
```
53+
[INFO] 2026-03-23 05:42:18 - -----------------------------------------------------------------------------------------
54+
[INFO] 2026-03-23 05:42:18 - -------------------Starting TPDM-Enable-Disable Testcase----------------------------
55+
[INFO] 2026-03-23 05:42:18 - Iteration: 0 - PASS
56+
[INFO] 2026-03-23 05:42:19 - Iteration: 1 - PASS
57+
[INFO] 2026-03-23 05:42:19 - Iteration: 2 - PASS
58+
[INFO] 2026-03-23 05:42:20 - Iteration: 3 - PASS
59+
[INFO] 2026-03-23 05:42:20 - Iteration: 4 - PASS
60+
.....
61+
[INFO] 2026-03-23 05:42:38 - Iteration: 49 - PASS
62+
[INFO] 2026-03-23 05:42:39 - Iteration: 50 - PASS
63+
[PASS] 2026-03-23 05:42:39 - -------------enable/disable TPDMs Test PASS-------------
64+
[INFO] 2026-03-23 05:42:39 - -------------------TPDM-Enable-Disable Testcase Finished----------------------------
65+
```
66+
67+
## Return Code
68+
69+
- `0` — All 50 iterations successfully enabled and disabled the TPDM sources
70+
- `1` — One or more iterations failed to toggle a source or verify its state
71+
72+
## Integration in CI
73+
74+
- Can be run standalone or via LAVA
75+
76+
- Result file TPDM-Enable-Disable.res will be parsed by result_parse.sh
77+
78+
## Notes
79+
80+
- The test performs exactly 50 iterations specifically to catch intermittent concurrency bugs or resource leaks in the driver's enable/disable path.
81+
82+
- A failure in any single iteration immediately flags the overall test run as a failure.
83+
84+
## License
85+
86+
SPDX-License-Identifier: BSD-3-Clause-Clear
87+
88+
(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-Enable-Disable
3+
format: "Lava-Test Test Definition 1.0"
4+
description: "Script to repeatedly enable and disable all TPDM coresight sources and verify their status."
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-Enable-Disable || true
15+
- ./run.sh || true
16+
- $REPO_PATH/Runner/utils/send-to-lava.sh TPDM-Enable-Disable.res || true
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
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-Enable-Disable"
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."
49+
echo "$TESTNAME FAIL" > "$res_file"
50+
exit 1
51+
fi
52+
53+
reset_devices() {
54+
for node in "$CS_BASE"/*; do
55+
[ -d "$node" ] || continue
56+
[ -f "$node/enable_source" ] && echo 0 > "$node/enable_source" 2>/dev/null
57+
[ -f "$node/enable_sink" ] && echo 0 > "$node/enable_sink" 2>/dev/null
58+
done
59+
}
60+
61+
tpdm_count=0
62+
for node_path in "$CS_BASE"/tpdm* "$CS_BASE"/coresight-tpdm*; do
63+
[ -d "$node_path" ] && tpdm_count=$((tpdm_count + 1))
64+
done
65+
66+
if [ "$tpdm_count" -eq 0 ]; then
67+
log_fail "No TPDM devices found on the system."
68+
echo "$TESTNAME FAIL" > "$res_file"
69+
exit 1
70+
fi
71+
72+
fail=0
73+
i=0
74+
75+
reset_devices
76+
77+
[ -f "$ETF_PATH/enable_sink" ] && echo 1 > "$ETF_PATH/enable_sink" 2>/dev/null
78+
79+
while [ "$i" -le 50 ]; do
80+
iter_fail=0
81+
82+
for node_path in "$CS_BASE"/tpdm* "$CS_BASE"/coresight-tpdm*; do
83+
[ ! -d "$node_path" ] && continue
84+
85+
node_name=$(basename "$node_path")
86+
87+
if echo "$node_name" | grep -q "tpdm-turing-llm"; then
88+
continue
89+
fi
90+
91+
if [ ! -f "$node_path/enable_source" ]; then
92+
continue
93+
fi
94+
95+
echo 1 > "$node_path/enable_source" 2>/dev/null
96+
if [ "$(cat "$node_path/enable_source" 2>/dev/null)" != "1" ]; then
97+
iter_fail=1
98+
log_fail "Iter $i: Failed to enable $node_name"
99+
echo "$TESTNAME FAIL" > "$res_file"
100+
fi
101+
102+
echo 0 > "$node_path/enable_source" 2>/dev/null
103+
if [ "$(cat "$node_path/enable_source" 2>/dev/null)" = "1" ]; then
104+
iter_fail=1
105+
log_fail "Iter $i: Failed to disable $node_name"
106+
echo "$TESTNAME FAIL" > "$res_file"
107+
fi
108+
done
109+
110+
if [ "$iter_fail" -eq 0 ]; then
111+
log_info "Iteration: $i - PASS"
112+
else
113+
log_fail "Iteration: $i - FAIL"
114+
fail=1
115+
fi
116+
117+
i=$((i+1))
118+
done
119+
120+
[ -f "$ETF_PATH/enable_sink" ] && echo 0 > "$ETF_PATH/enable_sink" 2>/dev/null
121+
reset_devices
122+
123+
if [ "$fail" -eq 0 ]; then
124+
log_pass "-------------enable/disable TPDMs Test PASS-------------"
125+
echo "$TESTNAME PASS" > "$res_file"
126+
else
127+
log_fail "-------------enable/disable TPDMs Test FAIL-------------"
128+
echo "$TESTNAME FAIL" > "$res_file"
129+
fi
130+
131+
log_info "-------------------$TESTNAME Testcase Finished----------------------------"
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

0 commit comments

Comments
 (0)