-
Notifications
You must be signed in to change notification settings - Fork 33
Added CoreSight TPDM automated Scripts #363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Rohan-in-Qualcomm
wants to merge
1
commit into
qualcomm-linux:main
Choose a base branch
from
Rohan-in-Qualcomm:debug-tpdm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # TPDM-Enable-Disable Test | ||
|
|
||
| ## Overview | ||
|
|
||
| This test acts as a stress test for the Coresight Trace Port Debug Module (TPDM) drivers. It repeatedly enables and disables all available TPDM sources to verify the stability and correctness of the toggling mechanism under repeated stress. | ||
|
|
||
| ## Test Goals | ||
|
|
||
| - Validate the stability of the TPDM drivers under repeated enable/disable cycles. | ||
| - Ensure all TPDM sources can be successfully toggled without causing system hangs or crashes. | ||
| - Verify that sysfs states correctly reflect the enabled/disabled status across multiple rapid transitions. | ||
| - Ensure 100% success rate across 50 iterations for pass criteria. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Kernel must be built with Coresight TPDM support. | ||
| - `sysfs` access to `/sys/bus/coresight/devices/`. | ||
| - Root privileges (to configure source enables). | ||
|
|
||
| ## Script Location | ||
|
|
||
| ``` | ||
| Runner/suites/Kernel/DEBUG/TPDM-Enable-Disable/run.sh | ||
| ``` | ||
|
|
||
| ## Files | ||
|
|
||
| - `run.sh` - Main test script | ||
| - `TPDM-Enable-Disable.res` - Summary result file with PASS/FAIL | ||
| - `TPDM-Enable-Disable.log` - Full execution log (generated if logging is enabled) | ||
|
|
||
| ## How It Works | ||
|
|
||
| 1. **Discovery**: Scans `/sys/bus/coresight/devices/` for all available TPDM devices (e.g., `tpdm*`). | ||
| 2. **Setup**: Resets all Coresight devices to ensure a clean state. | ||
| 3. **Loop (50 Iterations)**: | ||
| - **Enable**: Attempts to enable each discovered TPDM device. | ||
| - **Verify**: Confirms the device successfully transitioned to the enabled state. | ||
| - **Disable**: Attempts to disable each TPDM device. | ||
| - **Verify**: Confirms the device successfully transitioned to the disabled state. | ||
| 4. **Teardown**: Ensures all devices are left in a disabled, clean state. | ||
|
|
||
| ## Usage | ||
|
|
||
| Run the script directly via the framework: | ||
|
|
||
| ```bash | ||
| ./run.sh | ||
| ``` | ||
|
|
||
| ## Example Output | ||
|
|
||
| ``` | ||
| [INFO] 2026-03-23 05:42:18 - ----------------------------------------------------------------------------------------- | ||
| [INFO] 2026-03-23 05:42:18 - -------------------Starting TPDM-Enable-Disable Testcase---------------------------- | ||
| [INFO] 2026-03-23 05:42:18 - Iteration: 0 - PASS | ||
| [INFO] 2026-03-23 05:42:19 - Iteration: 1 - PASS | ||
| [INFO] 2026-03-23 05:42:19 - Iteration: 2 - PASS | ||
| [INFO] 2026-03-23 05:42:20 - Iteration: 3 - PASS | ||
| [INFO] 2026-03-23 05:42:20 - Iteration: 4 - PASS | ||
| ..... | ||
| [INFO] 2026-03-23 05:42:38 - Iteration: 49 - PASS | ||
| [INFO] 2026-03-23 05:42:39 - Iteration: 50 - PASS | ||
| [PASS] 2026-03-23 05:42:39 - -------------enable/disable TPDMs Test PASS------------- | ||
| [INFO] 2026-03-23 05:42:39 - -------------------TPDM-Enable-Disable Testcase Finished---------------------------- | ||
| ``` | ||
|
|
||
| ## Return Code | ||
|
|
||
| - `0` — All 50 iterations successfully enabled and disabled the TPDM sources | ||
| - `1` — One or more iterations failed to toggle a source or verify its state | ||
|
|
||
| ## Integration in CI | ||
|
|
||
| - Can be run standalone or via LAVA | ||
|
|
||
| - Result file TPDM-Enable-Disable.res will be parsed by result_parse.sh | ||
|
|
||
| ## Notes | ||
|
|
||
| - The test performs exactly 50 iterations specifically to catch intermittent concurrency bugs or resource leaks in the driver's enable/disable path. | ||
|
|
||
| - A failure in any single iteration immediately flags the overall test run as a failure. | ||
|
|
||
| ## License | ||
|
|
||
| SPDX-License-Identifier: BSD-3-Clause-Clear | ||
|
|
||
| (c) Qualcomm Technologies, Inc. and/or its subsidiaries. |
16 changes: 16 additions & 0 deletions
16
Runner/suites/Kernel/DEBUG/TPDM-Enable-Disable/TPDM-Enable-Disable.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| metadata: | ||
| name: TPDM-Enable-Disable | ||
| format: "Lava-Test Test Definition 1.0" | ||
| description: "Script to repeatedly enable and disable all TPDM coresight sources and verify their status." | ||
| os: | ||
| - linux | ||
| scope: | ||
| - coresight | ||
| - kernel | ||
|
|
||
| run: | ||
| steps: | ||
| - REPO_PATH=$PWD || true | ||
| - cd Runner/suites/Kernel/DEBUG/TPDM-Enable-Disable || true | ||
| - ./run.sh || true | ||
| - $REPO_PATH/Runner/utils/send-to-lava.sh TPDM-Enable-Disable.res || true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| #!/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" | ||
| __INIT_ENV_LOADED=1 | ||
|
|
||
| fi | ||
|
|
||
| # shellcheck disable=SC1090,SC1091 | ||
| . "$TOOLS/functestlib.sh" | ||
| # shellcheck disable=SC1090,SC1091 | ||
| . "$TOOLS/coresight_helper.sh" | ||
|
|
||
| TESTNAME="TPDM-Enable-Disable" | ||
| res_file="./$TESTNAME.res" | ||
| log_info "-----------------------------------------------------------------------------------------" | ||
| log_info "-------------------Starting $TESTNAME Testcase----------------------------" | ||
| cs_base="/sys/bus/coresight/devices" | ||
|
|
||
| etf_path=$(find_path "tmc_etf0" "tmc_etf" "tmc_etf1" "coresight-tmc_etf" "coresight-tmc_etf0") | ||
| if [ -z "$etf_path" ]; then | ||
| log_fail "TMC-ETF sink not found. Cannot proceed." | ||
| echo "$TESTNAME FAIL" > "$res_file" | ||
| exit 1 | ||
| fi | ||
|
|
||
| tpdm_count=0 | ||
| for node_path in "$cs_base"/tpdm* "$cs_base"/coresight-tpdm*; do | ||
| [ -d "$node_path" ] && tpdm_count=$((tpdm_count + 1)) | ||
| done | ||
|
|
||
| if [ "$tpdm_count" -eq 0 ]; then | ||
| log_fail "No TPDM devices found on the system." | ||
| echo "$TESTNAME FAIL" > "$res_file" | ||
| exit 1 | ||
| fi | ||
|
|
||
| fail=0 | ||
| i=0 | ||
|
|
||
| reset_devices | ||
|
|
||
| [ -f "$etf_path/enable_sink" ] && echo 1 > "$etf_path/enable_sink" 2>/dev/null | ||
|
|
||
| while [ "$i" -le 50 ]; do | ||
| iter_fail=0 | ||
|
|
||
| for node_path in "$cs_base"/tpdm* "$cs_base"/coresight-tpdm*; do | ||
| [ ! -d "$node_path" ] && continue | ||
|
|
||
| node_name=$(basename "$node_path") | ||
|
|
||
| if echo "$node_name" | grep -q "tpdm-turing-llm"; then | ||
| continue | ||
| fi | ||
|
|
||
| if [ ! -f "$node_path/enable_source" ]; then | ||
| continue | ||
| fi | ||
|
|
||
| echo 1 > "$node_path/enable_source" 2>/dev/null | ||
| if [ "$(cat "$node_path/enable_source" 2>/dev/null)" != "1" ]; then | ||
| iter_fail=1 | ||
| log_fail "Iter $i: Failed to enable $node_name" | ||
| echo "$TESTNAME FAIL" > "$res_file" | ||
| fi | ||
|
|
||
| echo 0 > "$node_path/enable_source" 2>/dev/null | ||
| if [ "$(cat "$node_path/enable_source" 2>/dev/null)" = "1" ]; then | ||
| iter_fail=1 | ||
| log_fail "Iter $i: Failed to disable $node_name" | ||
| echo "$TESTNAME FAIL" > "$res_file" | ||
| fi | ||
| done | ||
|
|
||
| if [ "$iter_fail" -eq 0 ]; then | ||
| log_info "Iteration: $i - PASS" | ||
| else | ||
| log_fail "Iteration: $i - FAIL" | ||
| fail=1 | ||
| fi | ||
|
|
||
| i=$((i+1)) | ||
| done | ||
|
|
||
| [ -f "$etf_path/enable_sink" ] && echo 0 > "$etf_path/enable_sink" 2>/dev/null | ||
| reset_devices | ||
|
|
||
| if [ "$fail" -eq 0 ]; then | ||
| log_pass "-------------enable/disable TPDMs Test PASS-------------" | ||
| echo "$TESTNAME PASS" > "$res_file" | ||
| else | ||
| log_fail "-------------enable/disable TPDMs Test FAIL-------------" | ||
| echo "$TESTNAME FAIL" > "$res_file" | ||
| fi | ||
|
|
||
| log_info "-------------------$TESTNAME Testcase Finished----------------------------" | ||
101 changes: 101 additions & 0 deletions
101
Runner/suites/Kernel/DEBUG/TPDM-Interface-Access/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| # TPDM-Interface-Access Test | ||
|
|
||
| ## Overview | ||
| This test performs comprehensive reads across all Trace Profiling and Diagnostics Monitor (TPDM) sysfs interfaces within the Coresight subsystem. It ensures that sysfs nodes correctly expose dataset properties and that interfaces remain securely readable without causing panics or "Invalid argument" responses. | ||
|
|
||
| ## Test Goals | ||
|
|
||
| - Dynamically scan and iterate through all registered TPDM devices in `/sys/bus/coresight/devices/`. | ||
| - Validate the dataset map implementation mapping (DSB, CMB, TC, BC, GPR, MCMB). | ||
| - Validate dataset configuration properties (e.g. converting hexadecimal active datasets mappings to logical subsystem checks). | ||
| - Prevent and detect attribute read failures on dynamically exposed sysfs device interfaces. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Kernel must be built with Coresight TPDM/ETF source support. | ||
| - `sysfs` access to `/sys/bus/coresight/devices/`. | ||
| - DebugFS access to `/d/npu/ctrl` or `/sys/kernel/debug/npu/ctrl` for TPDM-NPU tests. | ||
| - Root privileges (to configure Coresight source elements and access hardware attributes). | ||
|
|
||
| ## Script Location | ||
|
|
||
| ``` | ||
| Runner/suites/Kernel/DEBUG/TPDM-Interface-Access/run.sh | ||
| ``` | ||
|
|
||
| ## Files | ||
|
|
||
| - `run.sh` - Main test script | ||
| - `TPDM-Interface-Access.res` - Summary result file with PASS/FAIL | ||
| - `TPDM-Interface-Access.log` - Full execution log (generated if logging is enabled via functestlib) | ||
|
|
||
| ## How It Works | ||
|
|
||
| The test uses a two-pronged approach: | ||
|
|
||
| 1. **Dataset Verification Phase**: | ||
| - Dynamically discovers all TPDM nodes. | ||
| - Parses the active bit map exposed by the node's `enable_datasets` file. | ||
| - Translates the hex output to human-readable subsets (e.g., DSB, CMB). | ||
| - Dynamically probes every sysfs file matching the mapped properties to ensure driver readability. | ||
| 2. **Global Read Validation Phase**: | ||
| - Flushes all coresight elements (Resets sinks and sources to `0`). | ||
| - Recursively performs standard `cat` reads on every readable (`-r`) generic node under the device. | ||
| - Detects node read failures that typically indicate misconfigured kernel data boundaries. | ||
|
|
||
| ## Usage | ||
|
|
||
| Run the script directly. No iterations or special arguments are required for this basic test. | ||
|
|
||
| ```bash | ||
| ./run.sh | ||
| ``` | ||
|
|
||
| ## Example Output | ||
|
|
||
| ``` | ||
| [INFO] 2026-03-23 05:56:52 - ------------------------------------------------------ | ||
| [INFO] 2026-03-23 05:56:52 - Starting Testcase: TPDM-Interface-Access | ||
| [INFO] 2026-03-23 05:56:52 - Performing initial device reset... | ||
| [INFO] 2026-03-23 05:56:52 - --- Phase 1: Source dataset mode tests --- | ||
| [INFO] 2026-03-23 05:56:52 - Testing device: tpdm0 | ||
| [INFO] 2026-03-23 05:56:52 - Default datasets: (Mode: 00) -> Configurations: none | ||
| [INFO] 2026-03-23 05:56:52 - Testing device: tpdm1 | ||
| [INFO] 2026-03-23 05:56:52 - Default datasets: (Mode: 00) -> Configurations: none | ||
| ...... | ||
| [INFO] 2026-03-23 05:56:52 - Testing device: tpdm8 | ||
| [INFO] 2026-03-23 05:56:52 - Default datasets: (Mode: 00) -> Configurations: none | ||
| [INFO] 2026-03-23 05:56:52 - Testing device: tpdm9 | ||
| [INFO] 2026-03-23 05:56:52 - Default datasets: (Mode: 00) -> Configurations: none | ||
| [PASS] 2026-03-23 05:56:52 - Phase 1 Completed: All TPDM mode attributes check passed | ||
| [INFO] 2026-03-23 05:56:52 - Performing mid-test device reset... | ||
| [INFO] 2026-03-23 05:56:52 - --- Phase 2: Readable attributes check --- | ||
| [INFO] 2026-03-23 05:56:52 - Reading 8 accessible nodes under tpdm0 | ||
| [INFO] 2026-03-23 05:56:52 - Reading 8 accessible nodes under tpdm1 | ||
| ...... | ||
| [INFO] 2026-03-23 05:56:52 - Reading 8 accessible nodes under tpdm8 | ||
| [INFO] 2026-03-23 05:56:52 - Reading 8 accessible nodes under tpdm9 | ||
| [PASS] 2026-03-23 05:56:52 - Result: TPDM-Interface-Access PASS | ||
| [INFO] 2026-03-23 05:33:24 - -------------------TPDM-Interface-Access Testcase Finished---------------------------- | ||
|
|
||
| ``` | ||
|
|
||
| ## Return Code | ||
|
|
||
| - `0` — All attributes were read successfully without any panics, permission denials, or generic read errors | ||
| - `1` — One or more files in the TPDM tree failed to perform a valid return on cat | ||
|
|
||
| ## Integration in CI | ||
|
|
||
| - Can be run standalone or via LAVA | ||
| - Result file TPDM-Interface-Access.res will be parsed by result_parse.sh | ||
|
|
||
| ## Notes | ||
|
|
||
| - `tpdm-turing-llm` node paths are hardcoded to be skipped as per hardware testing constraints | ||
| - If tpdm-npu is detected, the framework will temporarily write to the NPU debugger control map at /sys/kernel/debug/npu/ctrl | ||
|
|
||
| ## License | ||
|
|
||
| SPDX-License-Identifier: BSD-3-Clause-Clear | ||
| (c) Qualcomm Technologies, Inc. and/or its subsidiaries. |
16 changes: 16 additions & 0 deletions
16
Runner/suites/Kernel/DEBUG/TPDM-Interface-Access/TPDM-Interface-Access.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| metadata: | ||
| name: TPDM-Interface-Access | ||
| format: "Lava-Test Test Definition 1.0" | ||
| description: "Test reading all active and inactive TPDM node interfaces, verifying dataset configurations and sysfs attributes." | ||
| os: | ||
| - linux | ||
| scope: | ||
| - coresight | ||
| - kernel | ||
|
|
||
| run: | ||
| steps: | ||
| - REPO_PATH=$PWD || true | ||
| - cd Runner/suites/Kernel/DEBUG/TPDM-Interface-Access || true | ||
| - ./run.sh || true | ||
| - $REPO_PATH/Runner/utils/send-to-lava.sh TPDM-Interface-Access.res || true |
Oops, something went wrong.
You are viewing a condensed version of this merge commit. You can view the full changes here.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.