Skip to content

Commit 0131108

Browse files
committed
Add DMA enablement tests
Added the tests to check DMA configs, Device Tree Validation and upstream kselftests Signed-off-by: Vamsee Narapareddi <vnarapar@qti.qualcomm.com>
1 parent d37dcc2 commit 0131108

File tree

7 files changed

+759
-0
lines changed

7 files changed

+759
-0
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# DMA-BUF Configuration Validation Test
2+
3+
## Overview
4+
5+
This test validates the DMA-BUF subsystem configuration on Qualcomm platforms, including kernel configuration, device tree setup, and system interfaces.
6+
7+
## Test Coverage
8+
9+
### 1. Kernel Configuration Validation
10+
**Mandatory**:
11+
- `CONFIG_DMA_SHARED_BUFFER CONFIG_DMABUF_HEAPS CONFIG_DMABUF_HEAPS_SYSTEM` - Core DMA-BUF support
12+
13+
**Optional but Recommended**:
14+
- `CONFIG_DMA_HEAP` - Modern DMA heap interface
15+
- `CONFIG_DMA_CMA` - Contiguous Memory Allocator
16+
- `CONFIG_TEE_DMABUF_HEAPS`
17+
- `CONFIG_HAS_DMA`
18+
19+
### 2. Device Tree Validation
20+
- Reserved memory nodes (`/proc/device-tree/reserved-memory`) - informational
21+
- Platform-specific DMA heap nodes
22+
- Memory region sizes and configurations
23+
24+
## Usage
25+
26+
### Run directly:
27+
```bash
28+
cd /path/to/Runner/suites/Kernel/Baseport/dmabuf
29+
./run.sh
30+
```
31+
32+
### Run via test runner:
33+
```bash
34+
cd /path/to/Runner
35+
./run-test.sh dmabuf
36+
```
37+
38+
## Test Results
39+
40+
Generates:
41+
- `dmabuf.res` - Final result (PASS/FAIL)
42+
- Console output with detailed validation steps
43+
44+
## Prerequisites
45+
46+
### Required:
47+
- `CONFIG_DMA_SHARED_BUFFER=y` in kernel config
48+
49+
50+
## Expected Output
51+
52+
```
53+
[INFO] 2026-03-23 12:39:05 - ================================================================================
54+
[INFO] 2026-03-23 12:39:05 - ============ Starting dmabuf Testcase =======================================
55+
[INFO] 2026-03-23 12:39:05 - ================================================================================
56+
[INFO] 2026-03-23 12:39:05 - === Kernel Configuration Validation ===
57+
[PASS] 2026-03-23 12:39:05 - Kernel config CONFIG_DMA_SHARED_BUFFER is enabled
58+
[PASS] 2026-03-23 12:39:05 - Kernel config CONFIG_DMABUF_HEAPS is enabled
59+
[PASS] 2026-03-23 12:39:06 - Kernel config CONFIG_DMABUF_HEAPS_SYSTEM is enabled
60+
[PASS] 2026-03-23 12:39:06 - Core DMA-BUF configs available
61+
[INFO] 2026-03-23 12:39:06 - Checking optional DMA-BUF configurations...
62+
[PASS] 2026-03-23 12:39:06 - Kernel config CONFIG_TEE_DMABUF_HEAPS is enabled
63+
[PASS] 2026-03-23 12:39:06 - CONFIG_TEE_DMABUF_HEAPS: enabled
64+
[PASS] 2026-03-23 12:39:06 - Kernel config CONFIG_HAS_DMA is enabled
65+
[PASS] 2026-03-23 12:39:06 - CONFIG_HAS_DMA: enabled
66+
[WARN] 2026-03-23 12:39:06 - Kernel config CONFIG_DMA_HEAP is missing or not enabled
67+
[WARN] 2026-03-23 12:39:06 - CONFIG_DMA_HEAP: not enabled (optional)
68+
[WARN] 2026-03-23 12:39:06 - Kernel config CONFIG_DMA_CMA is missing or not enabled
69+
[WARN] 2026-03-23 12:39:06 - CONFIG_DMA_CMA: not enabled (optional)
70+
[INFO] 2026-03-23 12:39:06 - === Device Tree Validation ===
71+
[INFO] 2026-03-23 12:39:06 - Found reserved-memory node
72+
[INFO] 2026-03-23 12:39:06 - Region: adsp-region@95c00000
73+
[INFO] 2026-03-23 12:39:06 - Region: adsp-rpc-remote-heap-region@94a00000
74+
[INFO] 2026-03-23 12:39:06 - Region: aop-cmd-db-region@90860000
75+
[INFO] 2026-03-23 12:39:06 - Region: aop-image-region@90800000
76+
[INFO] 2026-03-23 12:39:06 - Region: camera-region@95200000
77+
[INFO] 2026-03-23 12:39:06 - Region: cdsp-region@99980000
78+
[INFO] 2026-03-23 12:39:06 - Region: cvp-region@9b782000
79+
[INFO] 2026-03-23 12:39:06 - Region: gpdsp-region@97b00000
80+
[INFO] 2026-03-23 12:39:06 - Region: gpu-microcode-region@9b780000
81+
[INFO] 2026-03-23 12:39:06 - Region: lpass-machine-learning-region@93b00000
82+
[INFO] 2026-03-23 12:39:06 - Region: q6-adsp-dtb-region@97a00000
83+
[INFO] 2026-03-23 12:39:06 - Region: q6-cdsp-dtb-region@99900000
84+
[INFO] 2026-03-23 12:39:06 - Region: q6-gpdsp-dtb-region@97a80000
85+
[INFO] 2026-03-23 12:39:06 - Region: smem@90900000
86+
[INFO] 2026-03-23 12:39:06 - Region: video-region@9be82000
87+
[INFO] 2026-03-23 12:39:06 - /proc/device-tree/soc*/dma* /proc/device-tree/soc*/qcom,ion* /proc/device-tree/ion*
88+
[INFO] 2026-03-23 12:39:06 - /proc/device-tree/soc@0/dma-controller@1dc4000
89+
[PASS] 2026-03-23 12:39:06 - Device tree node exists: /proc/device-tree/soc@0/dma-controller@1dc4000
90+
[INFO] 2026-03-23 12:39:06 - /proc/device-tree/soc@0/dma-controller@900000
91+
[PASS] 2026-03-23 12:39:06 - Device tree node exists: /proc/device-tree/soc@0/dma-controller@900000
92+
[INFO] 2026-03-23 12:39:06 - /proc/device-tree/soc@0/dma-controller@a00000
93+
[PASS] 2026-03-23 12:39:06 - Device tree node exists: /proc/device-tree/soc@0/dma-controller@a00000
94+
[INFO] 2026-03-23 12:39:06 - /proc/device-tree/soc@0/dma-controller@b00000
95+
[PASS] 2026-03-23 12:39:06 - Device tree node exists: /proc/device-tree/soc@0/dma-controller@b00000
96+
[INFO] 2026-03-23 12:39:06 - /proc/device-tree/soc*/qcom,ion*
97+
[INFO] 2026-03-23 12:39:06 - /proc/device-tree/ion*
98+
[PASS] 2026-03-23 12:39:06 - At least one node was found.
99+
[PASS] 2026-03-23 12:39:06 - Device tree validation passed (found 1 relevant nodes)
100+
[INFO] 2026-03-23 12:39:06 - Found DMA heap device directory: /dev/dma_heap
101+
[PASS] 2026-03-23 12:39:06 - Available heap: system
102+
[PASS] 2026-03-23 12:39:06 - Total heaps found: 1
103+
[INFO] 2026-03-23 12:39:06 - DMA-BUF buffer information:
104+
[INFO] 2026-03-23 12:39:06 - Total DMA-BUF buffers: 1
105+
[PASS] 2026-03-23 12:39:06 - dmabuf : Test Passed
106+
[INFO] 2026-03-23 12:39:06 - -------------------Completed dmabuf Testcase----------------------------
107+
```
108+
109+
## License
110+
111+
Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
112+
SPDX-License-Identifier: BSD-3-Clause
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
metadata:
2+
format: Lava-Test Test Definition 1.0
3+
name: dmabuf
4+
description: "DMA-BUF kernel configuration and device tree validation"
5+
maintainer:
6+
- vnarapar@qti.qualcomm.com
7+
os:
8+
- openembedded
9+
scope:
10+
- functional
11+
devices:
12+
- rb3gen2
13+
- qcs6490
14+
- qcs8300
15+
- qcs9100
16+
- sa8775p
17+
18+
run:
19+
steps:
20+
- REPO_PATH=$PWD
21+
- cd "$REPO_PATH/Runner/suites/Kernel/Baseport/dmabuf" || true
22+
- ./run.sh || true
23+
- $REPO_PATH/Runner/utils/send-to-lava.sh dmabuf.res || true
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
#!/bin/sh
2+
3+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
7+
INIT_ENV=""
8+
SEARCH="$SCRIPT_DIR"
9+
while [ "$SEARCH" != "/" ]; do
10+
if [ -f "$SEARCH/init_env" ]; then
11+
INIT_ENV="$SEARCH/init_env"
12+
break
13+
fi
14+
SEARCH=$(dirname "$SEARCH")
15+
done
16+
17+
if [ -z "$INIT_ENV" ]; then
18+
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
19+
exit 1
20+
fi
21+
22+
# Only source if not already loaded (idempotent)
23+
if [ -z "${__INIT_ENV_LOADED:-}" ]; then
24+
# shellcheck disable=SC1090
25+
. "$INIT_ENV"
26+
fi
27+
28+
# shellcheck disable=SC1090,SC1091
29+
. "$TOOLS/functestlib.sh"
30+
31+
TESTNAME="dmabuf"
32+
test_path=$(find_test_case_by_name "$TESTNAME")
33+
cd "$test_path" || exit 1
34+
res_file="./$TESTNAME.res"
35+
36+
log_info "================================================================================"
37+
log_info "============ Starting $TESTNAME Testcase ======================================="
38+
log_info "================================================================================"
39+
40+
if ! check_dependencies "find grep basename"; then
41+
log_skip "$TESTNAME : Dependency check failed. Skipping."
42+
echo "$TESTNAME SKIP" > "$res_file"
43+
exit 0
44+
fi
45+
46+
pass=true
47+
48+
log_info "=== Kernel Configuration Validation ==="
49+
50+
if [ ! -f /proc/config.gz ]; then
51+
log_warn "/proc/config.gz not found — kernel config checks will be skipped"
52+
log_warn "Ensure CONFIG_IKCONFIG and CONFIG_IKCONFIG_PROC are enabled in the kernel"
53+
else
54+
CORE_CONFIGS="CONFIG_DMA_SHARED_BUFFER CONFIG_DMABUF_HEAPS CONFIG_DMABUF_HEAPS_SYSTEM"
55+
56+
if ! check_kernel_config "$CORE_CONFIGS"; then
57+
log_fail "Core DMA-BUF kernel config validation failed"
58+
pass=false
59+
else
60+
log_pass "Core DMA-BUF configs available"
61+
fi
62+
63+
OPTIONAL_CONFIGS="CONFIG_TEE_DMABUF_HEAPS CONFIG_HAS_DMA CONFIG_DMA_HEAP CONFIG_DMA_CMA"
64+
65+
log_info "Checking optional DMA-BUF configurations..."
66+
for cfg in $OPTIONAL_CONFIGS; do
67+
if check_optional_config "$cfg" 2>/dev/null; then
68+
log_pass " $cfg: enabled"
69+
else
70+
log_warn " $cfg: not enabled (optional)"
71+
fi
72+
done
73+
fi
74+
75+
log_info "=== Device Tree Validation ==="
76+
77+
found_nodes=0
78+
79+
if [ -d "/proc/device-tree/reserved-memory" ]; then
80+
log_info "Found reserved-memory node"
81+
82+
for region in /proc/device-tree/reserved-memory/*; do
83+
if [ -d "$region" ]; then
84+
region_name=$(basename "$region")
85+
log_info " Region: $region_name"
86+
fi
87+
done
88+
fi
89+
90+
if check_dt_nodes "/proc/device-tree/soc*/dma* /proc/device-tree/soc*/qcom,ion* /proc/device-tree/ion*"; then
91+
log_pass "At least one node was found."
92+
found_nodes=$((found_nodes + 1))
93+
else
94+
log_fail "None of the requested nodes were found."
95+
echo "$TESTNAME FAIL" > "$res_file"
96+
exit 1
97+
fi
98+
99+
if [ "$found_nodes" -gt 0 ]; then
100+
log_pass "Device tree validation passed (found $found_nodes relevant nodes)"
101+
else
102+
log_fail "No DMA-BUF specific device-tree nodes found"
103+
pass=false
104+
fi
105+
106+
# Check for DMA heap devices
107+
if [ -d "/dev/dma_heap" ]; then
108+
log_info "Found DMA heap device directory: /dev/dma_heap"
109+
110+
heap_count=0
111+
for heap in /dev/dma_heap/*; do
112+
if [ -e "$heap" ]; then
113+
heap_name=$(basename "$heap")
114+
log_pass " Available heap: $heap_name"
115+
heap_count=$((heap_count + 1))
116+
fi
117+
done
118+
log_pass "Total heaps found: $heap_count"
119+
else
120+
log_fail "DMA heap device directory not found"
121+
pass=false
122+
fi
123+
124+
if [ -f "/sys/kernel/debug/dma_buf/bufinfo" ]; then
125+
log_info "DMA-BUF buffer information:"
126+
127+
# Count total buffers
128+
total_bufs=$(grep -c "^Dma-buf" /sys/kernel/debug/dma_buf/bufinfo 2>/dev/null || echo 0)
129+
log_info " Total DMA-BUF buffers: $total_bufs"
130+
131+
# Calculate total size (if available)
132+
if grep -q "size:" /sys/kernel/debug/dma_buf/bufinfo 2>/dev/null; then
133+
total_size=$(awk '/size:/ {sum+=$2} END {print sum}' /sys/kernel/debug/dma_buf/bufinfo 2>/dev/null || echo 0)
134+
total_size_mb=$((total_size / 1024 / 1024))
135+
log_info " Total DMA-BUF memory: ${total_size_mb} MB"
136+
fi
137+
else
138+
log_warn "DMA-BUF bufinfo not available (debugfs may not be mounted)"
139+
fi
140+
141+
if $pass; then
142+
log_pass "$TESTNAME : Test Passed"
143+
echo "$TESTNAME PASS" > "$res_file"
144+
else
145+
log_fail "$TESTNAME : Test Failed"
146+
echo "$TESTNAME FAIL" > "$res_file"
147+
fi
148+
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
149+
exit 0

0 commit comments

Comments
 (0)