From cb0f312cf503b50bcd146d9d4ee5d8cb568723fd Mon Sep 17 00:00:00 2001 From: Srikanth Muppandam Date: Mon, 27 Apr 2026 21:30:13 +0530 Subject: [PATCH] fix: skip DSP_AudioPD when AudioPD allocator prerequisites are missing Add an AudioPD FastRPC allocator pre-check before validating adsprpcd. The test now verifies that the target exposes the non-secure ADSP FastRPC device (/dev/fastrpc-adsp), an active ADSP remoteproc, and ADSP RPC remote heap reserved-memory before running AudioPD validation. This prevents unsupported targets such as qcs615-ride from triggering repeated FastRPC kernel errors and marks them SKIP with a clear reason instead. Supported targets such as RB3GEN2 continue through the existing adsprpcd validation path. Also make adsprpcd wchan checks debug-only for non-poll states, since wchan can legitimately vary between poll/epoll/nanosleep depending on daemon timing. Signed-off-by: Srikanth Muppandam --- Runner/suites/Multimedia/DSP_AudioPD/run.sh | 210 +++++++++++++++++++- 1 file changed, 203 insertions(+), 7 deletions(-) diff --git a/Runner/suites/Multimedia/DSP_AudioPD/run.sh b/Runner/suites/Multimedia/DSP_AudioPD/run.sh index 0bd52766..6dc2d371 100755 --- a/Runner/suites/Multimedia/DSP_AudioPD/run.sh +++ b/Runner/suites/Multimedia/DSP_AudioPD/run.sh @@ -57,8 +57,8 @@ log_info "-------------------Starting $TESTNAME Testcase------------------------ log_info "=== Test Initialization ===" # Dependencies (single call; log list; SKIP if missing) -deps_list="adsprpcd tr awk grep sleep" -log_info "Checking dependencies: ""$deps_list""" +deps_list="adsprpcd tr awk grep sleep find cat" +log_info "Checking dependencies: $deps_list" if ! check_dependencies "$deps_list"; then log_skip "$TESTNAME SKIP - missing one or more dependencies: $deps_list" echo "$TESTNAME SKIP" >"$res_file" @@ -83,15 +83,16 @@ check_adsprpcd_wait_state() { if [ -r "/proc/$pid/wchan" ]; then wchan=$(tr -d '\r\n' <"/proc/$pid/wchan" 2>/dev/null) - # Accept suffixes like ".constprop.0" + # Keep wchan for debug. It is timing-sensitive and may move between + # poll/epoll/nanosleep while the daemon is alive and healthy. case "$wchan" in do_sys_poll*|ep_poll*|do_epoll_wait*|poll_schedule_timeout*) log_info "adsprpcd PID $pid wchan='$wchan' (accepted)" return 0 ;; *) - log_info "adsprpcd PID $pid wchan='$wchan' (not in expected set)" - return 1 + log_info "adsprpcd PID $pid wchan='$wchan' (debug only; not used as failure gate)" + return 0 ;; esac fi @@ -102,8 +103,9 @@ check_adsprpcd_wait_state() { log_info "adsprpcd PID $pid stack contains expected wait symbol" return 0 fi - log_info "adsprpcd PID $pid stack does not contain expected wait symbols" - return 1 + + log_info "adsprpcd PID $pid stack does not contain expected wait symbols (debug only)" + return 0 fi # Neither interface is available -> SKIP @@ -112,6 +114,200 @@ check_adsprpcd_wait_state() { return 2 } +# Check whether non-secure ADSP FastRPC and ADSP RPC remote heap are present +# before running AudioPD validation. Return 0=supported, 2=unsupported/SKIP. +# Check whether ADSP remoteproc, FastRPC device node, and allocator backing are +# available before AudioPD validation. Return 0=supported, 2=unsupported/SKIP. +check_audiopd_allocator_available() { + dt_root="" + dt_nodes_file="" + heap_path="" + logged_heaps="" + node="" + compat_text="" + rproc="" + remoteproc_name="" + remoteproc_state="" + memory_region_ok=0 + vmids_ok=0 + adsp_running=0 + dev_found=0 + heap_found=0 + fastrpc_dt_found=0 + fastrpc_allocator_found=0 + + log_info "=== AudioPD FastRPC allocator pre-check ===" + + # Check remoteproc before FastRPC device nodes. FastRPC device nodes are + # expected only after the corresponding remoteproc is up. + for rproc in /sys/class/remoteproc/remoteproc*; do + [ -e "$rproc" ] || continue + + remoteproc_name="$(cat "$rproc/name" 2>/dev/null || true)" + remoteproc_state="$(cat "$rproc/state" 2>/dev/null || true)" + + if [ "$remoteproc_name" = "adsp" ]; then + log_info "[audiopd] ADSP remoteproc: $rproc state=$remoteproc_state" + + if [ "$remoteproc_state" = "running" ]; then + adsp_running=1 + fi + fi + done + + if [ "$adsp_running" -eq 0 ]; then + log_skip "[audiopd] ADSP remoteproc is not running." + return 2 + fi + + # Device open logic checks secure first, then falls back to non-secure. + # Either device node is sufficient for this pre-check. + if [ -e /dev/fastrpc-adsp-secure ]; then + dev_found=1 + log_info "[audiopd] Secure ADSP FastRPC device present: /dev/fastrpc-adsp-secure" + elif [ -e /dev/fastrpc-adsp ]; then + dev_found=1 + log_info "[audiopd] Non-secure ADSP FastRPC device present: /dev/fastrpc-adsp" + else + log_warn "[audiopd] ADSP FastRPC device missing: /dev/fastrpc-adsp-secure and /dev/fastrpc-adsp" + fi + + for dt_root in /proc/device-tree /sys/firmware/devicetree/base; do + [ -d "$dt_root" ] || continue + + dt_nodes_file="${TMPDIR:-/tmp}/${TESTNAME}_fastrpc_dt.$$" + : >"$dt_nodes_file" 2>/dev/null || continue + find "$dt_root" -type d 2>/dev/null >"$dt_nodes_file" + + while IFS= read -r node; do + [ -n "$node" ] || continue + + compat_text="" + if [ -f "$node/compatible" ]; then + compat_text="$(tr '\000' ' ' <"$node/compatible" 2>/dev/null)" + fi + + # memory-region and qcom,vmids belong to the parent qcom,fastrpc + # node. Do not validate compute-cb child nodes for these properties. + case "$compat_text" in + *qcom,fastrpc-compute-cb*) + continue + ;; + esac + + case "$compat_text" in + *qcom,fastrpc*) + fastrpc_dt_found=1 + log_info "[audiopd] FastRPC parent DT candidate: $node" + + memory_region_ok=0 + vmids_ok=0 + + if [ -s "$node/memory-region" ]; then + memory_region_ok=1 + log_info "[audiopd] FastRPC memory-region present: $node/memory-region" + else + log_warn "[audiopd] FastRPC parent DT node missing memory-region: $node" + fi + + if [ -s "$node/qcom,vmids" ]; then + vmids_ok=1 + log_info "[audiopd] FastRPC qcom,vmids present: $node/qcom,vmids" + else + log_warn "[audiopd] FastRPC parent DT node missing qcom,vmids: $node" + fi + + if [ "$memory_region_ok" -eq 1 ]; then + if [ "$vmids_ok" -eq 1 ]; then + fastrpc_allocator_found=1 + log_info "[audiopd] FastRPC allocator DT properties are valid: $node" + break + fi + fi + ;; + esac + done <"$dt_nodes_file" + + rm -f "$dt_nodes_file" 2>/dev/null || true + + if [ "$fastrpc_allocator_found" -eq 1 ]; then + break + fi + done + + # Keep reserved-memory scan for debug/fallback visibility. However, if a + # qcom,fastrpc parent node is visible, the parent node must carry + # memory-region + qcom,vmids to pass. + for dt_root in /proc/device-tree /sys/firmware/devicetree/base; do + [ -d "$dt_root" ] || continue + + for heap_path in "$dt_root"/reserved-memory/*adsp*rpc*remote*heap* \ + "$dt_root"/reserved-memory/*adsp-rpc-remote-heap*; do + [ -e "$heap_path" ] || continue + + case " $logged_heaps " in + *" $heap_path "*) + continue + ;; + esac + logged_heaps="$logged_heaps $heap_path" + + heap_found=1 + log_info "[audiopd] ADSP RPC remote heap reserved-memory node: $heap_path" + + if [ -s "$heap_path/reg" ]; then + log_info "[audiopd] ADSP RPC remote heap reg property present: $heap_path/reg" + else + log_warn "[audiopd] ADSP RPC remote heap reg property missing or empty: $heap_path/reg" + fi + done + done + + if [ "$dev_found" -eq 1 ]; then + if [ "$fastrpc_allocator_found" -eq 1 ]; then + log_pass "[audiopd] AudioPD FastRPC allocator prerequisites are available." + return 0 + fi + fi + + # Some live DT layouts may not expose the qcom,fastrpc parent node clearly + # under /proc/device-tree. In that case only, allow reserved heap evidence + # to avoid false SKIP on targets where the parent node is not discoverable. + if [ "$dev_found" -eq 1 ]; then + if [ "$fastrpc_dt_found" -eq 0 ]; then + if [ "$heap_found" -eq 1 ]; then + log_warn "[audiopd] FastRPC parent DT node was not discoverable; falling back to ADSP RPC remote heap evidence." + log_pass "[audiopd] AudioPD FastRPC allocator prerequisites are available." + return 0 + fi + fi + fi + + if [ "$dev_found" -eq 0 ]; then + log_skip "[audiopd] No secure/non-secure ADSP FastRPC device is available." + fi + + if [ "$fastrpc_dt_found" -eq 1 ]; then + if [ "$fastrpc_allocator_found" -eq 0 ]; then + log_skip "[audiopd] FastRPC parent DT node is missing memory-region and/or qcom,vmids." + fi + elif [ "$heap_found" -eq 0 ]; then + log_skip "[audiopd] ADSP RPC remote heap reserved-memory is not available." + fi + + return 2 +} + +check_audiopd_allocator_available +allocator_rc=$? + +if [ "$allocator_rc" -eq 2 ]; then + log_skip "$TESTNAME SKIP - AudioPD FastRPC allocator prerequisites are not available on this target" + echo "$TESTNAME SKIP" >"$res_file" + log_info "-------------------Completed $TESTNAME Testcase----------------------------" + exit 0 +fi + if is_process_running "adsprpcd"; then # is_process_running already prints instances/cmdline (for CI debug) PIDS=$(get_one_pid_by_name "adsprpcd" all 2>/dev/null || true)