Skip to content

Commit f0fb098

Browse files
Add CTI, TGU, Node Access debug suites
Signed-off-by: Rohan Dutta <rohadutt@qti.qualcomm.com>
1 parent c1054c0 commit f0fb098

File tree

12 files changed

+789
-0
lines changed

12 files changed

+789
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
metadata:
2+
name: CTI-Enable-Disable
3+
description: "Verifies that all Coresight CTI devices can be successfully enabled and disabled via sysfs."
4+
5+
os:
6+
- linux
7+
devices:
8+
- qcm6490
9+
- qcs9100
10+
scope:
11+
- coresight
12+
- kernel
13+
timeout: 60
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
## Execution Logic
7+
1. **Preparation**:
8+
* Disables `stm0`, `tmc_etr0`, and `tmc_etf0` to ensure a clean state.
9+
* Enables `tmc_etf0` (Embedded Trace FIFO) as a sink, as some CTI configurations may require an active sink.
10+
2. **Discovery**: Scans `/sys/bus/coresight/devices/` for any directory containing `cti`.
11+
3. **Iteration**: For each CTI device:
12+
* **Enable**: Writes `1` to the `enable` file.
13+
* **Verify**: Reads the `enable` file; expects `1`.
14+
* **Disable**: Writes `0` to the `enable` file.
15+
* **Verify**: Reads the `enable` file; expects `0`.
16+
4. **Cleanup**: Resets all devices to disabled state.
17+
18+
## Output
19+
* Logs for every device toggle attempt.
20+
* `CTI-Enable-Disable.res` containing the final Pass/Fail status.
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
#!/bin/sh
2+
3+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
# Script to test the QDSS CTI driver.
7+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
8+
INIT_ENV=""
9+
SEARCH="$SCRIPT_DIR"
10+
while [ "$SEARCH" != "/" ]; do
11+
if [ -f "$SEARCH/init_env" ]; then
12+
INIT_ENV="$SEARCH/init_env"
13+
break
14+
fi
15+
SEARCH=$(dirname "$SEARCH")
16+
done
17+
18+
if [ -z "$INIT_ENV" ]; then
19+
echo "[ERROR] Could not find init_env" >&2
20+
exit 1
21+
fi
22+
23+
if [ -z "$__INIT_ENV_LOADED" ]; then
24+
# shellcheck disable=SC1090
25+
. "$INIT_ENV"
26+
fi
27+
28+
# shellcheck disable=SC1090,SC1091
29+
. "$TOOLS/functestlib.sh"
30+
31+
TESTNAME="CTI-Enable-Disable"
32+
if command -v find_test_case_by_name >/dev/null 2>&1; then
33+
test_path=$(find_test_case_by_name "$TESTNAME")
34+
cd "$test_path" || exit 1
35+
else
36+
cd "$SCRIPT_DIR" || exit 1
37+
fi
38+
39+
res_file="./$TESTNAME.res"
40+
rm -f "$res_file"
41+
touch "$res_file"
42+
43+
log_info "-----------------------------------------------------------------------------------------"
44+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
45+
46+
CS_BASE="/sys/bus/coresight/devices"
47+
FAIL_COUNT=0
48+
49+
50+
reset_devices() {
51+
log_info "Resetting Coresight devices..."
52+
if [ -f "$CS_BASE/tmc_etf0/enable_sink" ]; then
53+
echo 0 > "$CS_BASE/tmc_etf0/enable_sink" 2>/dev/null
54+
fi
55+
if [ -f "$CS_BASE/tmc_etr0/enable_sink" ]; then
56+
echo 0 > "$CS_BASE/tmc_etr0/enable_sink" 2>/dev/null
57+
fi
58+
if [ -f "$CS_BASE/stm0/enable_source" ]; then
59+
echo 0 > "$CS_BASE/stm0/enable_source" 2>/dev/null
60+
fi
61+
}
62+
63+
64+
if [ ! -d "$CS_BASE" ]; then
65+
log_fail "Coresight directory not found: $CS_BASE"
66+
echo "Coresight directory not found" >> "$res_file"
67+
exit 1
68+
fi
69+
70+
reset_devices
71+
72+
if [ -f "$CS_BASE/tmc_etf0/enable_sink" ]; then
73+
echo 1 > "$CS_BASE/tmc_etf0/enable_sink"
74+
else
75+
log_warn "tmc_etf0 not found, proceeding without it..."
76+
fi
77+
78+
# shellcheck disable=SC2010
79+
CTI_LIST=$(ls "$CS_BASE" | grep 'cti')
80+
81+
if [ -z "$CTI_LIST" ]; then
82+
log_fail "No CTI devices found."
83+
FAIL_COUNT=$((FAIL_COUNT + 1))
84+
else
85+
for cti in $CTI_LIST; do
86+
dev_path="$CS_BASE/$cti"
87+
88+
if [ ! -f "$dev_path/enable" ]; then
89+
log_warn "Skipping $cti: 'enable' node not found"
90+
continue
91+
fi
92+
93+
log_info "Testing Device: $cti"
94+
95+
if ! echo 1 > "$dev_path/enable"; then
96+
log_fail "$cti: Failed to write 1 to enable"
97+
FAIL_COUNT=$((FAIL_COUNT + 1))
98+
continue
99+
fi
100+
101+
res=$(cat "$dev_path/enable")
102+
if [ "$res" -eq 1 ]; then
103+
log_pass "$cti Enabled Successfully"
104+
else
105+
log_fail "$cti Failed to Enable (Value: $res)"
106+
FAIL_COUNT=$((FAIL_COUNT + 1))
107+
fi
108+
109+
if ! echo 0 > "$dev_path/enable"; then
110+
log_fail "$cti: Failed to write 0 to enable"
111+
FAIL_COUNT=$((FAIL_COUNT + 1))
112+
continue
113+
fi
114+
115+
res=$(cat "$dev_path/enable")
116+
if [ "$res" -eq 0 ]; then
117+
log_pass "$cti Disabled Successfully"
118+
else
119+
log_fail "$cti Failed to Disable (Value: $res)"
120+
FAIL_COUNT=$((FAIL_COUNT + 1))
121+
fi
122+
done
123+
fi
124+
125+
reset_devices
126+
127+
if [ "$FAIL_COUNT" -eq 0 ]; then
128+
log_pass "CTI Enable/Disable Test Completed Successfully"
129+
echo "$TESTNAME: PASS" >> "$res_file"
130+
else
131+
log_fail "CTI Enable/Disable Test Failed ($FAIL_COUNT errors)"
132+
echo "$TESTNAME: FAIL" >> "$res_file"
133+
fi
134+
135+
# log_info "-------------------$TESTNAME Testcase Finished----------------------------"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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
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)