Skip to content

Commit 32b90ee

Browse files
Added CoreSight TPDM automated scripts
This patch adds 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. Signed-off-by: Rohan Dutta <rohadutt@qti.qualcomm.com>
2 parents 5867b6c + d12c7e0 commit 32b90ee

File tree

12 files changed

+1563
-24
lines changed

12 files changed

+1563
-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: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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+
27+
fi
28+
29+
# shellcheck disable=SC1090,SC1091
30+
. "$TOOLS/functestlib.sh"
31+
# shellcheck disable=SC1090,SC1091
32+
. "$TOOLS/coresight_helper.sh"
33+
34+
TESTNAME="TPDM-Enable-Disable"
35+
res_file="./$TESTNAME.res"
36+
log_info "-----------------------------------------------------------------------------------------"
37+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
38+
CS_BASE="/sys/bus/coresight/devices"
39+
40+
ETF_PATH=$(find_path "tmc_etf0" "tmc_etf" "tmc_etf1" "coresight-tmc_etf" "coresight-tmc_etf0")
41+
if [ -z "$ETF_PATH" ]; then
42+
log_fail "TMC-ETF sink not found. Cannot proceed."
43+
echo "$TESTNAME FAIL" > "$res_file"
44+
exit 1
45+
fi
46+
47+
tpdm_count=0
48+
for node_path in "$CS_BASE"/tpdm* "$CS_BASE"/coresight-tpdm*; do
49+
[ -d "$node_path" ] && tpdm_count=$((tpdm_count + 1))
50+
done
51+
52+
if [ "$tpdm_count" -eq 0 ]; then
53+
log_fail "No TPDM devices found on the system."
54+
echo "$TESTNAME FAIL" > "$res_file"
55+
exit 1
56+
fi
57+
58+
fail=0
59+
i=0
60+
61+
reset_devices
62+
63+
[ -f "$ETF_PATH/enable_sink" ] && echo 1 > "$ETF_PATH/enable_sink" 2>/dev/null
64+
65+
while [ "$i" -le 50 ]; do
66+
iter_fail=0
67+
68+
for node_path in "$CS_BASE"/tpdm* "$CS_BASE"/coresight-tpdm*; do
69+
[ ! -d "$node_path" ] && continue
70+
71+
node_name=$(basename "$node_path")
72+
73+
if echo "$node_name" | grep -q "tpdm-turing-llm"; then
74+
continue
75+
fi
76+
77+
if [ ! -f "$node_path/enable_source" ]; then
78+
continue
79+
fi
80+
81+
echo 1 > "$node_path/enable_source" 2>/dev/null
82+
if [ "$(cat "$node_path/enable_source" 2>/dev/null)" != "1" ]; then
83+
iter_fail=1
84+
log_fail "Iter $i: Failed to enable $node_name"
85+
echo "$TESTNAME FAIL" > "$res_file"
86+
fi
87+
88+
echo 0 > "$node_path/enable_source" 2>/dev/null
89+
if [ "$(cat "$node_path/enable_source" 2>/dev/null)" = "1" ]; then
90+
iter_fail=1
91+
log_fail "Iter $i: Failed to disable $node_name"
92+
echo "$TESTNAME FAIL" > "$res_file"
93+
fi
94+
done
95+
96+
if [ "$iter_fail" -eq 0 ]; then
97+
log_info "Iteration: $i - PASS"
98+
else
99+
log_fail "Iteration: $i - FAIL"
100+
fail=1
101+
fi
102+
103+
i=$((i+1))
104+
done
105+
106+
[ -f "$ETF_PATH/enable_sink" ] && echo 0 > "$ETF_PATH/enable_sink" 2>/dev/null
107+
reset_devices
108+
109+
if [ "$fail" -eq 0 ]; then
110+
log_pass "-------------enable/disable TPDMs Test PASS-------------"
111+
echo "$TESTNAME PASS" > "$res_file"
112+
else
113+
log_fail "-------------enable/disable TPDMs Test FAIL-------------"
114+
echo "$TESTNAME FAIL" > "$res_file"
115+
fi
116+
117+
log_info "-------------------$TESTNAME Testcase Finished----------------------------"
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# TPDM-Interface-Access Test
2+
3+
## Overview
4+
This test performs comprehensive reads across all Trace Profiling and Diagnostics Monitor (TPDM) sysfs interfaces within the Coresight subsystem. It ensures that sysfs nodes correctly expose dataset properties and that interfaces remain securely readable without causing panics or "Invalid argument" responses.
5+
6+
## Test Goals
7+
8+
- Dynamically scan and iterate through all registered TPDM devices in `/sys/bus/coresight/devices/`.
9+
- Validate the dataset map implementation mapping (DSB, CMB, TC, BC, GPR, MCMB).
10+
- Validate dataset configuration properties (e.g. converting hexadecimal active datasets mappings to logical subsystem checks).
11+
- Prevent and detect attribute read failures on dynamically exposed sysfs device interfaces.
12+
13+
## Prerequisites
14+
15+
- Kernel must be built with Coresight TPDM/ETF source support.
16+
- `sysfs` access to `/sys/bus/coresight/devices/`.
17+
- DebugFS access to `/d/npu/ctrl` or `/sys/kernel/debug/npu/ctrl` for TPDM-NPU tests.
18+
- Root privileges (to configure Coresight source elements and access hardware attributes).
19+
20+
## Script Location
21+
22+
```
23+
Runner/suites/Kernel/DEBUG/TPDM-Interface-Access/run.sh
24+
```
25+
26+
## Files
27+
28+
- `run.sh` - Main test script
29+
- `TPDM-Interface-Access.res` - Summary result file with PASS/FAIL
30+
- `TPDM-Interface-Access.log` - Full execution log (generated if logging is enabled via functestlib)
31+
32+
## How It Works
33+
34+
The test uses a two-pronged approach:
35+
36+
1. **Dataset Verification Phase**:
37+
- Dynamically discovers all TPDM nodes.
38+
- Parses the active bit map exposed by the node's `enable_datasets` file.
39+
- Translates the hex output to human-readable subsets (e.g., DSB, CMB).
40+
- Dynamically probes every sysfs file matching the mapped properties to ensure driver readability.
41+
2. **Global Read Validation Phase**:
42+
- Flushes all coresight elements (Resets sinks and sources to `0`).
43+
- Recursively performs standard `cat` reads on every readable (`-r`) generic node under the device.
44+
- Detects node read failures that typically indicate misconfigured kernel data boundaries.
45+
46+
## Usage
47+
48+
Run the script directly. No iterations or special arguments are required for this basic test.
49+
50+
```bash
51+
./run.sh
52+
```
53+
54+
55+
## Example Output
56+
57+
```
58+
[INFO] 2026-03-23 05:56:52 - ------------------------------------------------------
59+
[INFO] 2026-03-23 05:56:52 - Starting Testcase: TPDM-Interface-Access
60+
[INFO] 2026-03-23 05:56:52 - Performing initial device reset...
61+
[INFO] 2026-03-23 05:56:52 - --- Phase 1: Source dataset mode tests ---
62+
[INFO] 2026-03-23 05:56:52 - Testing device: tpdm0
63+
[INFO] 2026-03-23 05:56:52 - Default datasets: (Mode: 00) -> Configurations: none
64+
[INFO] 2026-03-23 05:56:52 - Testing device: tpdm1
65+
[INFO] 2026-03-23 05:56:52 - Default datasets: (Mode: 00) -> Configurations: none
66+
......
67+
[INFO] 2026-03-23 05:56:52 - Testing device: tpdm8
68+
[INFO] 2026-03-23 05:56:52 - Default datasets: (Mode: 00) -> Configurations: none
69+
[INFO] 2026-03-23 05:56:52 - Testing device: tpdm9
70+
[INFO] 2026-03-23 05:56:52 - Default datasets: (Mode: 00) -> Configurations: none
71+
[PASS] 2026-03-23 05:56:52 - Phase 1 Completed: All TPDM mode attributes check passed
72+
[INFO] 2026-03-23 05:56:52 - Performing mid-test device reset...
73+
[INFO] 2026-03-23 05:56:52 - --- Phase 2: Readable attributes check ---
74+
[INFO] 2026-03-23 05:56:52 - Reading 8 accessible nodes under tpdm0
75+
[INFO] 2026-03-23 05:56:52 - Reading 8 accessible nodes under tpdm1
76+
......
77+
[INFO] 2026-03-23 05:56:52 - Reading 8 accessible nodes under tpdm8
78+
[INFO] 2026-03-23 05:56:52 - Reading 8 accessible nodes under tpdm9
79+
[PASS] 2026-03-23 05:56:52 - Result: TPDM-Interface-Access PASS
80+
[INFO] 2026-03-23 05:33:24 - -------------------TPDM-Interface-Access Testcase Finished----------------------------
81+
82+
```
83+
84+
## Return Code
85+
86+
- `0` — All attributes were read successfully without any panics, permission denials, or generic read errors
87+
- `1` — One or more files in the TPDM tree failed to perform a valid return on cat
88+
89+
## Integration in CI
90+
91+
- Can be run standalone or via LAVA
92+
- Result file TPDM-Interface-Access.res will be parsed by result_parse.sh
93+
94+
## Notes
95+
96+
- `tpdm-turing-llm` node paths are hardcoded to be skipped as per hardware testing constraints
97+
- If tpdm-npu is detected, the framework will temporarily write to the NPU debugger control map at /sys/kernel/debug/npu/ctrl
98+
99+
## License
100+
101+
SPDX-License-Identifier: BSD-3-Clause-Clear
102+
(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-Interface-Access
3+
format: "Lava-Test Test Definition 1.0"
4+
description: "Test reading all active and inactive TPDM node interfaces, verifying dataset configurations and sysfs attributes."
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-Interface-Access || true
15+
- ./run.sh || true
16+
- $REPO_PATH/Runner/utils/send-to-lava.sh TPDM-Interface-Access.res || true

0 commit comments

Comments
 (0)