Skip to content

check-sof-logger.sh: use a short stream in ping_pcm_devices() - #1371

Merged
harajend merged 1 commit into
thesofproject:mainfrom
kv2019i:202611-soflogger-fix
Dec 1, 2026
Merged

harajend merged 1 commit into
thesofproject:mainfrom
kv2019i:202611-soflogger-fix

Conversation

@kv2019i

@kv2019i kv2019i commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

SOF SOF Linux driver introduced support for on-demand booting of DSP in upstream Linux commit c3e154981174 ("ASoC: SOF: Add support for on-demand DSP boot"). This broke the check-sof-logger.sh function to ping PCM devices with dd. As a result, loggers could end up attached to a suspended DSP and the log output was empty.

Run a short (1s) silent stream with aplay, or arecord as a fallback, on the PCMs of the SOF cards until one succeeds. The PCMs are found from /proc/asound and plughw is used to let ALSA pick working parameters, so this does not depend on the hardware or the topology. Failing PCMs are skipped, and only a warning is printed if none could be opened.

Also wake up the DSP before starting mtrace-reader.py, in addition to the existing call that generates DSP activity while the loggers run. Removed in V2.

@kv2019i
kv2019i requested review from a team, lgirdwood and marc-hb as code owners November 26, 2026 16:03
@kv2019i
kv2019i requested review from ujfalusi and a balanced review from Copilot November 26, 2026 16:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

PCM fallback probing can exceed the logger capture window, causing a later working PCM’s DSP activity to be missed; probing must complete before capture starts or reader lifetime must cover the full sequence.

1 open issue
What changed in this PR

This PR updates the SOF logger test to wake the DSP with a real audio stream, addressing empty logs when drivers use on-demand DSP boot.

Changes:

  • Replace raw PCM-node reads with one-second playback or capture streams using plughw.
  • Try SOF PCM devices until one succeeds, warning if none work.
  • Wake the DSP before starting mtrace-reader.py.
File Description
test-case/​check-sof-logger.sh Adds stream-based DSP wake-up and a pre-mtrace wake-up call.

Review effort: Balanced

Comment thread test-case/check-sof-logger.sh Resolved

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but giving a little more time for the PCM is probably needed.

Comment thread test-case/check-sof-logger.sh Resolved
Comment thread test-case/check-sof-logger.sh Resolved
Comment thread test-case/check-sof-logger.sh Resolved

@marc-hb marc-hb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a result, loggers could end up attached to a suspended DSP and the log output was empty.

... and tests were passing? More "green failures" :-(

I remember working hard to detect empty logs, is that not working anymore? This would be an different issue than this PR - but a (nth repeat of) a serious one.

@kv2019i
kv2019i force-pushed the 202611-soflogger-fix branch from 37b67f9 to 018546b Compare November 30, 2026 10:56
@kv2019i

kv2019i commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

V2 pushed:

  • addressing code review comments so far

SOF Linux driver introduced support for on-demand booting of DSP in
upstream Linux commit c3e154981174 ("ASoC: SOF: Add support for
on-demand DSP boot"). This broke the check-sof-logger.sh function to
ping PCM devices with dd. As a result, loggers could end
up attached to a suspended DSP and the log output was empty.

Run a short (1s) silent stream with aplay, or arecord as a fallback, on
the PCMs of the SOF cards until one succeeds. The PCMs are found from
/proc/asound and plughw is used to let ALSA pick working parameters, so
this does not depend on the hardware or the topology. Failing PCMs are
skipped with the tool error message logged, and only a warning is
printed if none could be opened.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
@kv2019i
kv2019i force-pushed the 202611-soflogger-fix branch from 018546b to 5492eb2 Compare November 30, 2026 11:00
@kv2019i

kv2019i commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

V3 pushed:

  • remove spurious extra line in the patch

grep -q '^sof' "$cardpath/id" || continue
cardnum=${cardpath##*card}

for pcm in "$cardpath"/pcm[0-9]*[pc]; do

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to get out the fw boot log why do you need to ping all of the PCMs of the card?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ujfalusi ? the test doesn't do this, see L135

# to what the PCM supports. Failing PCMs, e.g. HDMI without a
# monitor, are expected.
local cardpath cardnum pcm dev dir tool err
local params=(-q -t raw -f S16_LE -r 48000 -c 2 -d 1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-fS16_LE -r48000 -c2 == -fdat

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to be explicit here, no need to save characters typing here

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The DSP wake-up call is still missing before mtrace readers start, so readers can attach to a suspended DSP.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread test-case/check-sof-logger.sh Resolved

@marc-hb marc-hb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nit below.

for pcm in "$cardpath"/pcm[0-9]*[pc]; do
test -e "$pcm" || continue
dev=${pcm##*/pcm} # e.g. 12p
dir=${dev: -1}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dir=${dev: -1}
dir=${dev: -1} # last character thanks to substring expansion

This syntax is valid and useful but very cryptic for non-shell experts. What is especially cryptic: it's totally different from ${dev:-1}!

An audio expert can guess the intent and "reverse-engineer" it but that's not ideal.

@kv2019i
kv2019i requested a review from harajend November 30, 2026 15:28

@harajend harajend left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI run for this PR used sof-test commit 5492eb2 and failed in check-sof-logger on ba-wclu-rvp-08 (job log). The test log shows mtrace-reader.py exiting immediately with FileNotFoundError for /sys/kernel/debug/sof/mtrace/core0; logger.etrace.txt is empty. The other test cases in the suite passed.

run_loggers() starts the mtrace reader before calling ping_pcm_devices(). If the mtrace node is unavailable until the PCM activity wakes the on-demand DSP, the reader may exit before that wakeup occurs. Could we ensure the DSP is awake and the mtrace node exists before starting the reader, or retry the reader after the PCM wakeup? The log does report firmware boot complete, so it would also help to confirm whether this DUT/kernel configuration is expected to expose that debugfs node. Please rerun check-sof-logger on the affected setup after addressing or explaining this failure.

@kv2019i

kv2019i commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@harajend wrote:

The CI run for this PR used sof-test commit 5492eb2 and failed in check-sof-logger on ba-wclu-rvp-08 (job log). The test log shows mtrace-reader.py exiting immediately with FileNotFoundError for /sys/kernel/debug/sof/mtrace/core0; logger.etrace.txt is empty. The other test cases in the suite passed.

I checked the failing case and device and this is caused by invalid test device configuration. Check of "cat /sys/module/snd_sof/parameters/sof_debug" shows FW logs are not enabled so mtrace is not enabled.

So not related to this PR.

@harajend harajend left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harajend
harajend merged commit 8fed5f7 into thesofproject:main Dec 1, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants