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----------------------------" +