Repository navigation
SoC_Infra: add SoC_Infra_GPU_Clock_Rate_Validation suite #695
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
VinodGudla
wants to merge
2
commits into
qualcomm-linux:main
Choose a base branch
from
VinodGudla:feature/soc_infra_gpu_clock_rate
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.
+256
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
88 changes: 88 additions & 0 deletions
88
Runner/suites/Kernel/Baseport/SoC_Infra_GPU_Clock_Rate_Validation/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,88 @@ | ||
| Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
| SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| # SoC_Infra_GPU_Clock_Rate_Validation | ||
|
|
||
| Checks that every GPU clock rate exposed by the Linux clock framework in debugfs | ||
| (`/sys/kernel/debug/clk/gpu*/clk_rate`) is a valid integer. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Root access, because debugfs is readable by root only. | ||
| - debugfs mounted at `/sys/kernel/debug` (or `/debug`) with the clock tree under | ||
| `<debugfs>/clk`, which needs `CONFIG_DEBUG_FS`. The test does not mount it. | ||
| debugfs is optional on production images, so the test skips when it is not | ||
| available. A GPU clock controller in the device tree does not change that. | ||
| - The GPU clock controller driver loaded on platforms that have one. | ||
| - Base utilities: `find`, `grep`, `cat`, `tr`, `readlink`, `dirname`, `basename`, `mktemp`. | ||
| The test never installs packages. It skips when a utility is missing. | ||
|
|
||
| The test only reads files. It changes no module, service, mount or setting, so | ||
| there is nothing to clean up on the device. | ||
|
|
||
| ## Applicability | ||
|
|
||
| The runtime device tree decides whether the platform has a GPU clock controller: | ||
| an enabled node whose compatible string contains `-gpucc`, for example | ||
| `qcom,sm8550-gpucc`. | ||
|
|
||
| ## Usage | ||
|
|
||
| The suite has no command-line options and no environment overrides. | ||
|
|
||
| ```sh | ||
| cd Runner | ||
| ./run-test.sh SoC_Infra_GPU_Clock_Rate_Validation | ||
| ``` | ||
|
|
||
| It can also be run directly: | ||
|
|
||
| ```sh | ||
| cd Runner/suites/Kernel/Baseport/SoC_Infra_GPU_Clock_Rate_Validation | ||
| ./run.sh | ||
| ``` | ||
|
|
||
| ## Results and logs | ||
|
|
||
| All files are written to the directory the test is started from. That is the suite | ||
| directory when the test runs through `run-test.sh`, the LAVA definition, or | ||
| `./run.sh` inside the suite directory: | ||
|
|
||
| | File | Content | | ||
| |---|---| | ||
| | `SoC_Infra_GPU_Clock_Rate_Validation.res` | Final verdict: `PASS`, `FAIL` or `SKIP` | | ||
| | `gpu_clk_rates.log` | One `<clock> <rate>` line per clock; a bad value shows as `NOT_INTEGER(<value>)` and an unreadable file as `READ_ERROR` | | ||
| | `SoC_Infra_GPU_Clock_Rate_Validation_stdout_<time>.log` | Captured console output of the run | | ||
|
|
||
| These files are runtime output and must not be committed. | ||
|
|
||
| ## PASS, FAIL and SKIP | ||
|
|
||
| | Verdict | Condition | | ||
| |---|---| | ||
| | PASS | At least one `gpu*` clock exists and each `clk_rate` file holds exactly one non-negative integer. A rate of `0` is valid, because a gated clock reports zero. | | ||
| | FAIL | A `gpu*` clock rate is not a single integer (for example `12 34`, which is not merged into `1234`) or cannot be read. | | ||
| | FAIL | debugfs and `<debugfs>/clk` are available and the device tree has a GPU clock controller, but no `gpu*` clock is registered. This points to a missing or failed GPU clock driver. | | ||
| | SKIP | debugfs is not mounted or not readable, whatever the device tree says. | | ||
| | SKIP | `<debugfs>/clk` is not available, whatever the device tree says. | | ||
| | SKIP | debugfs and `<debugfs>/clk` are available, no `gpu*` clock is registered, and the device tree has no GPU clock controller. | | ||
| | SKIP | A required base utility is missing. | | ||
|
|
||
| Each `clk_rate` value is validated with `is_unsigned_number` exactly as read. Only | ||
| the trailing newline is dropped, so embedded whitespace makes the value invalid. | ||
|
|
||
| ## LAVA publication | ||
|
|
||
| The LAVA definition publishes the result with | ||
| `send-to-lava.sh SoC_Infra_GPU_Clock_Rate_Validation.res --strict --expected-testcase-id SoC_Infra_GPU_Clock_Rate_Validation`. | ||
| If `run.sh` exits early and leaves no valid result, the publish step fails instead | ||
| of reporting nothing. The step is the last one in the definition, so its failure | ||
| status is kept. | ||
|
|
||
| ## Shared helpers | ||
|
|
||
| The suite uses two helpers added to `Runner/utils/functestlib.sh`: | ||
|
|
||
| - `socinfra_debugfs_root` prints the mounted debugfs root. | ||
| - `socinfra_check_clk_rates` reads `clk_rate` for a clock name prefix and checks | ||
| the value with `is_unsigned_number`. | ||
15 changes: 15 additions & 0 deletions
15
...nel/Baseport/SoC_Infra_GPU_Clock_Rate_Validation/SoC_Infra_GPU_Clock_Rate_Validation.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,15 @@ | ||
| metadata: | ||
| name: soc-infra-gpu-clock-rate-validation | ||
| format: "Lava-Test Test Definition 1.0" | ||
| description: "Validate that every GPU clock rate exposed in debugfs is a valid integer" | ||
| os: | ||
| - linux | ||
| scope: | ||
| - functional | ||
|
|
||
| run: | ||
| steps: | ||
| - REPO_PATH=$PWD | ||
| - cd Runner/suites/Kernel/Baseport/SoC_Infra_GPU_Clock_Rate_Validation | ||
| - ./run.sh || true | ||
| - $REPO_PATH/Runner/utils/send-to-lava.sh SoC_Infra_GPU_Clock_Rate_Validation.res --strict --expected-testcase-id SoC_Infra_GPU_Clock_Rate_Validation |
100 changes: 100 additions & 0 deletions
100
Runner/suites/Kernel/Baseport/SoC_Infra_GPU_Clock_Rate_Validation/run.sh
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,100 @@ | ||
| #!/bin/sh | ||
|
|
||
| # Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| # ---------- Repo env + helpers ---------- | ||
| SCRIPT_DIR="$( | ||
| cd "$(dirname "$0")" || exit 1 | ||
| 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 | ||
|
|
||
| # Only source once (idempotent) | ||
| # NOTE: We intentionally **do not export** any new vars. They stay local to this shell. | ||
| if [ -z "${__INIT_ENV_LOADED:-}" ]; then | ||
| # shellcheck disable=SC1090 | ||
| . "$INIT_ENV" | ||
| __INIT_ENV_LOADED=1 | ||
| fi | ||
|
|
||
| # shellcheck disable=SC1090 | ||
| . "$INIT_ENV" | ||
| # shellcheck disable=SC1091 | ||
| . "$TOOLS/functestlib.sh" | ||
|
|
||
| TESTNAME="SoC_Infra_GPU_Clock_Rate_Validation" | ||
| RES_FILE="./$TESTNAME.res" | ||
| test_result_init "$TESTNAME" "$RES_FILE" || exit 1 | ||
|
|
||
| CLK_PREFIX="gpu" | ||
| GPUCC_ERE='(^|[[:space:]])qcom,[[:alnum:]_-]+-gpucc([[:space:]]|$)' | ||
| REPORT_FILE="./gpu_clk_rates.log" | ||
|
|
||
| log_info "--------------------------------------------------------------------------" | ||
| log_info "Starting $TESTNAME" | ||
|
|
||
| # Never install packages on the target; skip when a base utility is missing. | ||
| if ! CHECK_DEPS_RECOVER=0 CHECK_DEPS_NO_EXIT=1 check_dependencies find grep cat tr readlink dirname basename mktemp; then | ||
| test_result_finish "SKIP" "$TESTNAME SKIP: required base utilities are unavailable" | ||
| fi | ||
|
|
||
| # debugfs is a prerequisite of its own. It needs CONFIG_DEBUG_FS and a mount, and | ||
| # the clk/ tree exists only when the clock framework registered its debugfs | ||
| # files. A GPU clock controller in the device tree guarantees none of that, so an | ||
| # unavailable interface is a SKIP, not a FAIL. FAIL is kept below for the cases | ||
| # where the interface is present and the clocks are still broken. | ||
| if ! debugfs_root=$(socinfra_debugfs_root); then | ||
| test_result_finish "SKIP" "$TESTNAME SKIP: debugfs is not mounted or not readable, so the clock tree is unavailable (mount -t debugfs debugfs /sys/kernel/debug, run as root)" | ||
| fi | ||
| if [ ! -d "$debugfs_root/clk" ] || [ ! -r "$debugfs_root/clk" ] || [ ! -x "$debugfs_root/clk" ]; then | ||
| test_result_finish "SKIP" "$TESTNAME SKIP: $debugfs_root/clk is not available, the kernel does not expose the clock tree in debugfs" | ||
| fi | ||
|
|
||
| # The interface is usable. The device tree now decides whether the platform has | ||
| # a GPU clock controller, so having no GPU clocks on such a platform is a failure | ||
| # and not a skip. | ||
| gpucc_in_dt=0 | ||
| if dt_list_compatible_nodes "$GPUCC_ERE" regex >/dev/null 2>&1; then | ||
| gpucc_in_dt=1 | ||
| fi | ||
| log_info "GPU clock controller (*-gpucc) in the device tree: $gpucc_in_dt" | ||
| log_info "Checking $debugfs_root/clk/${CLK_PREFIX}*/clk_rate" | ||
|
|
||
| socinfra_check_clk_rates "$debugfs_root" "$CLK_PREFIX" "$REPORT_FILE" | ||
| clk_rc=$? | ||
| log_info "Clocks checked: total=$SOCINFRA_CLK_TOTAL invalid=$SOCINFRA_CLK_BAD (details: $REPORT_FILE)" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Job 619157 reports PASS for 18 clocks, but stdout contains none of their names or rates. Replay |
||
|
|
||
| case "$clk_rc" in | ||
| 0) | ||
| test_result_record "PASS" "All $SOCINFRA_CLK_TOTAL ${CLK_PREFIX}* clock rates are integers" | ||
| ;; | ||
| 2) | ||
| if [ "$gpucc_in_dt" -eq 1 ]; then | ||
| test_result_finish "FAIL" "$TESTNAME FAIL: the device tree has a GPU clock controller but no ${CLK_PREFIX}* clocks are registered under $debugfs_root/clk; check the GPU clock driver" | ||
| fi | ||
| test_result_finish "SKIP" "$TESTNAME SKIP: no ${CLK_PREFIX}* clocks under $debugfs_root/clk and no GPU clock controller in the device tree" | ||
| ;; | ||
| *) | ||
| grep -E 'NOT_INTEGER|READ_ERROR' "$REPORT_FILE" | while IFS= read -r bad_line; do | ||
| log_fail "Invalid clock rate: $bad_line" | ||
| done | ||
| test_result_record "FAIL" "$SOCINFRA_CLK_BAD of $SOCINFRA_CLK_TOTAL ${CLK_PREFIX}* clock rates are not valid integers or cannot be read" | ||
| ;; | ||
| esac | ||
|
|
||
| test_result_finish | ||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The clock core can retain a nonzero cached rate for a gated clock or return zero for an unresolved parent. Please replace the gated-clock explanation with: zero is accepted by this readability/format check, which does not establish the physical frequency or clock enable state.