Skip to content

Commit 56032b1

Browse files
Added QDSS STM and TMC support in DEBUG suite
- MultiSource-STM-ETM: validates STM and ETM multi-source trace configuration - Sink-Status-STM-Toggle: tests STM sink status and toggle functionality - STM-HWE-PORT-SWITCH: verifies STM hardware event port switching - STM-Source-Enable-Disable: tests STM source enable/disable via sysfs - Added coresight_common.sh utility for shared functions Signed-off-by: Rohan Dutta <rohadutt@qti.qualcomm.com>
1 parent 89e3067 commit 56032b1

File tree

13 files changed

+892
-0
lines changed

13 files changed

+892
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
metadata:
2+
name: MultiSource-STM-ETM
3+
description: "Validates concurrent STM and ETM trace collection across multiple cores."
4+
5+
os:
6+
- linux
7+
devices:
8+
- qcm6490
9+
- qcs9100
10+
scope:
11+
- coresight
12+
- kernel
13+
timeout: 300
14+
15+
run:
16+
steps:
17+
- REPO_PATH=$PWD
18+
- cd Runner/suites/Kernel/DEBUG/MultiSource-STM-ETM
19+
- ./run.sh || true
20+
- $REPO_PATH/Runner/utils/send-to-lava.sh MultiSource-STM-ETM.res || true
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Multi-Source STM + ETM Test
2+
3+
## Description
4+
This test verifies the Coresight subsystem's ability to handle simultaneous trace data from:
5+
1. **STM (System Trace Macrocell)**: Software events.
6+
2. **ETM (Embedded Trace Macrocell)**: Instruction trace from all online CPUs.
7+
8+
It iterates through available sinks (e.g., `tmc_etf0`, `tmc_etr0`) and checks if valid binary data is captured.
9+
10+
## Dependencies
11+
- **Library**: `Runner/utils/coresight_common.sh`
12+
- **Kernel Config**: `CONFIG_CORESIGHT`, `CONFIG_CORESIGHT_STM`, `CONFIG_CORESIGHT_LINK_AND_SINK_TMC`.
13+
14+
## Execution
15+
Run the script directly:
16+
```
17+
./run.sh
18+
```
19+
20+
## Result
21+
A MultiSource-STM-ETM.res file is generated
22+
```
23+
MultiSource_tmc_etf0: Pass
24+
MultiSource_tmc_etr0: Pass
25+
```
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
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 (starting at $SCRIPT_DIR)" >&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+
# shellcheck disable=SC1090,SC1091
30+
. "$TOOLS/coresight_common.sh"
31+
32+
TESTNAME="MultiSource-STM-ETM"
33+
if command -v find_test_case_by_name >/dev/null 2>&1; then
34+
test_path=$(find_test_case_by_name "$TESTNAME")
35+
cd "$test_path" || exit 1
36+
else
37+
cd "$SCRIPT_DIR" || exit 1
38+
fi
39+
40+
res_file="./$TESTNAME.res"
41+
rm -f "$res_file"
42+
touch "$res_file"
43+
44+
log_info "-----------------------------------------------------------------------------------------"
45+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
46+
log_info "=== Test Initialization ==="
47+
log_info "Checking if required tools are available"
48+
49+
for tool in timeout stat; do
50+
if ! command -v "$tool" >/dev/null 2>&1; then
51+
log_skip "Required tool '$tool' not found. Skipping test."
52+
echo "$TESTNAME SKIP" > "$res_file"
53+
exit 0
54+
fi
55+
done
56+
57+
CPU_PATH="/sys/devices/system/cpu/cpu"
58+
CORES=$(grep -c "processor" /proc/cpuinfo)
59+
STM_PATH="$CS_BASE/stm0"
60+
[ ! -d "$STM_PATH" ] && STM_PATH="$CS_BASE/coresight-stm"
61+
62+
# --- Helpers ---
63+
64+
toggle_etm_all() {
65+
_state=$1
66+
_count=0
67+
while [ "$_count" -lt "$CORES" ]; do
68+
69+
if [ -f "${CPU_PATH}${_count}/online" ]; then
70+
if [ "$(cat "${CPU_PATH}${_count}/online")" -eq 0 ]; then
71+
log_info "CPU $_count is offline, skipping ETM toggle for this core."
72+
_count=$((_count + 1))
73+
continue
74+
fi
75+
fi
76+
77+
if [ -d "$CS_BASE/ete$_count" ]; then
78+
_etm="$CS_BASE/ete$_count/enable_source"
79+
elif [ -d "$CS_BASE/coresight-ete$_count" ]; then
80+
_etm="$CS_BASE/coresight-ete$_count/enable_source"
81+
elif [ -d "$CS_BASE/etm$_count" ]; then
82+
_etm="$CS_BASE/etm$_count/enable_source"
83+
elif [ -d "$CS_BASE/coresight-etm$_count" ]; then
84+
_etm="$CS_BASE/coresight-etm$_count/enable_source"
85+
else
86+
_count=$((_count + 1))
87+
continue
88+
fi
89+
90+
[ -f "$_etm" ] && echo "$_state" > "$_etm"
91+
_count=$((_count + 1))
92+
done
93+
}
94+
95+
# --- Preflight ---
96+
97+
cs_check_base || { echo "$TESTNAME FAIL" > "$res_file"; exit 1; }
98+
99+
# Reset all sources and sinks before starting
100+
cs_global_reset
101+
toggle_etm_all 0
102+
103+
# shellcheck disable=SC2010
104+
SINKS=""
105+
for _d in "$CS_BASE"/tmc_et* "$CS_BASE"/coresight-tmc-et*; do
106+
[ -d "$_d" ] || continue
107+
_name="${_d##*/}"
108+
[ "$_name" = "tmc_etf1" ] && continue
109+
[ -f "$_d/enable_sink" ] || continue
110+
SINKS="$SINKS $_name"
111+
done
112+
SINKS="${SINKS# }"
113+
114+
if [ -z "$SINKS" ]; then
115+
log_fail "No suitable TMC sinks found"
116+
echo "$TESTNAME FAIL" > "$res_file"
117+
exit 1
118+
fi
119+
120+
for sinkname in $SINKS; do
121+
log_info "Testing Sink: $sinkname"
122+
123+
cs_global_reset
124+
OUTPUT_BIN="/tmp/$sinkname.bin"
125+
rm -f "$OUTPUT_BIN"
126+
127+
if ! cs_enable_sink "$sinkname"; then
128+
log_warn "Sink $sinkname enable_sink node not found"
129+
echo "$TESTNAME FAIL" > "$res_file"
130+
continue
131+
fi
132+
133+
toggle_etm_all 1
134+
135+
if [ -f "$STM_PATH/enable_source" ]; then
136+
echo 1 > "$STM_PATH/enable_source"
137+
else
138+
log_warn "STM source not found"
139+
fi
140+
141+
[ -c "/dev/$sinkname" ] && timeout 2s cat "/dev/$sinkname" > "$OUTPUT_BIN"
142+
143+
if [ -f "$OUTPUT_BIN" ]; then
144+
bin_size=$(stat -c%s "$OUTPUT_BIN")
145+
if [ "$bin_size" -ge 64 ]; then
146+
log_pass "Captured $bin_size bytes from $sinkname"
147+
echo "$TESTNAME PASS" > "$res_file"
148+
else
149+
log_fail "Captured data too small ($bin_size bytes) from $sinkname"
150+
echo "$TESTNAME FAIL" > "$res_file"
151+
fi
152+
else
153+
log_fail "No output file generated for $sinkname"
154+
echo "$TESTNAME FAIL" > "$res_file"
155+
fi
156+
157+
toggle_etm_all 0
158+
done
159+
160+
cs_global_reset
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# STM-HWE-PORT-SWITCH Test
2+
3+
## Overview
4+
This test verifies that the **STM (System Trace Macrocell)** attributes `hwevent_enable` and `port_enable` can be successfully toggled (0 and 1) via sysfs, regardless of whether the main STM source (`enable_source`) is currently active or inactive.
5+
6+
## Execution
7+
1. **Setup**:
8+
* Creates STP policy directories.
9+
* Resets Coresight devices.
10+
* Enables `tmc_etf0` as the sink.
11+
2. **Test Loop (Run for both `hwevent_enable` and `port_enable`)**:
12+
* **Outer Loop**: Toggles STM `enable_source` (0, then 1).
13+
* **Inner Loop**: Toggles the target attribute (0, then 1).
14+
* **Verification**: Reads back the attribute value to ensure it matches the written value.
15+
3. **Teardown**:
16+
* Resets all devices.
17+
* Restores `hwevent_enable` to `0`.
18+
* Restores `port_enable` to `0xffffffff` (all ports enabled).
19+
20+
## Output
21+
* Console logs detailing the read/write operations.
22+
* `STM-HWEvent-Port-Enable-Disable.res` containing Pass/Fail status for each attribute.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
metadata:
2+
name: STM-HWEvent-Port-Enable-Disable
3+
description: "Validates the ability to enable and disable STM Hardware Events and Ports via sysfs."
4+
5+
os:
6+
- linux
7+
devices:
8+
- qcm6490
9+
- qcs9100
10+
scope:
11+
- coresight
12+
- kernel
13+
timeout: 60
14+
15+
run:
16+
steps:
17+
- REPO_PATH=$PWD
18+
- cd Runner/suites/Kernel/DEBUG/STM-HWE-PORT-SWITCH
19+
- ./run.sh || true
20+
- $REPO_PATH/Runner/utils/send-to-lava.sh STM-HWE-PORT-SWITCH.res || true

0 commit comments

Comments
 (0)