Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions Runner/suites/Kernel/DEBUG/CTI-Enable-Disable/README.md
Original file line number Diff line number Diff line change
@@ -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.
135 changes: 135 additions & 0 deletions Runner/suites/Kernel/DEBUG/CTI-Enable-Disable/run.sh
Original file line number Diff line number Diff line change
@@ -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----------------------------"
13 changes: 13 additions & 0 deletions Runner/suites/Kernel/DEBUG/CTI-Test/CTI-Test.yaml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions Runner/suites/Kernel/DEBUG/CTI-Test/README.md
Original file line number Diff line number Diff line change
@@ -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.
Loading
Loading