Skip to content

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

Open
kv2019i wants to merge 1 commit into
thesofproject:mainfrom
kv2019i:202611-soflogger-fix
Open

kv2019i wants to merge 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.

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.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
@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 on lines +130 to +132
timeout -k 2 5 aplay "${params[@]}" \
-D "plughw:$cardnum,$dev" /dev/zero \
>/dev/null 2>&1 && return 0

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.

This is not valid. The test sequence synchronously waits until card is probe and registered. Then this ping is called to force the DSP to boot. This function will exit immediately when a PCM is succesfully opened. Then sof_loggers will immediately start mtrace-reader (or other tool). This leaves for 2secs of time to start capturing logs. A more robust change would be require to run logger in background and then force DSP boot with aplay/arecord. That is better done in separate PR if needed. The current PR fixes a clear bug introduced with recent LInux, so I think this is good to go. FYI @lgirdwood

@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.


for cardpath in /proc/asound/card[0-9]*; do
# SOF card ids start with "sof", see sof_alsa_card_found()
case $(cat "$cardpath/id" 2>/dev/null) in

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.

Maybe

grep -q '^sof' "$cardpath/id" 2>/dev/null || continue

BTW why discard stderr, what error is expected? Discarding stderr is evil, should be justified every time :-)

else
timeout -k 2 5 arecord "${params[@]}" \
-D "plughw:$cardnum,$dev" /dev/null \
>/dev/null 2>&1 && return 0

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.

Same: why discard stderr, what sort of spurious error message is expected?

local mtracetool="$MTRACE"

# Make sure the DSP is active before the reader attaches
ping_pcm_devices

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.

I feel like this is significantly different from the rest to deserve a separate commit IMHO

@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.

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.

4 participants