From eb8e68f2e29462d167a56bf1644be62c276f443a Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Thu, 17 Jun 2021 22:46:39 -0700 Subject: [PATCH 1/2] check-sof-logger: reload drivers first As we look for the FW ABI banner we must start from a clean state Signed-off-by: Marc Herbert --- test-case/check-sof-logger.sh | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/test-case/check-sof-logger.sh b/test-case/check-sof-logger.sh index 473a5e2f..9c1412e5 100755 --- a/test-case/check-sof-logger.sh +++ b/test-case/check-sof-logger.sh @@ -21,13 +21,12 @@ set -e +TOPDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) # shellcheck source=case-lib/lib.sh -source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh +source "${TOPDIR}"/case-lib/lib.sh func_opt_parse_option "$@" -setup_kernel_check_point - # check sof-logger location type -a sof-logger || die "sof-logger Not Installed!" @@ -121,10 +120,31 @@ print_logs_exit() exit "$exit_code" } +reload_drivers() +{ + "${TOPDIR}"/tools/kmod/sof_remove.sh + + setup_kernel_check_point + + "${TOPDIR}"/tools/kmod/sof_insert.sh + + # The DSP may unfortunately need multiple retries to boot, see + # https://github.com/thesofproject/sof/issues/3395 + dlogi "Waiting a few seconds for the DSP to fully boot and then suspend" + for i in $(seq 1 5); do + if sudo test -e /sys/kernel/debug/sof/etrace; then break; fi + sleep 1 + done + # Now give enough time to go to D3 suspend + sleep 4 +} + main() { + reload_drivers + run_loggers || - print_logs_exit 1 "Reading etrace failed, run_loggers returned $?" + print_logs_exit 1 "Reading (e)trace failed, run_loggers returned $?" local f From 378a0cb18e1279feeed9d54bc6da251eaeff1e85 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Fri, 18 Jun 2021 00:56:00 -0700 Subject: [PATCH 2/2] check-sof-logger: nudge the DMA trace when it's empty See bug https://github.com/thesofproject/sof/issues/4333 Signed-off-by: Marc Herbert --- test-case/check-sof-logger.sh | 38 +++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/test-case/check-sof-logger.sh b/test-case/check-sof-logger.sh index 9c1412e5..aa3d2b88 100755 --- a/test-case/check-sof-logger.sh +++ b/test-case/check-sof-logger.sh @@ -97,6 +97,12 @@ run_loggers() return $etrace_exit } + +dma_nudge() +{ + sudo timeout -k 5 2 "$loggerBin" -l "${ldcFile}" -F info=pga -t +} + # Dumps all logs before exiting print_logs_exit() { @@ -110,11 +116,12 @@ print_logs_exit() local bname for ftype in data etrace error etrace_stderr; do - printf '\n\n' + printf '\n' bname="logger.$ftype.txt" dlogi "Log file $bname BEG::" cat "$LOG_ROOT/$bname" || true # we already checked these dlogi "::END log file $bname" + printf '\n' done test -z "$errmsg" || dloge "$errmsg" exit "$exit_code" @@ -158,8 +165,12 @@ main() logger."$f".txt > "$stderr_file" done + # Simulates a stuck DMA to test the code below + # sed -i -e '2,$ d' "$LOG_ROOT/logger.data.txt" + # Search for the log header, should be something like this: # TIMESTAMP DELTA C# COMPONENT LOCATION CONTENT + # then for the 'FW ABI' banner for f in etrace data; do local tracef="$LOG_ROOT/logger.$f.txt" test -e "$tracef" || die "$tracef" not found @@ -168,14 +179,29 @@ main() print_logs_exit 1 "Log header not found in ${data_file}" # See initial message SOF PR #3281 / SOF commit 67a0a69 - grep -q 'dma-trace.c.*FW ABI.*tag.*hash' "$tracef" || + grep -q 'dma-trace.c.*FW ABI.*tag.*hash' "$tracef" || { + + # Workaround for DMA trace bug + # https://github.com/thesofproject/sof/issues/4333 + if [ "$f" = data ]; then + dloge "Empty or stuck DMA trace? Let's try to nudge it." + dloge ' vv Workaround for SOF issue 4333 vv' + local second_chance="$LOG_ROOT/logger.dma_trace_bug_4333.txt" + dma_nudge | tee "$second_chance" + printf '\n' + dloge ' ^^ End of workaround nudge for 4333 ^^ ' + printf '\n' + + if head "$second_chance" | + grep -q 'dma-trace.c.*FW ABI.*tag.*hash'; then + continue # and don't report failure 4333 + fi + fi + print_logs_exit 1 "Initial FW ABI banner not found in ${data_file}" + } done - # This is a bit redundant with the previous test but does not hurt. - tail -n +2 "${data_file}" | grep -q '[^[:blank:]]' || - print_logs_exit 1 "Nothing but the first line in DMA trace ${data_file}" - # Show all outputs even when everything went OK print_logs_exit 0 }