Skip to content

Commit c1054c0

Browse files
Add DEBUG folder
Signed-off-by: Rohan Dutta <rohadutt@qti.qualcomm.com>
1 parent 89e3067 commit c1054c0

12 files changed

Lines changed: 741 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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
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+
```bash
17+
./run.sh
18+
```
19+
20+
## Result
21+
A result.res file is generated
22+
```bash
23+
MultiSource_tmc_etf0: Pass
24+
MultiSource_tmc_etr0: Pass
25+
```
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 (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+
30+
TESTNAME="MultiSource-STM-ETM"
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+
rm -f "$res_file"
40+
touch "$res_file"
41+
42+
log_info "-----------------------------------------------------------------------------------------"
43+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
44+
log_info "=== Test Initialization ==="
45+
log_info "Checking if required tools are available"
46+
47+
CS_BASE="/sys/bus/coresight/devices"
48+
CPU_PATH="/sys/devices/system/cpu/cpu"
49+
CORES=$(grep -c "processor" /proc/cpuinfo)
50+
STM_PATH="$CS_BASE/stm0"
51+
[ ! -d "$STM_PATH" ] && STM_PATH="$CS_BASE/coresight-stm"
52+
53+
reset_source_sink() {
54+
# shellcheck disable=SC2045
55+
for dev in $(ls "$CS_BASE"); do
56+
path="$CS_BASE/$dev"
57+
if [ -f "$path/enable_source" ]; then
58+
val=$(cat "$path/enable_source")
59+
if [ "$val" -eq 1 ]; then
60+
echo 0 > "$path/enable_source"
61+
[ -f "$path/reset" ] && echo 1 > "$path/reset"
62+
fi
63+
fi
64+
if [ -f "$path/enable_sink" ]; then
65+
val=$(cat "$path/enable_sink")
66+
[ "$val" -eq 1 ] && echo 0 > "$path/enable_sink"
67+
fi
68+
done
69+
}
70+
71+
toggle_etm_all() {
72+
state=$1
73+
count=0
74+
while [ "$count" -lt "$CORES" ]; do
75+
[ -f "$CPU_PATH$count/online" ] && echo 1 > "$CPU_PATH$count/online"
76+
77+
if [ -d "$CS_BASE/ete$count" ]; then
78+
etm_path="$CS_BASE/ete$count/enable_source"
79+
elif [ -d "$CS_BASE/coresight-ete$count" ]; then
80+
etm_path="$CS_BASE/coresight-ete$count/enable_source"
81+
elif [ -d "$CS_BASE/etm$count" ]; then
82+
etm_path="$CS_BASE/etm$count/enable_source"
83+
elif [ -d "$CS_BASE/coresight-etm$count" ]; then
84+
etm_path="$CS_BASE/coresight-etm$count/enable_source"
85+
else
86+
count=$((count + 1))
87+
continue
88+
fi
89+
90+
[ -f "$etm_path" ] && echo "$state" > "$etm_path"
91+
count=$((count + 1))
92+
done
93+
}
94+
95+
reset_source_sink
96+
toggle_etm_all 0
97+
98+
# shellcheck disable=SC2010
99+
SINKS=$(ls "$CS_BASE" | grep "tmc_et" | grep -v "tmc_etf1")
100+
101+
if [ -z "$SINKS" ]; then
102+
log_fail "No suitable TMC sinks found"
103+
echo "$TESTNAME: FAIL" >> "$res_file"
104+
exit 1
105+
fi
106+
107+
for sinkname in $SINKS; do
108+
log_info "Testing Sink: $sinkname"
109+
110+
reset_source_sink
111+
OUTPUT_BIN="/tmp/$sinkname.bin"
112+
rm -f "$OUTPUT_BIN"
113+
114+
if [ -f "$CS_BASE/$sinkname/enable_sink" ]; then
115+
echo 1 > "$CS_BASE/$sinkname/enable_sink"
116+
else
117+
log_warn "Sink $sinkname enable file not found"
118+
echo "$TESTNAME: FAIL" >> "$res_file"
119+
continue
120+
fi
121+
122+
toggle_etm_all 1
123+
124+
if [ -f "$STM_PATH/enable_source" ]; then
125+
echo 1 > "$STM_PATH/enable_source"
126+
else
127+
log_warn "STM source not found"
128+
fi
129+
130+
if [ -c "/dev/$sinkname" ]; then
131+
timeout 2s cat "/dev/$sinkname" > "$OUTPUT_BIN"
132+
fi
133+
134+
if [ -f "$OUTPUT_BIN" ]; then
135+
bin_size=$(stat -c%s "$OUTPUT_BIN")
136+
if [ "$bin_size" -ge 64 ]; then
137+
log_pass "Captured $bin_size bytes from $sinkname"
138+
echo "$TESTNAME: PASS" >> "$res_file"
139+
else
140+
log_fail "Captured data too small ($bin_size bytes) from $sinkname"
141+
echo "$TESTNAME: FAIL" >> "$res_file"
142+
fi
143+
else
144+
log_fail "No output file generated for $sinkname"
145+
echo "$TESTNAME: FAIL" >> "$res_file"
146+
fi
147+
148+
toggle_etm_all 0
149+
done
150+
151+
reset_source_sink
152+
# log_info "-------------------$TESTNAME Testcase Finished----------------------------"
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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
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="STM-HWE-PORT-SWITCH"
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+
rm -f "$res_file"
40+
touch "$res_file"
41+
42+
log_info "-----------------------------------------------------------------------------------------"
43+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
44+
45+
CS_BASE="/sys/bus/coresight/devices"
46+
STM_PATH="$CS_BASE/stm0"
47+
[ ! -d "$STM_PATH" ] && STM_PATH="$CS_BASE/coresight-stm"
48+
ETF_PATH="$CS_BASE/tmc_etf0"
49+
ETR_PATH="$CS_BASE/tmc_etr0"
50+
DEBUGFS="/sys/kernel/debug/tracing"
51+
52+
reset_source_sink() {
53+
if [ -f "$STM_PATH/enable_source" ]; then
54+
echo 0 > "$STM_PATH/enable_source"
55+
fi
56+
if [ -f "$ETF_PATH/enable_sink" ]; then
57+
echo 0 > "$ETF_PATH/enable_sink"
58+
fi
59+
if [ -f "$ETR_PATH/enable_sink" ]; then
60+
echo 0 > "$ETR_PATH/enable_sink"
61+
fi
62+
if [ -f "$DEBUGFS/tracing_on" ]; then
63+
echo 0 > "$DEBUGFS/tracing_on"
64+
fi
65+
}
66+
67+
test_attribute() {
68+
attr_name=$1
69+
attr_path="$STM_PATH/$attr_name"
70+
71+
log_info "Testing Attribute: $attr_name"
72+
73+
if [ ! -f "$attr_path" ]; then
74+
log_warn "Attribute $attr_name not found at $STM_PATH"
75+
return 0
76+
fi
77+
78+
for stm_state in 0 1; do
79+
echo "$stm_state" > "$STM_PATH/enable_source"
80+
81+
for val in 0 1; do
82+
echo "$val" > "$attr_path"
83+
readback=$(cat "$attr_path")
84+
85+
86+
if [ "$attr_name" = "hwevent_enable" ]; then
87+
if [ "$readback" -eq "$val" ]; then
88+
log_pass "STM_Src:$stm_state | $attr_name set to $val"
89+
else
90+
log_fail "STM_Src:$stm_state | Failed to set $attr_name to $val (Read: $readback)"
91+
echo "$TESTNAME: FAIL" >> "$res_file"
92+
return 1
93+
fi
94+
elif [ "$attr_name" = "port_enable" ]; then
95+
if [ "$val" -eq 1 ] && [ "$readback" != "0" ] && [ "$readback" != "0x0" ]; then
96+
log_pass "STM_Src:$stm_state | $attr_name set to $val"
97+
elif [ "$val" -eq 0 ] && [ "$readback" = "0" ]; then
98+
log_pass "STM_Src:$stm_state | $attr_name set to $val"
99+
elif [ "$val" -eq 0 ] && [ "$readback" = "0x0" ]; then
100+
log_pass "STM_Src:$stm_state | $attr_name set to $val"
101+
else
102+
log_fail "STM_Src:$stm_state | Failed to set $attr_name to $val (Read: $readback)"
103+
echo "$TESTNAME: FAIL" >> "$res_file"
104+
return 1
105+
fi
106+
fi
107+
done
108+
done
109+
110+
echo "$TESTNAME: PASS" >> "$res_file"
111+
return 0
112+
}
113+
114+
115+
if [ ! -d "$STM_PATH" ]; then
116+
log_fail "STM device not found"
117+
echo "$TESTNAME: FAIL" >> "$res_file"
118+
exit 1
119+
fi
120+
121+
log_info "Creating Policy Directories..."
122+
mkdir -p /sys/kernel/config/stp-policy/stm0:p_ost.policy/default
123+
124+
reset_source_sink
125+
126+
if [ -f "$ETF_PATH/enable_sink" ]; then
127+
echo 1 > "$ETF_PATH/enable_sink"
128+
fi
129+
130+
test_attribute "hwevent_enable"
131+
test_attribute "port_enable"
132+
133+
reset_source_sink
134+
135+
if [ -f "$STM_PATH/hwevent_enable" ]; then
136+
echo 0 > "$STM_PATH/hwevent_enable"
137+
fi
138+
if [ -f "$STM_PATH/port_enable" ]; then
139+
echo 0xffffffff > "$STM_PATH/port_enable"
140+
fi
141+
142+
# log_info "-------------------$TESTNAME Testcase Finished----------------------------"

0 commit comments

Comments
 (0)