Repository navigation
check-sof-logger.sh: use a short stream in ping_pcm_devices() #1371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,13 +102,44 @@ wait_for_sof_alsa_card() | |
|
|
||
| ping_pcm_devices() | ||
| { | ||
| # Open all ALSA PCM nodes and read one byte out of them. | ||
| # The operation will fail, but this is enough to cause | ||
| # the device to be powered up if it was in runtime-suspended (D3) | ||
| # state. | ||
| for pcm in /dev/snd/pcm* ; do | ||
| dd if="$pcm" of=/dev/null bs=1 count=1 >/dev/null 2>/dev/null || true | ||
| # Run a short real stream on one SOF PCM to power up the DSP (and | ||
| # boot it if needed), including when it was in runtime-suspended | ||
| # (D3) state. Merely opening the PCM device node is not enough with | ||
| # recent SOF drivers. Topology independent: try the PCMs of all SOF | ||
| # cards until one works. plughw converts format, rate and channels | ||
| # to what the PCM supports. Failing PCMs, e.g. HDMI without a | ||
| # monitor, are expected. | ||
| local cardpath cardnum pcm dev dir | ||
| local params=(-q -t raw -f S16_LE -r 48000 -c 2 -d 1) | ||
|
|
||
| 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 | ||
| sof*) ;; | ||
| *) continue ;; | ||
| esac | ||
| cardnum=${cardpath##*card} | ||
|
|
||
| for pcm in "$cardpath"/pcm[0-9]*[pc]; do | ||
| test -e "$pcm" || continue | ||
| dev=${pcm##*/pcm} # e.g. 12p | ||
| dir=${dev: -1} | ||
| dev=${dev%?} | ||
|
|
||
| if [ "$dir" = p ]; then | ||
| timeout -k 2 5 aplay "${params[@]}" \ | ||
| -D "plughw:$cardnum,$dev" /dev/zero \ | ||
| >/dev/null 2>&1 && return 0 | ||
|
Comment on lines
+130
to
+132
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| else | ||
| timeout -k 2 5 arecord "${params[@]}" \ | ||
| -D "plughw:$cardnum,$dev" /dev/null \ | ||
| >/dev/null 2>&1 && return 0 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same: why discard stderr, what sort of spurious error message is expected? |
||
| fi | ||
| done | ||
| done | ||
|
|
||
| dlogw "No SOF PCM could be opened, DSP may not be active" | ||
| return 0 | ||
| } | ||
|
|
||
| run_loggers() | ||
|
|
@@ -147,6 +178,10 @@ run_loggers() | |
| } | ||
| fi | ||
| local mtracetool="$MTRACE" | ||
|
|
||
| # Make sure the DSP is active before the reader attaches | ||
| ping_pcm_devices | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
|
||
| dlogi "Trying to get Zephyr logs from mtrace with background $mtracetool ..." | ||
| dlogc \ | ||
| "sudo $mtracetool > $etrace_file 2> $etrace_stderr_file" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
BTW why discard stderr, what error is expected? Discarding stderr is evil, should be justified every time :-)