From c1054c01c48c623f31177050cbc2c36a7d175561 Mon Sep 17 00:00:00 2001 From: Rohan Dutta Date: Wed, 18 Feb 2026 16:03:49 +0530 Subject: [PATCH 1/2] Add DEBUG folder Signed-off-by: Rohan Dutta --- .../MultiSource-STM-ETM.yaml | 13 ++ .../DEBUG/MultiSource-STM-ETM/README.md | 25 +++ .../Kernel/DEBUG/MultiSource-STM-ETM/run.sh | 152 +++++++++++++++ .../DEBUG/STM-HWE-PORT-SWITCH/README.md | 22 +++ .../STM-HWE-PORT-SWITCH.yaml | 13 ++ .../Kernel/DEBUG/STM-HWE-PORT-SWITCH/run.sh | 142 ++++++++++++++ .../DEBUG/STM-Source-Enable-Disable/README.md | 20 ++ .../STM-Source-Enable-Disable.yaml | 13 ++ .../DEBUG/STM-Source-Enable-Disable/run.sh | 126 +++++++++++++ .../DEBUG/Sink-Status-STM-Toggle/README.md | 28 +++ .../Sink-Status-STM-Toggle.yaml | 13 ++ .../DEBUG/Sink-Status-STM-Toggle/run.sh | 174 ++++++++++++++++++ 12 files changed, 741 insertions(+) create mode 100644 Runner/suites/Kernel/DEBUG/MultiSource-STM-ETM/MultiSource-STM-ETM.yaml create mode 100644 Runner/suites/Kernel/DEBUG/MultiSource-STM-ETM/README.md create mode 100644 Runner/suites/Kernel/DEBUG/MultiSource-STM-ETM/run.sh create mode 100644 Runner/suites/Kernel/DEBUG/STM-HWE-PORT-SWITCH/README.md create mode 100644 Runner/suites/Kernel/DEBUG/STM-HWE-PORT-SWITCH/STM-HWE-PORT-SWITCH.yaml create mode 100644 Runner/suites/Kernel/DEBUG/STM-HWE-PORT-SWITCH/run.sh create mode 100644 Runner/suites/Kernel/DEBUG/STM-Source-Enable-Disable/README.md create mode 100644 Runner/suites/Kernel/DEBUG/STM-Source-Enable-Disable/STM-Source-Enable-Disable.yaml create mode 100644 Runner/suites/Kernel/DEBUG/STM-Source-Enable-Disable/run.sh create mode 100644 Runner/suites/Kernel/DEBUG/Sink-Status-STM-Toggle/README.md create mode 100644 Runner/suites/Kernel/DEBUG/Sink-Status-STM-Toggle/Sink-Status-STM-Toggle.yaml create mode 100644 Runner/suites/Kernel/DEBUG/Sink-Status-STM-Toggle/run.sh diff --git a/Runner/suites/Kernel/DEBUG/MultiSource-STM-ETM/MultiSource-STM-ETM.yaml b/Runner/suites/Kernel/DEBUG/MultiSource-STM-ETM/MultiSource-STM-ETM.yaml new file mode 100644 index 00000000..221e8ba0 --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/MultiSource-STM-ETM/MultiSource-STM-ETM.yaml @@ -0,0 +1,13 @@ +metadata: + name: MultiSource-STM-ETM + description: "Validates concurrent STM and ETM trace collection across multiple cores." + + os: + - linux + devices: + - qcm6490 + - qcs9100 + scope: + - coresight + - kernel + timeout: 300 \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/MultiSource-STM-ETM/README.md b/Runner/suites/Kernel/DEBUG/MultiSource-STM-ETM/README.md new file mode 100644 index 00000000..db11cf4e --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/MultiSource-STM-ETM/README.md @@ -0,0 +1,25 @@ +# Multi-Source STM + ETM Test + +## Description +This test verifies the Coresight subsystem's ability to handle simultaneous trace data from: +1. **STM (System Trace Macrocell)**: Software events. +2. **ETM (Embedded Trace Macrocell)**: Instruction trace from all online CPUs. + +It iterates through available sinks (e.g., `tmc_etf0`, `tmc_etr0`) and checks if valid binary data is captured. + +## Dependencies +- **Library**: `Runner/utils/coresight_common.sh` +- **Kernel Config**: `CONFIG_CORESIGHT`, `CONFIG_CORESIGHT_STM`, `CONFIG_CORESIGHT_LINK_AND_SINK_TMC`. + +## Execution +Run the script directly: +```bash +./run.sh +``` + +## Result +A result.res file is generated +```bash +MultiSource_tmc_etf0: Pass +MultiSource_tmc_etr0: Pass +``` \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/MultiSource-STM-ETM/run.sh b/Runner/suites/Kernel/DEBUG/MultiSource-STM-ETM/run.sh new file mode 100644 index 00000000..a1fc608b --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/MultiSource-STM-ETM/run.sh @@ -0,0 +1,152 @@ +#!/bin/sh + +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + fi + SEARCH=$(dirname "$SEARCH") +done + +if [ -z "$INIT_ENV" ]; then + echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2 + exit 1 +fi + +if [ -z "$__INIT_ENV_LOADED" ]; then + # shellcheck disable=SC1090 + . "$INIT_ENV" +fi + +# shellcheck disable=SC1090,SC1091 +. "$TOOLS/functestlib.sh" + +TESTNAME="MultiSource-STM-ETM" +if command -v find_test_case_by_name >/dev/null 2>&1; then + test_path=$(find_test_case_by_name "$TESTNAME") + cd "$test_path" || exit 1 +else + cd "$SCRIPT_DIR" || exit 1 +fi + +res_file="./$TESTNAME.res" +rm -f "$res_file" +touch "$res_file" + +log_info "-----------------------------------------------------------------------------------------" +log_info "-------------------Starting $TESTNAME Testcase----------------------------" +log_info "=== Test Initialization ===" +log_info "Checking if required tools are available" + +CS_BASE="/sys/bus/coresight/devices" +CPU_PATH="/sys/devices/system/cpu/cpu" +CORES=$(grep -c "processor" /proc/cpuinfo) +STM_PATH="$CS_BASE/stm0" +[ ! -d "$STM_PATH" ] && STM_PATH="$CS_BASE/coresight-stm" + +reset_source_sink() { + # shellcheck disable=SC2045 + for dev in $(ls "$CS_BASE"); do + path="$CS_BASE/$dev" + if [ -f "$path/enable_source" ]; then + val=$(cat "$path/enable_source") + if [ "$val" -eq 1 ]; then + echo 0 > "$path/enable_source" + [ -f "$path/reset" ] && echo 1 > "$path/reset" + fi + fi + if [ -f "$path/enable_sink" ]; then + val=$(cat "$path/enable_sink") + [ "$val" -eq 1 ] && echo 0 > "$path/enable_sink" + fi + done +} + +toggle_etm_all() { + state=$1 + count=0 + while [ "$count" -lt "$CORES" ]; do + [ -f "$CPU_PATH$count/online" ] && echo 1 > "$CPU_PATH$count/online" + + if [ -d "$CS_BASE/ete$count" ]; then + etm_path="$CS_BASE/ete$count/enable_source" + elif [ -d "$CS_BASE/coresight-ete$count" ]; then + etm_path="$CS_BASE/coresight-ete$count/enable_source" + elif [ -d "$CS_BASE/etm$count" ]; then + etm_path="$CS_BASE/etm$count/enable_source" + elif [ -d "$CS_BASE/coresight-etm$count" ]; then + etm_path="$CS_BASE/coresight-etm$count/enable_source" + else + count=$((count + 1)) + continue + fi + + [ -f "$etm_path" ] && echo "$state" > "$etm_path" + count=$((count + 1)) + done +} + +reset_source_sink +toggle_etm_all 0 + +# shellcheck disable=SC2010 +SINKS=$(ls "$CS_BASE" | grep "tmc_et" | grep -v "tmc_etf1") + +if [ -z "$SINKS" ]; then + log_fail "No suitable TMC sinks found" + echo "$TESTNAME: FAIL" >> "$res_file" + exit 1 +fi + +for sinkname in $SINKS; do + log_info "Testing Sink: $sinkname" + + reset_source_sink + OUTPUT_BIN="/tmp/$sinkname.bin" + rm -f "$OUTPUT_BIN" + + if [ -f "$CS_BASE/$sinkname/enable_sink" ]; then + echo 1 > "$CS_BASE/$sinkname/enable_sink" + else + log_warn "Sink $sinkname enable file not found" + echo "$TESTNAME: FAIL" >> "$res_file" + continue + fi + + toggle_etm_all 1 + + if [ -f "$STM_PATH/enable_source" ]; then + echo 1 > "$STM_PATH/enable_source" + else + log_warn "STM source not found" + fi + + if [ -c "/dev/$sinkname" ]; then + timeout 2s cat "/dev/$sinkname" > "$OUTPUT_BIN" + fi + + if [ -f "$OUTPUT_BIN" ]; then + bin_size=$(stat -c%s "$OUTPUT_BIN") + if [ "$bin_size" -ge 64 ]; then + log_pass "Captured $bin_size bytes from $sinkname" + echo "$TESTNAME: PASS" >> "$res_file" + else + log_fail "Captured data too small ($bin_size bytes) from $sinkname" + echo "$TESTNAME: FAIL" >> "$res_file" + fi + else + log_fail "No output file generated for $sinkname" + echo "$TESTNAME: FAIL" >> "$res_file" + fi + + toggle_etm_all 0 +done + +reset_source_sink +# log_info "-------------------$TESTNAME Testcase Finished----------------------------" \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/STM-HWE-PORT-SWITCH/README.md b/Runner/suites/Kernel/DEBUG/STM-HWE-PORT-SWITCH/README.md new file mode 100644 index 00000000..5828f597 --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/STM-HWE-PORT-SWITCH/README.md @@ -0,0 +1,22 @@ +# STM-HWE-PORT-SWITCH Test + +## Overview +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. + +## Execution +1. **Setup**: + * Creates STP policy directories. + * Resets Coresight devices. + * Enables `tmc_etf0` as the sink. +2. **Test Loop (Run for both `hwevent_enable` and `port_enable`)**: + * **Outer Loop**: Toggles STM `enable_source` (0, then 1). + * **Inner Loop**: Toggles the target attribute (0, then 1). + * **Verification**: Reads back the attribute value to ensure it matches the written value. +3. **Teardown**: + * Resets all devices. + * Restores `hwevent_enable` to `0`. + * Restores `port_enable` to `0xffffffff` (all ports enabled). + +## Output +* Console logs detailing the read/write operations. +* `STM-HWEvent-Port-Enable-Disable.res` containing Pass/Fail status for each attribute. \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/STM-HWE-PORT-SWITCH/STM-HWE-PORT-SWITCH.yaml b/Runner/suites/Kernel/DEBUG/STM-HWE-PORT-SWITCH/STM-HWE-PORT-SWITCH.yaml new file mode 100644 index 00000000..14531410 --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/STM-HWE-PORT-SWITCH/STM-HWE-PORT-SWITCH.yaml @@ -0,0 +1,13 @@ +metadata: + name: STM-HWEvent-Port-Enable-Disable + description: "Validates the ability to enable and disable STM Hardware Events and Ports via sysfs." + + os: + - linux + devices: + - qcm6490 + - qcs9100 + scope: + - coresight + - kernel + timeout: 60 \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/STM-HWE-PORT-SWITCH/run.sh b/Runner/suites/Kernel/DEBUG/STM-HWE-PORT-SWITCH/run.sh new file mode 100644 index 00000000..0445f67d --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/STM-HWE-PORT-SWITCH/run.sh @@ -0,0 +1,142 @@ +#!/bin/sh + +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + fi + SEARCH=$(dirname "$SEARCH") +done + +if [ -z "$INIT_ENV" ]; then + echo "[ERROR] Could not find init_env" >&2 + exit 1 +fi + +if [ -z "$__INIT_ENV_LOADED" ]; then + # shellcheck disable=SC1090 + . "$INIT_ENV" +fi + +# shellcheck disable=SC1090,SC1091 +. "$TOOLS/functestlib.sh" + +TESTNAME="STM-HWE-PORT-SWITCH" +if command -v find_test_case_by_name >/dev/null 2>&1; then + test_path=$(find_test_case_by_name "$TESTNAME") + cd "$test_path" || exit 1 +else + cd "$SCRIPT_DIR" || exit 1 +fi + +res_file="./$TESTNAME.res" +rm -f "$res_file" +touch "$res_file" + +log_info "-----------------------------------------------------------------------------------------" +log_info "-------------------Starting $TESTNAME Testcase----------------------------" + +CS_BASE="/sys/bus/coresight/devices" +STM_PATH="$CS_BASE/stm0" +[ ! -d "$STM_PATH" ] && STM_PATH="$CS_BASE/coresight-stm" +ETF_PATH="$CS_BASE/tmc_etf0" +ETR_PATH="$CS_BASE/tmc_etr0" +DEBUGFS="/sys/kernel/debug/tracing" + +reset_source_sink() { + if [ -f "$STM_PATH/enable_source" ]; then + echo 0 > "$STM_PATH/enable_source" + fi + if [ -f "$ETF_PATH/enable_sink" ]; then + echo 0 > "$ETF_PATH/enable_sink" + fi + if [ -f "$ETR_PATH/enable_sink" ]; then + echo 0 > "$ETR_PATH/enable_sink" + fi + if [ -f "$DEBUGFS/tracing_on" ]; then + echo 0 > "$DEBUGFS/tracing_on" + fi +} + +test_attribute() { + attr_name=$1 + attr_path="$STM_PATH/$attr_name" + + log_info "Testing Attribute: $attr_name" + + if [ ! -f "$attr_path" ]; then + log_warn "Attribute $attr_name not found at $STM_PATH" + return 0 + fi + + for stm_state in 0 1; do + echo "$stm_state" > "$STM_PATH/enable_source" + + for val in 0 1; do + echo "$val" > "$attr_path" + readback=$(cat "$attr_path") + + + if [ "$attr_name" = "hwevent_enable" ]; then + if [ "$readback" -eq "$val" ]; then + log_pass "STM_Src:$stm_state | $attr_name set to $val" + else + log_fail "STM_Src:$stm_state | Failed to set $attr_name to $val (Read: $readback)" + echo "$TESTNAME: FAIL" >> "$res_file" + return 1 + fi + elif [ "$attr_name" = "port_enable" ]; then + if [ "$val" -eq 1 ] && [ "$readback" != "0" ] && [ "$readback" != "0x0" ]; then + log_pass "STM_Src:$stm_state | $attr_name set to $val" + elif [ "$val" -eq 0 ] && [ "$readback" = "0" ]; then + log_pass "STM_Src:$stm_state | $attr_name set to $val" + elif [ "$val" -eq 0 ] && [ "$readback" = "0x0" ]; then + log_pass "STM_Src:$stm_state | $attr_name set to $val" + else + log_fail "STM_Src:$stm_state | Failed to set $attr_name to $val (Read: $readback)" + echo "$TESTNAME: FAIL" >> "$res_file" + return 1 + fi + fi + done + done + + echo "$TESTNAME: PASS" >> "$res_file" + return 0 +} + + +if [ ! -d "$STM_PATH" ]; then + log_fail "STM device not found" + echo "$TESTNAME: FAIL" >> "$res_file" + exit 1 +fi + +log_info "Creating Policy Directories..." +mkdir -p /sys/kernel/config/stp-policy/stm0:p_ost.policy/default + +reset_source_sink + +if [ -f "$ETF_PATH/enable_sink" ]; then + echo 1 > "$ETF_PATH/enable_sink" +fi + +test_attribute "hwevent_enable" +test_attribute "port_enable" + +reset_source_sink + +if [ -f "$STM_PATH/hwevent_enable" ]; then + echo 0 > "$STM_PATH/hwevent_enable" +fi +if [ -f "$STM_PATH/port_enable" ]; then + echo 0xffffffff > "$STM_PATH/port_enable" +fi + +# log_info "-------------------$TESTNAME Testcase Finished----------------------------" \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/STM-Source-Enable-Disable/README.md b/Runner/suites/Kernel/DEBUG/STM-Source-Enable-Disable/README.md new file mode 100644 index 00000000..f0d173b7 --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/STM-Source-Enable-Disable/README.md @@ -0,0 +1,20 @@ +# STM Source Enable/Disable Stress Test + +## Overview +This test validates the stability of the **STM (System Trace Macrocell)** driver by repeatedly enabling and disabling the source in a loop. + +## Execution +1. **Setup**: + * Creates STP policy directories. + * Resets all Coresight source/sink devices. + * Disables hardware events and clears global tracing events. +2. **Loop (50 Iterations)**: + * Resets source/sink. + * Enables `tmc_etf` sink. + * Enables `stm` source $\to$ Checks if `enable_source` is `1`. + * Disables `stm` source $\to$ Checks if `enable_source` is `0`. +3. **Teardown**: Resets devices. + +## Output +* Console logs indicating iteration failures (if any). +* `STM-Source-Enable-Disable.res` containing Pass/Fail status. \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/STM-Source-Enable-Disable/STM-Source-Enable-Disable.yaml b/Runner/suites/Kernel/DEBUG/STM-Source-Enable-Disable/STM-Source-Enable-Disable.yaml new file mode 100644 index 00000000..6352587c --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/STM-Source-Enable-Disable/STM-Source-Enable-Disable.yaml @@ -0,0 +1,13 @@ +metadata: + name: STM-Source-Enable-Disable + description: "Stress test that toggles the STM source enablement 50 times to ensure stability." + + os: + - linux + devices: + - qcm6490 + - qcs9100 + scope: + - coresight + - kernel + timeout: 300 \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/STM-Source-Enable-Disable/run.sh b/Runner/suites/Kernel/DEBUG/STM-Source-Enable-Disable/run.sh new file mode 100644 index 00000000..a48397ca --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/STM-Source-Enable-Disable/run.sh @@ -0,0 +1,126 @@ +#!/bin/sh + +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + fi + SEARCH=$(dirname "$SEARCH") +done + +if [ -z "$INIT_ENV" ]; then + echo "[ERROR] Could not find init_env" >&2 + exit 1 +fi + +if [ -z "$__INIT_ENV_LOADED" ]; then + # shellcheck disable=SC1090 + . "$INIT_ENV" +fi + +# shellcheck disable=SC1090,SC1091 +. "$TOOLS/functestlib.sh" + +TESTNAME="STM-Source-Enable-Disable" +if command -v find_test_case_by_name >/dev/null 2>&1; then + test_path=$(find_test_case_by_name "$TESTNAME") + cd "$test_path" || exit 1 +else + cd "$SCRIPT_DIR" || exit 1 +fi + +res_file="./$TESTNAME.res" +rm -f "$res_file" +touch "$res_file" + +log_info "-----------------------------------------------------------------------------------------" +log_info "-------------------Starting $TESTNAME Testcase----------------------------" + +CS_BASE="/sys/bus/coresight/devices" +STM_PATH="$CS_BASE/stm0" +[ ! -d "$STM_PATH" ] && STM_PATH="$CS_BASE/coresight-stm" +ETF_PATH="$CS_BASE/tmc_etf0" +DEBUGFS="/sys/kernel/debug/tracing" +FAIL_COUNT=0 + +reset_source_sink() { + for dev in $(ls "$CS_BASE"); do + path="$CS_BASE/$dev" + if [ -f "$path/enable_source" ]; then + val=$(cat "$path/enable_source") + if [ "$val" -eq 1 ]; then + echo 0 > "$path/enable_source" + [ -f "$path/reset" ] && echo 1 > "$path/reset" + fi + fi + if [ -f "$path/enable_sink" ]; then + val=$(cat "$path/enable_sink") + [ "$val" -eq 1 ] && echo 0 > "$path/enable_sink" + fi + done +} + + +if [ ! -d "$STM_PATH" ]; then + log_fail "STM device not found" + echo "$TESTNAME: FAIL" >> "$res_file" + exit 1 +fi + +log_info "Setting up STP policy..." +mkdir -p /sys/kernel/config/stp-policy/stm0:p_ost.policy/default + +log_info "Initial cleanup..." +reset_source_sink + +if [ -f "$STM_PATH/hwevent_enable" ]; then + echo 0 > "$STM_PATH/hwevent_enable" +fi +if [ -f "$STM_PATH/port_enable" ]; then + echo 0xffffffff > "$STM_PATH/port_enable" +fi +echo 0 > "$DEBUGFS/events/enable" + +log_info "Starting 50 iteration loop..." + +for i in $(seq 1 50); do + reset_source_sink + + if [ -f "$ETF_PATH/enable_sink" ]; then + echo 1 > "$ETF_PATH/enable_sink" + fi + + echo 1 > "$STM_PATH/enable_source" + val=$(cat "$STM_PATH/enable_source") + + if [ "$val" -ne 1 ]; then + log_fail "Iteration $i: Failed to enable STM source" + FAIL_COUNT=$((FAIL_COUNT + 1)) + fi + + echo 0 > "$STM_PATH/enable_source" + val=$(cat "$STM_PATH/enable_source") + + if [ "$val" -ne 0 ]; then + log_fail "Iteration $i: Failed to disable STM source" + FAIL_COUNT=$((FAIL_COUNT + 1)) + fi +done + +reset_source_sink + +if [ "$FAIL_COUNT" -eq 0 ]; then + log_pass "STM source enable/disable loop passed (50 iterations)" + echo "$TESTNAME: PASS" >> "$res_file" +else + log_fail "STM source enable/disable loop failed ($FAIL_COUNT failures)" + echo "$TESTNAME: FAIL" >> "$res_file" +fi + +# log_info "-------------------$TESTNAME Testcase Finished----------------------------" \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/Sink-Status-STM-Toggle/README.md b/Runner/suites/Kernel/DEBUG/Sink-Status-STM-Toggle/README.md new file mode 100644 index 00000000..ad1cd7f8 --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/Sink-Status-STM-Toggle/README.md @@ -0,0 +1,28 @@ +# Coresight Sink Status Test (STM Toggle) + +## Overview +This test verifies the dependency behavior between Coresight Sources (STM, ETM) and Sinks (TMC-ETF, TMC-ETR). It ensures that sinks open and close correctly based on the activity of connected sources. + +## Execution + +The test performs two phases of validation for every available sink (`tmc_etf0`, `tmc_etr0`, etc., excluding `tmc_etf1`). + +### Phase 1: Single Source (STM Only) +1. **Setup**: Reset devices. +2. **Enable**: Enable Sink $\to$ Enable STM Source. + * *Verification*: Check if Sink `enable_sink` is `1`. +3. **Disable**: Disable STM Source. + * *Verification*: Check if Sink `enable_sink` drops to `0` (Release resource). + +### Phase 2: Multi-Source (STM + ETM) +*Note: This phase runs only if an ETM device is detected.* +1. **Setup**: Reset devices. +2. **Enable**: Enable Sink $\to$ Enable STM Source $\to$ Enable ETM Source. + * *Verification*: Check if Sink `enable_sink` is `1`. +3. **Partial Disable**: Disable **only** STM Source. + * *Verification*: Check if Sink `enable_sink` remains `1` (ETM should keep the sink active). +4. **Cleanup**: Reset devices. + +## Output +* Console logs for each sink and phase transition. +* `Sink-Status-STM-Toggle.res` containing the final Pass/Fail status. \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/Sink-Status-STM-Toggle/Sink-Status-STM-Toggle.yaml b/Runner/suites/Kernel/DEBUG/Sink-Status-STM-Toggle/Sink-Status-STM-Toggle.yaml new file mode 100644 index 00000000..dc63d61e --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/Sink-Status-STM-Toggle/Sink-Status-STM-Toggle.yaml @@ -0,0 +1,13 @@ +metadata: + name: Sink-Status-STM-Toggle + description: "Verifies that Coresight sinks maintain correct enabled/disabled states when sources (STM/ETM) are toggled." + + os: + - linux + devices: + - qcm6490 + - qcs9100 + scope: + - coresight + - kernel + timeout: 60 \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/Sink-Status-STM-Toggle/run.sh b/Runner/suites/Kernel/DEBUG/Sink-Status-STM-Toggle/run.sh new file mode 100644 index 00000000..7a57985a --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/Sink-Status-STM-Toggle/run.sh @@ -0,0 +1,174 @@ +#!/bin/sh + +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + fi + SEARCH=$(dirname "$SEARCH") +done + +if [ -z "$INIT_ENV" ]; then + echo "[ERROR] Could not find init_env" >&2 + exit 1 +fi + +if [ -z "$__INIT_ENV_LOADED" ]; then + # shellcheck disable=SC1090 + . "$INIT_ENV" +fi + +# shellcheck disable=SC1090,SC1091 +. "$TOOLS/functestlib.sh" + +TESTNAME="Sink-Status-STM-Toggle" +if command -v find_test_case_by_name >/dev/null 2>&1; then + test_path=$(find_test_case_by_name "$TESTNAME") + cd "$test_path" || exit 1 +else + cd "$SCRIPT_DIR" || exit 1 +fi + +res_file="./$TESTNAME.res" +rm -f "$res_file" +touch "$res_file" + +log_info "-----------------------------------------------------------------------------------------" +log_info "-------------------Starting $TESTNAME Testcase----------------------------" + +CS_BASE="/sys/bus/coresight/devices" +STM_PATH="$CS_BASE/stm0" +[ ! -d "$STM_PATH" ] && STM_PATH="$CS_BASE/coresight-stm" + +ETM_PATH="$CS_BASE/etm0" +[ ! -d "$ETM_PATH" ] && ETM_PATH="$CS_BASE/coresight-etm0" +[ ! -d "$ETM_PATH" ] && ETM_PATH="$CS_BASE/coresight-etm4x" + +FAIL_COUNT=0 + + +reset_devices() { + if [ -f "$CS_BASE/reset_source_sink" ]; then + echo 1 > "$CS_BASE/reset_source_sink" + else + [ -d "$STM_PATH" ] && echo 0 > "$STM_PATH/enable_source" 2>/dev/null + [ -d "$ETM_PATH" ] && echo 0 > "$ETM_PATH/enable_source" 2>/dev/null + + for sink in "$CS_BASE"/tmc_et*; do + [ -f "$sink/enable_sink" ] && echo 0 > "$sink/enable_sink" 2>/dev/null + done + fi +} + +check_sink_status() { + sink=$1 + expected=$2 + stage=$3 + + val=$(cat "$sink/enable_sink") + if [ "$val" -ne "$expected" ]; then + log_fail "$stage: $sink status is $val (Expected: $expected)" + return 1 + else + log_pass "$stage: $sink status is $val" + return 0 + fi +} + + +if [ ! -d "$STM_PATH" ]; then + log_fail "STM device not found" + echo "STM_Init: Fail" >> "$res_file" + exit 1 +fi + +SINK_LIST=$(ls -d "$CS_BASE"/tmc_et* 2>/dev/null | grep -v tmc_etf1) + +if [ -z "$SINK_LIST" ]; then + log_fail "No suitable sinks found" + echo "Sink_Discovery: Fail" >> "$res_file" + exit 1 +fi + +if [ -f "$CS_BASE/tmc_etr0/out_mode" ]; then + echo mem > "$CS_BASE/tmc_etr0/out_mode" +fi + +log_info "=== Phase 1: STM Only Test ===" + +for sink in $SINK_LIST; do + log_info "Testing Sink: $(basename "$sink")" + + reset_devices + echo 1 > "$sink/enable_sink" + echo 1 > "$STM_PATH/enable_source" + sleep 1 + + if ! check_sink_status "$sink" 1 "Phase1_STM_Enable"; then + FAIL_COUNT=$((FAIL_COUNT + 1)) + fi + + echo 0 > "$STM_PATH/enable_source" + + if ! check_sink_status "$sink" 0 "Phase1_STM_Disable"; then + FAIL_COUNT=$((FAIL_COUNT + 1)) + fi +done + +log_info "=== Phase 2: STM + ETM Test ===" + +HAS_ETM=0 +if [ -d "$ETM_PATH" ]; then + if [ -f /proc/config.gz ]; then + if zcat /proc/config.gz | grep -q "CONFIG_CORESIGHT_SOURCE_ETM4X=y"; then + HAS_ETM=1 + fi + else + HAS_ETM=1 + fi +fi + +if [ "$HAS_ETM" -eq 1 ]; then + for sink in $SINK_LIST; do + log_info "Testing Sink (Multi-Source): $(basename "$sink")" + + reset_devices + echo 1 > "$sink/enable_sink" + + echo 1 > "$STM_PATH/enable_source" + echo 1 > "$ETM_PATH/enable_source" + sleep 1 + + if ! check_sink_status "$sink" 1 "Phase2_Both_Enable"; then + FAIL_COUNT=$((FAIL_COUNT + 1)) + fi + + echo 0 > "$STM_PATH/enable_source" + + if ! check_sink_status "$sink" 1 "Phase2_STM_Disable_ETM_Active"; then + FAIL_COUNT=$((FAIL_COUNT + 1)) + fi + + reset_devices + done +else + log_info "Skipping Phase 2 (ETM not found or not enabled)" +fi + +reset_devices + +if [ "$FAIL_COUNT" -eq 0 ]; then + log_pass "Sink status check passed across all phases" + echo "${TESTNAME}: Pass" >> "$res_file" +else + log_fail "Sink status check failed ($FAIL_COUNT errors)" + echo "${TESTNAME}: Fail" >> "$res_file" +fi + +# log_info "-------------------$TESTNAME Testcase Finished----------------------------" \ No newline at end of file From f0fb09839db73eb12422633a0ca3a519514bfd0f Mon Sep 17 00:00:00 2001 From: Rohan Dutta Date: Fri, 20 Feb 2026 16:45:53 +0530 Subject: [PATCH 2/2] Add CTI, TGU, Node Access debug suites Signed-off-by: Rohan Dutta --- .../CTI-Enable-Disable.yaml | 13 + .../Kernel/DEBUG/CTI-Enable-Disable/README.md | 20 ++ .../Kernel/DEBUG/CTI-Enable-Disable/run.sh | 135 +++++++++ .../Kernel/DEBUG/CTI-Test/CTI-Test.yaml | 13 + Runner/suites/Kernel/DEBUG/CTI-Test/README.md | 21 ++ Runner/suites/Kernel/DEBUG/CTI-Test/run.sh | 263 ++++++++++++++++++ .../Kernel/DEBUG/Node-Access/Node-Access.yaml | 13 + .../suites/Kernel/DEBUG/Node-Access/README.md | 20 ++ Runner/suites/Kernel/DEBUG/Node-Access/run.sh | 122 ++++++++ .../Kernel/DEBUG/TGU-Enable-Disable/README.md | 23 ++ .../TGU-Enable-Disable.yaml | 13 + .../Kernel/DEBUG/TGU-Enable-Disable/run.sh | 133 +++++++++ 12 files changed, 789 insertions(+) create mode 100644 Runner/suites/Kernel/DEBUG/CTI-Enable-Disable/CTI-Enable-Disable.yaml create mode 100644 Runner/suites/Kernel/DEBUG/CTI-Enable-Disable/README.md create mode 100644 Runner/suites/Kernel/DEBUG/CTI-Enable-Disable/run.sh create mode 100644 Runner/suites/Kernel/DEBUG/CTI-Test/CTI-Test.yaml create mode 100644 Runner/suites/Kernel/DEBUG/CTI-Test/README.md create mode 100644 Runner/suites/Kernel/DEBUG/CTI-Test/run.sh create mode 100644 Runner/suites/Kernel/DEBUG/Node-Access/Node-Access.yaml create mode 100644 Runner/suites/Kernel/DEBUG/Node-Access/README.md create mode 100644 Runner/suites/Kernel/DEBUG/Node-Access/run.sh create mode 100644 Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/README.md create mode 100644 Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/TGU-Enable-Disable.yaml create mode 100644 Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/run.sh diff --git a/Runner/suites/Kernel/DEBUG/CTI-Enable-Disable/CTI-Enable-Disable.yaml b/Runner/suites/Kernel/DEBUG/CTI-Enable-Disable/CTI-Enable-Disable.yaml new file mode 100644 index 00000000..d5d8ab4c --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/CTI-Enable-Disable/CTI-Enable-Disable.yaml @@ -0,0 +1,13 @@ +metadata: + name: CTI-Enable-Disable + description: "Verifies that all Coresight CTI devices can be successfully enabled and disabled via sysfs." + + os: + - linux + devices: + - qcm6490 + - qcs9100 + scope: + - coresight + - kernel + timeout: 60 \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/CTI-Enable-Disable/README.md b/Runner/suites/Kernel/DEBUG/CTI-Enable-Disable/README.md new file mode 100644 index 00000000..53604cb0 --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/CTI-Enable-Disable/README.md @@ -0,0 +1,20 @@ +# Coresight CTI Enable/Disable Test + +## Overview +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. + +## Execution Logic +1. **Preparation**: + * Disables `stm0`, `tmc_etr0`, and `tmc_etf0` to ensure a clean state. + * Enables `tmc_etf0` (Embedded Trace FIFO) as a sink, as some CTI configurations may require an active sink. +2. **Discovery**: Scans `/sys/bus/coresight/devices/` for any directory containing `cti`. +3. **Iteration**: For each CTI device: + * **Enable**: Writes `1` to the `enable` file. + * **Verify**: Reads the `enable` file; expects `1`. + * **Disable**: Writes `0` to the `enable` file. + * **Verify**: Reads the `enable` file; expects `0`. +4. **Cleanup**: Resets all devices to disabled state. + +## Output +* Logs for every device toggle attempt. +* `CTI-Enable-Disable.res` containing the final Pass/Fail status. \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/CTI-Enable-Disable/run.sh b/Runner/suites/Kernel/DEBUG/CTI-Enable-Disable/run.sh new file mode 100644 index 00000000..dbf78418 --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/CTI-Enable-Disable/run.sh @@ -0,0 +1,135 @@ +#!/bin/sh + +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause + +# Script to test the QDSS CTI driver. +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + fi + SEARCH=$(dirname "$SEARCH") +done + +if [ -z "$INIT_ENV" ]; then + echo "[ERROR] Could not find init_env" >&2 + exit 1 +fi + +if [ -z "$__INIT_ENV_LOADED" ]; then + # shellcheck disable=SC1090 + . "$INIT_ENV" +fi + +# shellcheck disable=SC1090,SC1091 +. "$TOOLS/functestlib.sh" + +TESTNAME="CTI-Enable-Disable" +if command -v find_test_case_by_name >/dev/null 2>&1; then + test_path=$(find_test_case_by_name "$TESTNAME") + cd "$test_path" || exit 1 +else + cd "$SCRIPT_DIR" || exit 1 +fi + +res_file="./$TESTNAME.res" +rm -f "$res_file" +touch "$res_file" + +log_info "-----------------------------------------------------------------------------------------" +log_info "-------------------Starting $TESTNAME Testcase----------------------------" + +CS_BASE="/sys/bus/coresight/devices" +FAIL_COUNT=0 + + +reset_devices() { + log_info "Resetting Coresight devices..." + if [ -f "$CS_BASE/tmc_etf0/enable_sink" ]; then + echo 0 > "$CS_BASE/tmc_etf0/enable_sink" 2>/dev/null + fi + if [ -f "$CS_BASE/tmc_etr0/enable_sink" ]; then + echo 0 > "$CS_BASE/tmc_etr0/enable_sink" 2>/dev/null + fi + if [ -f "$CS_BASE/stm0/enable_source" ]; then + echo 0 > "$CS_BASE/stm0/enable_source" 2>/dev/null + fi +} + + +if [ ! -d "$CS_BASE" ]; then + log_fail "Coresight directory not found: $CS_BASE" + echo "Coresight directory not found" >> "$res_file" + exit 1 +fi + +reset_devices + +if [ -f "$CS_BASE/tmc_etf0/enable_sink" ]; then + echo 1 > "$CS_BASE/tmc_etf0/enable_sink" +else + log_warn "tmc_etf0 not found, proceeding without it..." +fi + +# shellcheck disable=SC2010 +CTI_LIST=$(ls "$CS_BASE" | grep 'cti') + +if [ -z "$CTI_LIST" ]; then + log_fail "No CTI devices found." + FAIL_COUNT=$((FAIL_COUNT + 1)) +else + for cti in $CTI_LIST; do + dev_path="$CS_BASE/$cti" + + if [ ! -f "$dev_path/enable" ]; then + log_warn "Skipping $cti: 'enable' node not found" + continue + fi + + log_info "Testing Device: $cti" + + if ! echo 1 > "$dev_path/enable"; then + log_fail "$cti: Failed to write 1 to enable" + FAIL_COUNT=$((FAIL_COUNT + 1)) + continue + fi + + res=$(cat "$dev_path/enable") + if [ "$res" -eq 1 ]; then + log_pass "$cti Enabled Successfully" + else + log_fail "$cti Failed to Enable (Value: $res)" + FAIL_COUNT=$((FAIL_COUNT + 1)) + fi + + if ! echo 0 > "$dev_path/enable"; then + log_fail "$cti: Failed to write 0 to enable" + FAIL_COUNT=$((FAIL_COUNT + 1)) + continue + fi + + res=$(cat "$dev_path/enable") + if [ "$res" -eq 0 ]; then + log_pass "$cti Disabled Successfully" + else + log_fail "$cti Failed to Disable (Value: $res)" + FAIL_COUNT=$((FAIL_COUNT + 1)) + fi + done +fi + +reset_devices + +if [ "$FAIL_COUNT" -eq 0 ]; then + log_pass "CTI Enable/Disable Test Completed Successfully" + echo "$TESTNAME: PASS" >> "$res_file" +else + log_fail "CTI Enable/Disable Test Failed ($FAIL_COUNT errors)" + echo "$TESTNAME: FAIL" >> "$res_file" +fi + +# log_info "-------------------$TESTNAME Testcase Finished----------------------------" \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/CTI-Test/CTI-Test.yaml b/Runner/suites/Kernel/DEBUG/CTI-Test/CTI-Test.yaml new file mode 100644 index 00000000..602c0aaf --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/CTI-Test/CTI-Test.yaml @@ -0,0 +1,13 @@ +metadata: + name: CTI-Trigger-Map + description: "Validates Coresight Cross Trigger Interface (CTI) by mapping and unmapping triggers to channels." + + os: + - linux + devices: + - qcm6490 + - qcs9100 + scope: + - coresight + - kernel + timeout: 120 \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/CTI-Test/README.md b/Runner/suites/Kernel/DEBUG/CTI-Test/README.md new file mode 100644 index 00000000..9c1f4484 --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/CTI-Test/README.md @@ -0,0 +1,21 @@ +# CTI Test + +## Overview +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). + +## Execution Logic +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. +2. **Discovery**: Finds all CTI devices in `/sys/bus/coresight/devices/`. +3. **Mode Detection**: Checks for the existence of `enable` sysfs node to determine if the driver uses the Modern or Legacy sysfs interface. +4. **Configuration Parsing**: Reads the `devid` (Modern) or `show_info` (Legacy) to calculate the maximum number of triggers and channels supported by the hardware. +5. **Test Loop**: + * Iterates through a subset of triggers (randomized within valid range). + * Iterates through valid channels. + * **Attach**: writes `channel trigger` to `trigin_attach` / `trigout_attach`. + * **Verify**: Reads back via `chan_xtrigs_sel` and `chan_xtrigs_in`/`out` to confirm mapping. + * **Detach**: Unmaps the trigger and confirms the entry is cleared. +6. **Cleanup**: Restores the original LPM sleep setting. + +## Output +* Logs identifying which CTI device, trigger, and channel are being tested. +* `CTI-Trigger-Map.res` containing the final Pass/Fail status. \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/CTI-Test/run.sh b/Runner/suites/Kernel/DEBUG/CTI-Test/run.sh new file mode 100644 index 00000000..09733b05 --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/CTI-Test/run.sh @@ -0,0 +1,263 @@ +#!/bin/sh + +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + fi + SEARCH=$(dirname "$SEARCH") +done + +if [ -z "$INIT_ENV" ]; then + echo "[ERROR] Could not find init_env" >&2 + exit 1 +fi + +if [ -z "$__INIT_ENV_LOADED" ]; then + # shellcheck disable=SC1090 + . "$INIT_ENV" +fi + +# shellcheck disable=SC1090,SC1091 +. "$TOOLS/functestlib.sh" + +TESTNAME="CTI-Test" +if command -v find_test_case_by_name >/dev/null 2>&1; then + test_path=$(find_test_case_by_name "$TESTNAME") + cd "$test_path" || exit 1 +else + cd "$SCRIPT_DIR" || exit 1 +fi + +res_file="./$TESTNAME.res" +rm -f "$res_file" +touch "$res_file" + +log_info "-----------------------------------------------------------------------------------------" +log_info "-------------------Starting $TESTNAME Testcase----------------------------" + +CS_BASE="/sys/bus/coresight/devices" +LPM_SLEEP="/sys/module/lpm_levels/parameters/sleep_disabled" +ORIG_SLEEP_VAL="" +FAIL_COUNT=0 + +CTI_MAX_TRIGGERS=8 +CTI_MAX_CHANNELS=4 +CTI_TRIGGERS_TO_TEST=1 + + +setup_sleep() { + if [ -f "$LPM_SLEEP" ]; then + ORIG_SLEEP_VAL=$(cat "$LPM_SLEEP") + if [ "$ORIG_SLEEP_VAL" != "Y" ] && [ "$ORIG_SLEEP_VAL" != "1" ]; then + log_info "Disabling LPM Sleep for test duration..." + echo 1 > "$LPM_SLEEP" + fi + fi +} + +restore_sleep() { + if [ -f "$LPM_SLEEP" ] && [ -n "$ORIG_SLEEP_VAL" ]; then + log_info "Restoring LPM Sleep value: $ORIG_SLEEP_VAL" + echo "$ORIG_SLEEP_VAL" > "$LPM_SLEEP" + fi +} + +map_cti_trigin() { + trig=$1; channel=$2; ctiname=$3; + cti_dev="$CS_BASE/$ctiname" + + log_info "Legacy: mapping trig $trig ch $channel to $ctiname" + echo "$trig" "$channel" > "$cti_dev/map_trigin" + + trigin=$(cut -b 4 "$cti_dev/show_trigin") + channelin=$(cut -b 8 "$cti_dev/show_trigin") + + if [ "$trig" -eq "$trigin" ] && [ "$channel" -eq "$channelin" ]; then + echo "$trig" "$channel" > "$cti_dev/unmap_trigin" + trigin=$(cut -b 4 "$cti_dev/show_trigin") + if [ -n "$trigin" ]; then + log_warn "Failed to unmap $ctiname trigin" + FAIL_COUNT=$((FAIL_COUNT + 1)) + echo 1 > "$cti_dev/reset" + fi + else + log_warn "Failed to map $ctiname trigin $trig to channel $channel" + FAIL_COUNT=$((FAIL_COUNT + 1)) + echo 1 > "$cti_dev/reset" + fi +} + +set_trigin_attach() { + trig=$1; channel=$2; ctiname=$3; + cti_dev="$CS_BASE/$ctiname" + + log_info "Attach trigin: trig $trig -> ch $channel on $ctiname" + + echo 1 > "$cti_dev/enable" + + echo "$channel" "$trig" > "$cti_dev/channels/trigin_attach" + + echo "$channel" > "$cti_dev/channels/chan_xtrigs_sel" + read_trig=$(cat "$cti_dev/channels/chan_xtrigs_in") + + if [ "$trig" -eq "$read_trig" ]; then + echo "$channel" "$trig" > "$cti_dev/channels/trigin_detach" + + echo "$channel" > "$cti_dev/channels/chan_xtrigs_sel" + read_trig=$(cat "$cti_dev/channels/chan_xtrigs_in") + + if [ -n "$read_trig" ]; then + log_warn "Failed to detach trigin on $ctiname" + FAIL_COUNT=$((FAIL_COUNT + 1)) + echo 1 > "$cti_dev/reset" + fi + else + log_warn "Failed to attach trigin $trig to channel $channel on $ctiname" + FAIL_COUNT=$((FAIL_COUNT + 1)) + echo 1 > "$cti_dev/channels/chan_xtrigs_reset" + fi + + echo 0 > "$cti_dev/enable" +} + +set_trigout_attach() { + trig=$1; channel=$2; ctiname=$3; + cti_dev="$CS_BASE/$ctiname" + + log_info "Attach trigout: trig $trig -> ch $channel on $ctiname" + + echo 1 > "$cti_dev/enable" + + echo "$channel" "$trig" > "$cti_dev/channels/trigout_attach" + + echo "$channel" > "$cti_dev/channels/chan_xtrigs_sel" + read_trig=$(cat "$cti_dev/channels/chan_xtrigs_out") + + if [ "$trig" -eq "$read_trig" ]; then + echo "$channel" "$trig" > "$cti_dev/channels/trigout_detach" + + echo "$channel" > "$cti_dev/channels/chan_xtrigs_sel" + read_trig=$(cat "$cti_dev/channels/chan_xtrigs_out") + + if [ -n "$read_trig" ]; then + log_warn "Failed to detach trigout on $ctiname" + FAIL_COUNT=$((FAIL_COUNT + 1)) + echo 1 > "$cti_dev/reset" + fi + else + log_warn "Failed to attach trigout $trig to channel $channel on $ctiname" + FAIL_COUNT=$((FAIL_COUNT + 1)) + echo 1 > "$cti_dev/channels/chan_xtrigs_reset" + fi + + echo 0 > "$cti_dev/enable" +} + + +setup_sleep + +# shellcheck disable=SC2010 +CTI_DEVICES=$(ls "$CS_BASE" | grep 'cti') + +if [ -z "$CTI_DEVICES" ]; then + log_fail "No CTI devices found in $CS_BASE" + echo "CTI_Discovery: Fail" >> "$res_file" + restore_sleep + exit 1 +fi + +NEW_VER=0 +for cti in $CTI_DEVICES; do + if [ -f "$CS_BASE/$cti/enable" ]; then + NEW_VER=1 + break + fi +done + +log_info "CTI Driver Version: $( [ $NEW_VER -eq 1 ] && echo "Modern" || echo "Legacy" )" + +for cti in $CTI_DEVICES; do + if [ $NEW_VER -eq 1 ]; then + if [ -f "$CS_BASE/$cti/channels/chan_xtrigs_reset" ]; then + echo 1 > "$CS_BASE/$cti/channels/chan_xtrigs_reset" + fi + else + if [ -f "$CS_BASE/$cti/reset" ]; then + echo 1 > "$CS_BASE/$cti/reset" + fi + fi +done + +for cti in $CTI_DEVICES; do + cti_path="$CS_BASE/$cti" + + if [ $NEW_VER -eq 1 ]; then + if [ -f "$cti_path/mgmt/devid" ]; then + devid=$(cat "$cti_path/mgmt/devid") + chmax=$(( (devid & 2064384) >> 16 )) + trigmax=$(( (devid & 32640) >> 8 )) + else + chmax=4 + trigmax=8 + fi + else + if [ -f "$cti_path/show_info" ]; then + trigmax=$(cut -f1 -d ' ' "$cti_path/show_info") + chmax=$(cut -f2 -d ' ' "$cti_path/show_info") + else + chmax=4 + trigmax=8 + fi + fi + + log_info "Device: $cti (MaxTrig: $trigmax, MaxCh: $chmax)" + + # Shellcheck disable=SC2034 + for i in $(seq 0 $CTI_TRIGGERS_TO_TEST); do + rand_val=$(awk 'BEGIN{srand(); print int(rand()*32768)}') + + if [ "$trigmax" -gt 0 ]; then + if [ "$trigmax" -lt "$CTI_MAX_TRIGGERS" ]; then + trig=$(( rand_val % trigmax )) + else + trig=$(( rand_val % CTI_MAX_TRIGGERS )) + fi + else + trig=0 + fi + + limit_ch=$((CTI_MAX_CHANNELS - 1)) + + for channel in $(seq 0 $limit_ch); do + if [ "$channel" -gt "$chmax" ]; then + continue + fi + + if [ $NEW_VER -eq 1 ]; then + set_trigin_attach "$trig" "$channel" "$cti" + set_trigout_attach "$trig" "$channel" "$cti" + else + map_cti_trigin "$trig" "$channel" "$cti" + fi + done + done +done + +restore_sleep + +if [ "$FAIL_COUNT" -eq 0 ]; then + log_pass "CTI map/unmap Test PASS" + echo "$TESTNAME: PASS" >> "$res_file" +else + log_fail "CTI map/unmap Test FAIL ($FAIL_COUNT errors)" + echo "$TESTNAME: FAIL" >> "$res_file" +fi + +# log_info "-------------------$TESTNAME Testcase Finished----------------------------" \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/Node-Access/Node-Access.yaml b/Runner/suites/Kernel/DEBUG/Node-Access/Node-Access.yaml new file mode 100644 index 00000000..066320b9 --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/Node-Access/Node-Access.yaml @@ -0,0 +1,13 @@ +metadata: + name: Sysfs-Node-Access + description: "Iterates through all Coresight sysfs nodes (excluding TPDM) and attempts to read them to ensure stability and permission correctness." + + os: + - linux + devices: + - qcm6490 + - qcs9100 + scope: + - coresight + - kernel + timeout: 120 \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/Node-Access/README.md b/Runner/suites/Kernel/DEBUG/Node-Access/README.md new file mode 100644 index 00000000..8c1b8f98 --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/Node-Access/README.md @@ -0,0 +1,20 @@ +# Node Access Test + +## Overview +This test acts as a "fuzz" or stability test for the Coresight driver sysfs interface. It iterates through every exposed Coresight device (excluding `tpdm`) and attempts to read every readable attribute. This ensures that reading status registers or configuration nodes does not crash the system or return unexpected I/O errors. + +## Execution Logic +1. **Iterations**: Runs the scan loop 3 times. +2. **Discovery**: Scans `/sys/bus/coresight/devices/`. +3. **Exclusion**: Skips any path containing `tpdm` (Trace Port Debug Module). +4. **Reset**: Resets basic source/sink enables (`stm0`, `tmc_etf0`, `tmc_etr0`) before accessing a new device folder to ensure a clean state. +5. **Access**: + * Iterates all files in the device folder. + * Checks if the file is readable (`-r`). + * Performs a `cat` operation. + * Repeats the process for the `mgmt/` subdirectory if it exists. +6. **Verification**: Any read failure (exit code non-zero) increments the failure counter. + +## Output +* Logs warnings for any specific node that fails to read. +* `Node-Access.res` containing the final Pass/Fail status. \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/Node-Access/run.sh b/Runner/suites/Kernel/DEBUG/Node-Access/run.sh new file mode 100644 index 00000000..c99e0af1 --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/Node-Access/run.sh @@ -0,0 +1,122 @@ +#!/bin/sh + +# Copyright (c) 2024 Qualcomm Technologies, Inc. +# All Rights Reserved. Qualcomm Technologies Proprietary and Confidential. + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + fi + SEARCH=$(dirname "$SEARCH") +done + +if [ -z "$INIT_ENV" ]; then + echo "[ERROR] Could not find init_env" >&2 + exit 1 +fi + +if [ -z "$__INIT_ENV_LOADED" ]; then + # shellcheck disable=SC1090 + . "$INIT_ENV" +fi + +# shellcheck disable=SC1090,SC1091 +. "$TOOLS/functestlib.sh" + +TESTNAME="Node-Access" +if command -v find_test_case_by_name >/dev/null 2>&1; then + test_path=$(find_test_case_by_name "$TESTNAME") + cd "$test_path" || exit 1 +else + cd "$SCRIPT_DIR" || exit 1 +fi + +res_file="./$TESTNAME.res" +rm -f "$res_file" +touch "$res_file" + +log_info "-----------------------------------------------------------------------------------------" +log_info "-------------------Starting $TESTNAME Testcase----------------------------" + +CS_BASE="/sys/bus/coresight/devices" +FAIL_COUNT=0 +ITERATIONS=3 + + +reset_source_sink() { + if [ -f "$CS_BASE/stm0/enable_source" ]; then + echo 0 > "$CS_BASE/stm0/enable_source" 2>/dev/null + fi + if [ -f "$CS_BASE/tmc_etf0/enable_sink" ]; then + echo 0 > "$CS_BASE/tmc_etf0/enable_sink" 2>/dev/null + fi + if [ -f "$CS_BASE/tmc_etr0/enable_sink" ]; then + echo 0 > "$CS_BASE/tmc_etr0/enable_sink" 2>/dev/null + fi +} + +read_sysfs_node() { + node=$1 + if [ -f "$node" ] && [ -r "$node" ]; then + if ! cat "$node" > /dev/null 2>&1; then + log_warn "Failed to read: $node" + return 1 + fi + fi + return 0 +} + + +if [ ! -d "$CS_BASE" ]; then + log_fail "Coresight directory $CS_BASE not found" + echo "$TESTNAME: FAIL" >> "$res_file" + exit 1 +fi + +i=0 +while [ $i -lt $ITERATIONS ]; do + log_info "--- Iteration $((i+1)) / $ITERATIONS ---" + + for node_path in "$CS_BASE"/*; do + if [ ! -d "$node_path" ]; then + continue + fi + + if echo "$node_path" | grep -q "tpdm"; then + continue + fi + + reset_source_sink + + for node in "$node_path"/*; do + if ! read_sysfs_node "$node"; then + FAIL_COUNT=$((FAIL_COUNT + 1)) + fi + done + + if [ -d "$node_path/mgmt" ]; then + for snode in "$node_path"/mgmt/*; do + if ! read_sysfs_node "$snode"; then + log_fail "Failed to read mgmt node: $snode" + FAIL_COUNT=$((FAIL_COUNT + 1)) + fi + done + fi + done + i=$((i+1)) +done + + +if [ "$FAIL_COUNT" -eq 0 ]; then + log_pass "All sysfs nodes (except tpdm) Read Test PASS" + echo "$TESTNAME: PASS" >> "$res_file" +else + log_fail "Sysfs nodes Read Test FAIL ($FAIL_COUNT errors)" + echo "$TESTNAME: FAIL" >> "$res_file" +fi + +# log_info "-------------------$TESTNAME Testcase Finished----------------------------" \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/README.md b/Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/README.md new file mode 100644 index 00000000..a9a4c01d --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/README.md @@ -0,0 +1,23 @@ +# Coresight TGU Enable/Disable Test + +## Overview +This test validates the **Trace Generation Unit (TGU)** drivers in the CoresigCCCCht subsystem. It ensures that TGUs can be enabled and disabled successfully when paired with standard sinks (ETR and ETF). + +## Execution Logic +1. **Discovery**: + * Scans `/sys/bus/coresight/devices/` for devices matching `tgu` (e.g., `coresight-tgu`). + * Identifies available sinks (`tmc_etr`, `tmc_etf`, or `coresight-tmc-*` variants). +2. **Outer Loop (Sinks)**: + * Iterates through available sinks (ETR, then ETF). + * Resets the Coresight topology (`reset_source_sink`). + * Enables the current sink. +3. **Inner Loop (TGUs)**: + * **Enable**: Writes `1` to `enable_tgu`. + * **Verify**: Checks the exit code of the write operation. + * **Disable**: Writes `0` to `enable_tgu`. + * **Verify**: Checks the exit code. +4. **Cleanup**: Disables the sink before the next iteration. + +## Output +* Logs indicating which Sink-TGU pair is being tested. +* `TGU-Enable-Disable.res` containing the final Pass/Fail status. \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/TGU-Enable-Disable.yaml b/Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/TGU-Enable-Disable.yaml new file mode 100644 index 00000000..7021ebef --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/TGU-Enable-Disable.yaml @@ -0,0 +1,13 @@ +metadata: + name: TGU-Enable-Disable + description: "Verifies Trace Generation Unit (TGU) functionality by enabling and disabling TGUs while routing to ETR and ETF sinks." + + os: + - linux + devices: + - qcm6490 + - qcs9100 + scope: + - coresight + - kernel + timeout: 60 \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/run.sh b/Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/run.sh new file mode 100644 index 00000000..0074dab1 --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/run.sh @@ -0,0 +1,133 @@ +#!/bin/sh + +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + fi + SEARCH=$(dirname "$SEARCH") +done + +if [ -z "$INIT_ENV" ]; then + echo "[ERROR] Could not find init_env" >&2 + exit 1 +fi + +if [ -z "$__INIT_ENV_LOADED" ]; then + # shellcheck disable=SC1090 + . "$INIT_ENV" +fi + +# shellcheck disable=SC1090,SC1091 +. "$TOOLS/functestlib.sh" + +TESTNAME="TGU-Enable-Disable" +if command -v find_test_case_by_name >/dev/null 2>&1; then + test_path=$(find_test_case_by_name "$TESTNAME") + cd "$test_path" || exit 1 +else + cd "$SCRIPT_DIR" || exit 1 +fi + +res_file="./$TESTNAME.res" +rm -f "$res_file" +touch "$res_file" + +log_info "-----------------------------------------------------------------------------------------" +log_info "-------------------Starting $TESTNAME Testcase----------------------------" + +CS_BASE="/sys/bus/coresight/devices" +FAIL_COUNT=0 +POTENTIAL_SINKS="coresight-tmc-etr coresight-tmc-etf tmc_etr0 tmc_etf0" + + +global_reset() { + if [ -f "/sys/bus/coresight/reset_source_sink" ]; then + echo 1 > "/sys/bus/coresight/reset_source_sink" 2>/dev/null + else + for s in $POTENTIAL_SINKS; do + if [ -f "$CS_BASE/$s/enable_sink" ]; then + echo 0 > "$CS_BASE/$s/enable_sink" 2>/dev/null + fi + done + fi +} + + +if [ ! -d "$CS_BASE" ]; then + log_fail "Coresight directory not found" + echo "Coresight directory not found" >> "$res_file" + exit 1 +fi + +# shellcheck disable=SC2010 +TGU_LIST=$(ls "$CS_BASE" | grep "tgu") + +if [ -z "$TGU_LIST" ]; then + log_warn "No TGU (Trace Generation Unit) devices found. Skipping test." + echo "TGU Discovery: Skip" >> "$res_file" + exit 0 +fi + +log_info "Found TGUs: $TGU_LIST" + +for sink_name in $POTENTIAL_SINKS; do + sink_path="$CS_BASE/$sink_name" + + if [ ! -d "$sink_path" ]; then + continue + fi + + log_info "--- Testing with Sink: $sink_name ---" + + global_reset + + if [ -f "$sink_path/enable_sink" ]; then + if ! echo 1 > "$sink_path/enable_sink"; then + log_fail "Failed to enable sink: $sink_name" + FAIL_COUNT=$((FAIL_COUNT + 1)) + continue + fi + else + log_warn "Sink $sink_name has no enable_sink node" + continue + fi + + for tgu in $TGU_LIST; do + tgu_path="$CS_BASE/$tgu" + + if ! echo 1 > "$tgu_path/enable_tgu"; then + log_fail "Failed to enable TGU: $tgu (Sink: $sink_name)" + FAIL_COUNT=$((FAIL_COUNT + 1)) + else + log_info "Enabled $tgu OK" + fi + + if ! echo 0 > "$tgu_path/enable_tgu"; then + log_fail "Failed to disable TGU: $tgu (Sink: $sink_name)" + FAIL_COUNT=$((FAIL_COUNT + 1)) + else + log_info "Disabled $tgu OK" + fi + done + + echo 0 > "$sink_path/enable_sink" 2>/dev/null +done + + +if [ "$FAIL_COUNT" -eq 0 ]; then + log_pass "TGU Enable/Disable Test PASS" + echo "$TESTNAME: PASS" >> "$res_file" +else + log_fail "TGU Enable/Disable Test FAIL ($FAIL_COUNT errors)" + echo "$TESTNAME: FAIL" >> "$res_file" +fi + +# log_info "-------------------$TESTNAME Testcase Finished----------------------------" +