From 2115e04a7031f42ef484f9a956d976d6bf1c0d7a Mon Sep 17 00:00:00 2001 From: Rohan Dutta Date: Fri, 20 Feb 2026 16:45:53 +0530 Subject: [PATCH] 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 --- .../CTI-Enable-Disable.yaml | 20 ++ .../Kernel/DEBUG/CTI-Enable-Disable/README.md | 20 ++ .../Kernel/DEBUG/CTI-Enable-Disable/run.sh | 138 +++++++++ .../Kernel/DEBUG/CTI-Test/CTI-Test.yaml | 20 ++ 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 | 20 ++ .../suites/Kernel/DEBUG/Node-Access/README.md | 20 ++ Runner/suites/Kernel/DEBUG/Node-Access/run.sh | 123 ++++++++ .../Kernel/DEBUG/TGU-Enable-Disable/README.md | 23 ++ .../TGU-Enable-Disable.yaml | 20 ++ .../Kernel/DEBUG/TGU-Enable-Disable/run.sh | 136 +++++++++ 12 files changed, 824 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 100755 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 100755 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 100755 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 100755 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..6f3f991e --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/CTI-Enable-Disable/CTI-Enable-Disable.yaml @@ -0,0 +1,20 @@ +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 + +run: + steps: + - REPO_PATH=$PWD + - cd Runner/suites/Kernel/DEBUG/CTI-Enable-Disable + - ./run.sh || true + - $REPO_PATH/Runner/utils/send-to-lava.sh CTI-Enable-Disable.res || true \ 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 100755 index 00000000..483b416f --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/CTI-Enable-Disable/run.sh @@ -0,0 +1,138 @@ +#!/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-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 + +CTI_LIST="" +for _dev in "$CS_BASE"/cti*; do + [ -e "$_dev" ] || continue + CTI_LIST="$CTI_LIST $(basename "$_dev")" +done +CTI_LIST="${CTI_LIST# }" + +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..8dd4b54d --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/CTI-Test/CTI-Test.yaml @@ -0,0 +1,20 @@ +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 + +run: + steps: + - REPO_PATH=$PWD + - cd Runner/suites/Kernel/DEBUG/CTI-Test + - ./run.sh || true + - $REPO_PATH/Runner/utils/send-to-lava.sh CTI-Test.res || true \ 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 100755 index 00000000..fc1f0b51 --- /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 + +CTI_DEVICES="" +for _dev in "$CS_BASE"/cti*; do + [ -e "$_dev" ] || continue + CTI_DEVICES="$CTI_DEVICES $(basename "$_dev")" +done +CTI_DEVICES="${CTI_DEVICES# }" + +if [ -z "$CTI_DEVICES" ]; then + log_fail "No CTI devices found in $CS_BASE" + echo "$TESTNAME 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)" + + _trig=0 + while [ "$_trig" -lt "$trigmax" ]; do + if [ "$_trig" -lt "$CTI_MAX_TRIGGERS" ]; then + trig="$_trig" + else + trig=$(( _trig % CTI_MAX_TRIGGERS )) + fi + + limit_ch=$(( CTI_MAX_CHANNELS - 1 )) + + _ch=0 + while [ "$_ch" -le "$limit_ch" ]; do + if [ "$_ch" -le "$chmax" ]; then + if [ "$NEW_VER" -eq 1 ]; then + set_trigin_attach "$trig" "$_ch" "$cti" + set_trigout_attach "$trig" "$_ch" "$cti" + else + map_cti_trigin "$trig" "$_ch" "$cti" + fi + fi + _ch=$(( _ch + 1 )) + done + + _trig=$(( _trig + 1 )) + 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..0a0502f4 --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/Node-Access/Node-Access.yaml @@ -0,0 +1,20 @@ +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 + +run: + steps: + - REPO_PATH=$PWD + - cd Runner/suites/Kernel/DEBUG/Node-Access + - ./run.sh || true + - $REPO_PATH/Runner/utils/send-to-lava.sh Node-Access.res || true \ 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 100755 index 00000000..bc5a10ca --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/Node-Access/run.sh @@ -0,0 +1,123 @@ +#!/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="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 ! echo | cat "$node" > /dev/null 2>&1; then + log_warn "Failed to read: $node" + 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 [ -f "$snode" ] && [ -r "$snode" ]; then + if ! echo | cat "$snode" > /dev/null 2>&1; then + log_fail "Failed to read mgmt node: $snode" + FAIL_COUNT=$((FAIL_COUNT + 1)) + fi + 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..85eb22bd --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/TGU-Enable-Disable.yaml @@ -0,0 +1,20 @@ +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 + +run: + steps: + - REPO_PATH=$PWD + - cd Runner/suites/Kernel/DEBUG/TGU-Enable-Disable + - ./run.sh || true + - $REPO_PATH/Runner/utils/send-to-lava.sh TGU-Enable-Disable.res || true \ 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 100755 index 00000000..663a4448 --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/run.sh @@ -0,0 +1,136 @@ +#!/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 || true + 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 || true + fi + done + fi +} + +if [ ! -d "$CS_BASE" ]; then + log_fail "Coresight directory not found" + echo "$TESTNAME FAIL" >> "$res_file" + exit 1 +fi + +TGU_LIST="" +for _d in "$CS_BASE"/tgu*; do + [ -d "$_d" ] || continue + TGU_LIST="$TGU_LIST $(basename "$_d")" +done +TGU_LIST="${TGU_LIST# }" + +if [ -z "$TGU_LIST" ]; then + log_warn "No TGU (Trace Generation Unit) devices found. Skipping test." + echo "$TESTNAME SKIP" >> "$res_file" + exit 0 +fi + +log_info "Found TGUs: $TGU_LIST" + +SINK_ENABLED=0 +for sink_name in $POTENTIAL_SINKS; do + sink_path="$CS_BASE/$sink_name" + [ -d "$sink_path" ] || continue + if [ -f "$sink_path/enable_sink" ]; then + echo 1 > "$sink_path/enable_sink" 2>/dev/null || true + log_info "Enabled sink: $sink_name" + SINK_ENABLED=1 + break + fi +done + +if [ "$SINK_ENABLED" -eq 0 ]; then + log_warn "No sink enabled — proceeding with TGU test anyway" +fi + +for tgu in $TGU_LIST; do + tgu_path="$CS_BASE/$tgu" + + if [ ! -f "$tgu_path/enable_tgu" ]; then + log_warn "No enable_tgu node for $tgu — skipping" + continue + fi + + if ! echo 1 > "$tgu_path/enable_tgu" 2>/dev/null; then + log_fail "Failed to enable TGU: $tgu" + FAIL_COUNT=$((FAIL_COUNT + 1)) + else + log_info "Enabled $tgu OK" + fi + + if ! echo 0 > "$tgu_path/enable_tgu" 2>/dev/null; then + log_fail "Failed to disable TGU: $tgu" + FAIL_COUNT=$((FAIL_COUNT + 1)) + else + log_info "Disabled $tgu OK" + fi +done + +for sink_name in $POTENTIAL_SINKS; do + sink_path="$CS_BASE/$sink_name" + [ -f "$sink_path/enable_sink" ] && echo 0 > "$sink_path/enable_sink" 2>/dev/null || true +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----------------------------" +