-
Notifications
You must be signed in to change notification settings - Fork 30
Added tests for dmabuf validations #296
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| # DMA-BUF Configuration Validation Test | ||
|
|
||
| ## Overview | ||
|
|
||
| This test validates the DMA-BUF subsystem configuration on Qualcomm platforms, including kernel configuration, device tree setup, and system interfaces. | ||
|
|
||
| ## Test Coverage | ||
|
|
||
| ### 1. Kernel Configuration Validation | ||
| **Mandatory**: | ||
| - `CONFIG_DMA_SHARED_BUFFER CONFIG_DMABUF_HEAPS CONFIG_DMABUF_HEAPS_SYSTEM CONFIG_TEE_DMABUF_HEAPS CONFIG_HAS_DMA` - Core DMA-BUF support | ||
|
|
||
| **Optional but Recommended**: | ||
| - `CONFIG_DMA_HEAP` - Modern DMA heap interface | ||
| - `CONFIG_DMA_CMA` - Contiguous Memory Allocator | ||
|
|
||
| ### 2. Device Tree Validation | ||
| - Reserved memory nodes (`/proc/device-tree/reserved-memory`) | ||
| - Platform-specific DMA heap nodes | ||
| - Memory region sizes and configurations | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Run directly: | ||
| ```bash | ||
| cd /path/to/Runner/suites/Kernel/Baseport/dmabuf | ||
| ./run.sh | ||
| ``` | ||
|
|
||
| ### Run via test runner: | ||
| ```bash | ||
| cd /path/to/Runner | ||
| ./run-test.sh dmabuf | ||
| ``` | ||
|
|
||
| ## Test Results | ||
|
|
||
| Generates: | ||
| - `dmabuf.res` - Final result (PASS/FAIL) | ||
| - Console output with detailed validation steps | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| ### Required: | ||
| - `CONFIG_DMA_SHARED_BUFFER=y` in kernel config | ||
|
|
||
|
|
||
| ## Expected Output | ||
|
|
||
| ``` | ||
| [Executing test case: dmabuf] 1970-01-01 09:29:40 - | ||
| [INFO] 1970-01-01 09:29:40 - ================================================================================ | ||
| [INFO] 1970-01-01 09:29:40 - ============ Starting dmabuf Testcase ======================================= | ||
| [INFO] 1970-01-01 09:29:40 - ================================================================================ | ||
| [INFO] 1970-01-01 09:29:40 - === Kernel Configuration Validation === | ||
| [PASS] 1970-01-01 09:29:40 - Kernel config CONFIG_DMA_SHARED_BUFFER is enabled | ||
| [PASS] 1970-01-01 09:29:41 - Kernel config CONFIG_DMABUF_HEAPS is enabled | ||
| [PASS] 1970-01-01 09:29:41 - Kernel config CONFIG_DMABUF_HEAPS_SYSTEM is enabled | ||
| [PASS] 1970-01-01 09:29:41 - Kernel config CONFIG_TEE_DMABUF_HEAPS is enabled | ||
| [PASS] 1970-01-01 09:29:41 - Kernel config CONFIG_HAS_DMA is enabled | ||
| [PASS] 1970-01-01 09:29:41 - Core DMA-BUF configs available | ||
| [INFO] 1970-01-01 09:29:41 - Checking optional DMA-BUF configurations... | ||
| [FAIL] 1970-01-01 09:29:41 - Kernel config CONFIG_DMA_HEAP is missing or not enabled | ||
| [WARN] 1970-01-01 09:29:41 - CONFIG_DMA_HEAP: not enabled (optional) | ||
| [FAIL] 1970-01-01 09:29:41 - Kernel config CONFIG_DMA_CMA is missing or not enabled | ||
| [WARN] 1970-01-01 09:29:41 - CONFIG_DMA_CMA: not enabled (optional) | ||
| [INFO] 1970-01-01 09:29:41 - === Device Tree Validation === | ||
| [INFO] 1970-01-01 09:29:41 - Found reserved-memory node | ||
| [INFO] 1970-01-01 09:29:41 - Region: adsp-rpc-remote-heap@9cb80000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: adsp@86100000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: aop-cmd-db@80860000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: aop@80800000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: camera@84300000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: cdsp-secure-heap@81800000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: cdsp@88900000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: cpucp@80b00000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: cvp@8ae00000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: debug-vm@d0600000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: gpu-microcode@8b31a000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: hyp@80000000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: ipa-fw@8b300000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: ipa-gsi@8b310000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: mpss@8b800000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: qtee@c1300000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: sec-apps@808ff000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: smem@80900000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: tags@c0100000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: trusted-apps@c1800000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: tz-stat@c0000000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: video@8a700000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: wlan-fw@80c00000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: wpss@84800000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: xbl-uefi-res@80880000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: xbl@80700000 | ||
| [INFO] 1970-01-01 09:29:41 - Region: zap@8b71a000 | ||
| [INFO] 1970-01-01 09:29:41 - Found DMA heap node: /proc/device-tree/soc@0/dma-controller@1dc4000 | ||
| [INFO] 1970-01-01 09:29:41 - Found DMA heap node: /proc/device-tree/soc@0/dma-controller@3a84000 | ||
| [INFO] 1970-01-01 09:29:41 - Found DMA heap node: /proc/device-tree/soc@0/dma-controller@900000 | ||
| [INFO] 1970-01-01 09:29:41 - Found DMA heap node: /proc/device-tree/soc@0/dma-controller@a00000 | ||
| [INFO] 1970-01-01 09:29:41 - Found DMA heap node: /proc/device-tree/soc@0/dma-ranges | ||
| [INFO] 1970-01-01 09:29:41 - Found DMA heap node: /proc/device-tree/soc@0/dma@117f000 | ||
| [PASS] 1970-01-01 09:29:41 - Device tree validation passed (found 6 relevant nodes) | ||
| [INFO] 1970-01-01 09:29:41 - Found DMA heap device directory: /dev/dma_heap | ||
| [PASS] 1970-01-01 09:29:41 - Available heap: system | ||
| [PASS] 1970-01-01 09:29:41 - Total heaps found: 1 | ||
| [PASS] 1970-01-01 09:29:41 - dmabuf : Test Passed | ||
| [INFO] 1970-01-01 09:29:41 - -------------------Completed dmabuf Testcase---------------------------- | ||
| ``` | ||
|
|
||
| ## License | ||
|
|
||
| Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
| SPDX-License-Identifier: BSD-3-Clause | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| metadata: | ||
| format: Lava-Test Test Definition 1.0 | ||
| name: dmabuf_config | ||
|
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. Set YAML name: dmabuf (or rename test folder + TESTNAME + run-test invocation). Don’t mix. |
||
| description: "DMA-BUF kernel configuration and device tree validation" | ||
| maintainer: | ||
| - vnarapar@qti.qualcomm.com | ||
| os: | ||
| - openembedded | ||
| scope: | ||
| - functional | ||
| devices: | ||
| - rb3gen2 | ||
| - qcs6490 | ||
| - qcs8300 | ||
| - qcs9100 | ||
| - sa8775p | ||
|
|
||
| run: | ||
| steps: | ||
| - cd $PWD/suites/Kernel/Baseport/dmabuf | ||
| - ./run.sh | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| #!/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 (starting at $SCRIPT_DIR)" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Only source if not already loaded (idempotent) | ||
| if [ -z "$__INIT_ENV_LOADED" ]; then | ||
| # shellcheck disable=SC1090 | ||
| . "$INIT_ENV" | ||
| fi | ||
|
|
||
| # shellcheck disable=SC1090,SC1091 | ||
| . "$TOOLS/functestlib.sh" | ||
|
|
||
| TESTNAME="dmabuf" | ||
| test_path=$(find_test_case_by_name "$TESTNAME") | ||
| cd "$test_path" || exit 1 | ||
| res_file="./$TESTNAME.res" | ||
|
|
||
| log_info "================================================================================" | ||
| log_info "============ Starting $TESTNAME Testcase =======================================" | ||
| log_info "================================================================================" | ||
|
|
||
| pass=true | ||
|
|
||
| log_info "=== Kernel Configuration Validation ===" | ||
|
|
||
| CORE_CONFIGS="CONFIG_DMA_SHARED_BUFFER CONFIG_DMABUF_HEAPS CONFIG_DMABUF_HEAPS_SYSTEM CONFIG_TEE_DMABUF_HEAPS CONFIG_HAS_DMA" | ||
|
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. Core config list is likely too strict / not portable You require: On some upstream configs, TEE_DMABUF_HEAPS might not exist or may be module/disabled but DMA-BUF is still valid. Tier-1 mandatory (should fail if absent): Tier-2 recommended (warn): Also: there’s a confusion in README between CONFIG_DMA_HEAP and CONFIG_DMA_HEAP vs heaps framework. On upstream kernels, the feature is often CONFIG_DMABUF_HEAPS and the device nodes are /dev/dma_heap/*. Some trees have CONFIG_DMA_HEAP too, but not universal. |
||
|
|
||
| if ! check_kernel_config "$CORE_CONFIGS"; then | ||
|
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. Missing dependency checks / permissions handling This script assumes: listing /dev/dma_heap doesn’t need root (usually ok) |
||
| log_fail "Core DMA-BUF kernel config validation failed" | ||
| pass=false | ||
| else | ||
| log_pass "Core DMA-BUF configs available" | ||
| fi | ||
|
|
||
| OPTIONAL_CONFIGS="CONFIG_DMA_HEAP CONFIG_DMA_CMA" | ||
|
|
||
| log_info "Checking optional DMA-BUF configurations..." | ||
| for cfg in $OPTIONAL_CONFIGS; do | ||
| if check_kernel_config "$cfg" 2>/dev/null; then | ||
| log_pass " $cfg: enabled" | ||
| else | ||
| log_warn " $cfg: not enabled (optional)" | ||
| fi | ||
| done | ||
|
|
||
| log_info "=== Device Tree Validation ===" | ||
|
|
||
| found_nodes=0 | ||
|
|
||
| if [ -d "/proc/device-tree/reserved-memory" ]; then | ||
| log_info "Found reserved-memory node" | ||
|
|
||
| for region in /proc/device-tree/reserved-memory/*; do | ||
| if [ -d "$region" ]; then | ||
| region_name=$(basename "$region") | ||
| log_info " Region: $region_name" | ||
| fi | ||
| done | ||
| fi | ||
|
|
||
| for heap_path in /proc/device-tree/soc*/dma* /proc/device-tree/soc*/qcom,ion* /proc/device-tree/ion* ; do | ||
|
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. Please use dt related functions which are already available in functestlib.sh |
||
| if [ -e "$heap_path" ]; then | ||
| log_info "Found DMA heap node: $heap_path" | ||
| found_nodes=$((found_nodes + 1)) | ||
| fi | ||
| done | ||
|
|
||
| if [ "$found_nodes" -gt 0 ]; then | ||
| log_pass "Device tree validation passed (found $found_nodes relevant nodes)" | ||
| else | ||
| log_fail "No DMA-BUF specific device-tree nodes found" | ||
| pass=false | ||
| fi | ||
|
|
||
| # Check for DMA heap devices | ||
| if [ -d "/dev/dma_heap" ]; then | ||
| log_info "Found DMA heap device directory: /dev/dma_heap" | ||
|
|
||
| heap_count=0 | ||
| for heap in /dev/dma_heap/*; do | ||
| if [ -e "$heap" ]; then | ||
| heap_name=$(basename "$heap") | ||
| log_pass " Available heap: $heap_name" | ||
| heap_count=$((heap_count + 1)) | ||
| fi | ||
| done | ||
| log_pass "Total heaps found: $heap_count" | ||
| else | ||
| log_fail "DMA heap device directory not found" | ||
| pass=false | ||
| fi | ||
|
|
||
| if $pass; then | ||
| log_pass "$TESTNAME : Test Passed" | ||
| echo "$TESTNAME PASS" > "$res_file" | ||
| else | ||
| log_fail "$TESTNAME : Test Failed" | ||
| echo "$TESTNAME FAIL" > "$res_file" | ||
| fi | ||
| log_info "-------------------Completed $TESTNAME Testcase----------------------------" | ||
| exit 0 | ||
|
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. Kernel-functional extensions for dmabuf Right now it’s “presence validation”. To make it functional without requiring special userspace: Extension 1: Quick allocate/free sanity (if you have an allocator interface) Some environments have dma-heap test tools; most don’t. For now: Extension 2: dmabuf sysfs/debug info (optional) Treat as INFO/WARN only. B) Review: dmabuf_heap_kselftest (runs upstream selftest) What’s good Good CLI flag parser (--binary-path), POSIX-friendly. Captures output to a file and prints it (good for LAVA artifacts and debugging). Handles TAP totals line if present; otherwise counts ok/not ok/skip. Issues / fixes needed
README says: ./run.sh /custom/path/to/dmabuf-heap But the script does not accept positional path (it ignores positional args, only supports -b/--binary-path). It even prints: log_info " ./run.sh /path/to/dmabuf-heap" That instruction is wrong. Fix Either: support positional path (simpler), OR fix README + log message to match --binary-path. I’d recommend supporting positional path because it’s convenient and backwards compatible: if $1 doesn’t start with -, treat it as binary path.
You create: output_file="./OUTPUTFILE.res" That’s confusing in this repo because .res is the final verdict file. Also you delete it at end, so it’s not even an artifact. Fix Use mktemp or ./dmabuf_heap_kselftest.out (or ./logs/... if you have standard log dirs). Better: output_file="$(mktemp "$TESTNAME.XXXXXX.log")" with trap cleanup or keep it and don’t delete so LAVA can archive it. Given your earlier preferences: usually you keep logs.
This part: pass_count=$(echo "$totals_line" | grep -o " pass:[0-9]*" | cut -d':' -f2) grep -o isn’t guaranteed on very minimal busybox (often present, but not always). The pattern includes leading space; ok, but still fragile. Fix Parse with awk reliably: extract numbers after pass: fail: etc. Example robust parse: pass_count=$(echo "$totals_line" | awk -F'pass:| ' '{print $2}' | awk -F' ' '{print $1}') or one awk script.
Fallback: pass_count=$(grep -c "^ok " ...) But TAP marks skip as ok N # SKIP ..., so pass_count includes skipped tests. That leads to inflated pass count. Fix When using fallback mode: pass = ok lines that are NOT SKIP skip = ok lines that are SKIP Example: skip_count=$(grep -c "^ok .*# SKIP" "$output_file") pass_count=$(grep -c "^ok " "$output_file") - skip_count
You set: pass=false if fail_count>0 OR error_count>0 OR exit_code!=0 OR pass_count==0. That’s fine, but note: Some selftests exit non-zero even when TAP shows pass (rare, but possible), or vice versa. Best practice: trust TAP totals first; if totals show fail=0 and error=0, treat as pass even if exit code non-zero but log warn. Fix Priority:
You use grep, awk, cut, mktemp not used but would be good, basename, etc. Fix Add: deps_list="grep awk cut basename date" (whatever your functestlib expects) If missing -> SKIP, not FAIL. |
||
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.
In run.sh they are WARN-only (good), but README shows FAIL lines for optional configs. That’s confusing. Update README expected output to show WARN/INFO for optional configs only.