Skip to content

Commit 87f9b75

Browse files
Added CTI, TGU, and Node Access test suites for QDSS
- CTI-Enable-Disable: tests for enabling/disabling Cross Trigger Interface - CTI-Test: functional validation of CTI trigger channels - Node-Access: verifies QDSS debug node accessibility via sysfs - TGU-Enable-Disable: tests for Trigger Generation Unit enable/disable flow Signed-off-by: Rohan Dutta <rohadutt@qti.qualcomm.com>
1 parent 89e3067 commit 87f9b75

File tree

12 files changed

+897
-0
lines changed

12 files changed

+897
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
metadata:
2+
name: CTI-Enable-Disable
3+
format: "Lava-Test Test Definition 1.0"
4+
description: "Verifies that all Coresight CTI devices can be successfully enabled and disabled via sysfs."
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/CTI-Enable-Disable || true
15+
- ./run.sh || true
16+
- $REPO_PATH/Runner/utils/send-to-lava.sh CTI-Enable-Disable.res || true
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Coresight CTI Enable/Disable Test
2+
3+
## Overview
4+
This test validates the basic toggle functionality of the Coresight Cross Trigger Interface (CTI) drivers. It ensures that every CTI device exposed in sysfs can be turned on and off without errors.
5+
6+
## Test Goals
7+
8+
- Validate basic toggle functionality of Coresight CTI drivers.
9+
- Ensure all sysfs-exposed CTI drivers can be enabled and disabled without errors.
10+
- Verify that the device states are correctly reflected in sysfs after toggling.
11+
- Ensure proper cleanup and reset of devices to a clean state after testing.
12+
13+
## Prerequisites
14+
15+
- Kernel must be built with Coresight CTI support.
16+
- `sysfs` access to `/sys/bus/coresight/devices/`.
17+
- Root priviledges needed.
18+
19+
## Script Location
20+
21+
```
22+
Runner/suites/Kernel/DEBUG/CTI-Enable-Disable/run.sh
23+
```
24+
25+
## Files
26+
27+
- `run.sh` - Main test script
28+
- `CTI-Enable-Disable.res` - Summary result file with PASS/FAIL
29+
- `CTI-Enable-Disable.log` - Full execution log.
30+
31+
## Execution Logic
32+
1. **Preparation**:
33+
* Disables `stm0`, `tmc_etr0`, and `tmc_etf0` to ensure a clean state.
34+
* Enables `tmc_etf0` (Embedded Trace FIFO) as a sink, as some CTI configurations may require an active sink.
35+
2. **Discovery**: Scans `/sys/bus/coresight/devices/` for any directory containing `cti`.
36+
3. **Iteration**: For each CTI device:
37+
* **Enable**: Writes `1` to the `enable` file.
38+
* **Verify**: Reads the `enable` file; expects `1`.
39+
* **Disable**: Writes `0` to the `enable` file.
40+
* **Verify**: Reads the `enable` file; expects `0`.
41+
4. **Cleanup**: Resets all devices to disabled state.
42+
43+
## Usage
44+
45+
Run the script directly. No iterations or special arguments are required for this basic test.
46+
47+
```bash
48+
./run.sh
49+
```
50+
51+
## Example Output
52+
53+
```
54+
[INFO] 2026-03-23 10:43:51 - -----------------------------------------------------------------------------------------
55+
[INFO] 2026-03-23 10:43:51 - -------------------Starting CTI-Enable-Disable Testcase----------------------------
56+
[INFO] 2026-03-23 10:43:51 - Saving state and resetting Coresight devices...
57+
[INFO] 2026-03-23 10:43:51 - Testing Device: cti_sys0
58+
[PASS] 2026-03-23 10:43:51 - cti_sys0 Enabled Successfully
59+
[PASS] 2026-03-23 10:43:51 - cti_sys0 Disabled Successfully
60+
[PASS] 2026-03-23 10:43:51 - CTI Enable/Disable Test Completed Successfully
61+
[INFO] 2026-03-23 10:43:51 - Restoring Coresight devices state...
62+
[INFO] 2026-03-23 10:09:51 - -------------------CTI-Enable-Disable Testcase Finished----------------------------
63+
```
64+
65+
## Return Code
66+
67+
- `0` — All CTI devices were toggled successfully
68+
- `1` — One or more CTI devices failed to toggle
69+
70+
## Integration in CI
71+
72+
- Can be run standalone or via LAVA
73+
- Result file `CTI-Enable-Disable.res` will be parsed by `result_parse.sh`
74+
75+
## Notes
76+
77+
- Some CTI cofigurations may require an active sink (like `tmc_etf0`) to function properly, which is handled in the preparation phase.
78+
- Ensure no other trace/debug sessions are actively using the CTI devices before running this test.
79+
80+
## License
81+
82+
SPDX-License-Identifier: BSD-3-Clause.
83+
(c) Qualcomm Technologies, Inc. and/or its subsidiaries.
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
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="CTI-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+
CS_BASE="/sys/bus/coresight/devices"
42+
FAIL_COUNT=0
43+
44+
ORIG_ETF0_SINK=""
45+
ORIG_ETR0_SINK=""
46+
ORIG_STM0_SOURCE=""
47+
48+
save_and_reset_devices() {
49+
log_info "Saving state and resetting Coresight devices..."
50+
if [ -f "$CS_BASE/tmc_etf0/enable_sink" ]; then
51+
ORIG_ETF0_SINK=$(cat "$CS_BASE/tmc_etf0/enable_sink" 2>/dev/null)
52+
echo 0 > "$CS_BASE/tmc_etf0/enable_sink" 2>/dev/null || true
53+
fi
54+
if [ -f "$CS_BASE/tmc_etr0/enable_sink" ]; then
55+
ORIG_ETR0_SINK=$(cat "$CS_BASE/tmc_etr0/enable_sink" 2>/dev/null)
56+
echo 0 > "$CS_BASE/tmc_etr0/enable_sink" 2>/dev/null || true
57+
fi
58+
if [ -f "$CS_BASE/stm0/enable_source" ]; then
59+
ORIG_STM0_SOURCE=$(cat "$CS_BASE/stm0/enable_source" 2>/dev/null)
60+
echo 0 > "$CS_BASE/stm0/enable_source" 2>/dev/null || true
61+
fi
62+
}
63+
64+
cleanup() {
65+
log_info "Restoring Coresight devices state..."
66+
if [ -n "$ORIG_ETF0_SINK" ] && [ -f "$CS_BASE/tmc_etf0/enable_sink" ]; then
67+
echo "$ORIG_ETF0_SINK" > "$CS_BASE/tmc_etf0/enable_sink" 2>/dev/null || true
68+
fi
69+
if [ -n "$ORIG_ETR0_SINK" ] && [ -f "$CS_BASE/tmc_etr0/enable_sink" ]; then
70+
echo "$ORIG_ETR0_SINK" > "$CS_BASE/tmc_etr0/enable_sink" 2>/dev/null || true
71+
fi
72+
if [ -n "$ORIG_STM0_SOURCE" ] && [ -f "$CS_BASE/stm0/enable_source" ]; then
73+
echo "$ORIG_STM0_SOURCE" > "$CS_BASE/stm0/enable_source" 2>/dev/null || true
74+
fi
75+
}
76+
77+
trap cleanup EXIT
78+
79+
if [ ! -d "$CS_BASE" ]; then
80+
log_fail "Coresight directory not found: $CS_BASE"
81+
echo "$TESTNAME FAIL" > "$res_file"
82+
exit 1
83+
fi
84+
85+
save_and_reset_devices
86+
87+
if [ -f "$CS_BASE/tmc_etf0/enable_sink" ]; then
88+
echo 1 > "$CS_BASE/tmc_etf0/enable_sink"
89+
else
90+
log_warn "tmc_etf0 not found, proceeding without it..."
91+
fi
92+
93+
CTI_LIST=""
94+
for _dev in "$CS_BASE"/cti*; do
95+
[ -e "$_dev" ] || continue
96+
CTI_LIST="$CTI_LIST $(basename "$_dev")"
97+
done
98+
99+
if [ -z "$CTI_LIST" ]; then
100+
log_fail "No CTI devices found."
101+
echo "$TESTNAME FAIL" > "$res_file"
102+
exit 1
103+
else
104+
for cti in $CTI_LIST; do
105+
dev_path="$CS_BASE/$cti"
106+
107+
if [ ! -f "$dev_path/enable" ]; then
108+
log_warn "Skipping $cti: 'enable' node not found"
109+
continue
110+
fi
111+
112+
log_info "Testing Device: $cti"
113+
114+
if ! echo 1 > "$dev_path/enable"; then
115+
log_fail "$cti: Failed to write 1 to enable"
116+
FAIL_COUNT=$((FAIL_COUNT + 1))
117+
continue
118+
fi
119+
120+
res=$(cat "$dev_path/enable")
121+
if [ "$res" -eq 1 ]; then
122+
log_pass "$cti Enabled Successfully"
123+
else
124+
log_fail "$cti Failed to Enable (Value: $res)"
125+
FAIL_COUNT=$((FAIL_COUNT + 1))
126+
fi
127+
128+
if ! echo 0 > "$dev_path/enable"; then
129+
log_fail "$cti: Failed to write 0 to enable"
130+
FAIL_COUNT=$((FAIL_COUNT + 1))
131+
continue
132+
fi
133+
134+
res=$(cat "$dev_path/enable")
135+
if [ "$res" -eq 0 ]; then
136+
log_pass "$cti Disabled Successfully"
137+
else
138+
log_fail "$cti Failed to Disable (Value: $res)"
139+
FAIL_COUNT=$((FAIL_COUNT + 1))
140+
fi
141+
done
142+
fi
143+
144+
if [ "$FAIL_COUNT" -eq 0 ]; then
145+
log_pass "CTI Enable/Disable Test Completed Successfully"
146+
echo "$TESTNAME PASS" > "$res_file"
147+
else
148+
log_fail "CTI Enable/Disable Test Failed ($FAIL_COUNT errors)"
149+
echo "$TESTNAME FAIL" > "$res_file"
150+
fi
151+
152+
log_info "-------------------$TESTNAME Testcase Finished----------------------------"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
metadata:
2+
name: CTI-Trigger-Map
3+
description: "Validates Coresight Cross Trigger Interface (CTI) by mapping and unmapping triggers to channels."
4+
5+
os:
6+
- linux
7+
devices:
8+
- qcm6490
9+
- qcs9100
10+
scope:
11+
- coresight
12+
- kernel
13+
timeout: 120
14+
15+
run:
16+
steps:
17+
- REPO_PATH=$PWD
18+
- cd Runner/suites/Kernel/DEBUG/CTI-Test
19+
- ./run.sh || true
20+
- $REPO_PATH/Runner/utils/send-to-lava.sh CTI-Test.res || true
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# CTI Test
2+
3+
## Overview
4+
This test verifies the functionality of the Coresight CTI (Cross Trigger Interface) driver. It ensures that hardware triggers can be successfully mapped (attached) to CTI channels and subsequently unmapped (detached).
5+
6+
## Execution Logic
7+
1. **Sleep Disable**: Temporarily prevents the device from entering low-power modes (`/sys/module/lpm_levels/parameters/sleep_disabled`) to ensure CTI registers are accessible.
8+
2. **Discovery**: Finds all CTI devices in `/sys/bus/coresight/devices/`.
9+
3. **Mode Detection**: Checks for the existence of `enable` sysfs node to determine if the driver uses the Modern or Legacy sysfs interface.
10+
4. **Configuration Parsing**: Reads the `devid` (Modern) or `show_info` (Legacy) to calculate the maximum number of triggers and channels supported by the hardware.
11+
5. **Test Loop**:
12+
* Iterates through a subset of triggers (randomized within valid range).
13+
* Iterates through valid channels.
14+
* **Attach**: writes `channel trigger` to `trigin_attach` / `trigout_attach`.
15+
* **Verify**: Reads back via `chan_xtrigs_sel` and `chan_xtrigs_in`/`out` to confirm mapping.
16+
* **Detach**: Unmaps the trigger and confirms the entry is cleared.
17+
6. **Cleanup**: Restores the original LPM sleep setting.
18+
19+
## Output
20+
* Logs identifying which CTI device, trigger, and channel are being tested.
21+
* `CTI-Trigger-Map.res` containing the final Pass/Fail status.

0 commit comments

Comments
 (0)