Skip to content

tools/kmod: tolerate USB-audio-busy for shared ALSA core modules - #1367

Open
harajend wants to merge 1 commit into
mainfrom
usb-audio-busy-tolerance-shared-alsa-core
Open

harajend wants to merge 1 commit into
mainfrom
usb-audio-busy-tolerance-shared-alsa-core

Conversation

@harajend

Copy link
Copy Markdown
Contributor

Problem

sof_remove.sh runs under 'bash -e'. If a USB audio device (e.g. a loopback/offload device used by CI) is briefly busy when snd_usb_audio/snd_usbmidi_lib are removed, the script aborts right there.

Root cause

Because the script aborts mid-way under set -e, snd_sof can already be removed by the time the abort happens, but reload_drivers() never gets to reload it. That breaks the DSP for every subsequent test case in the run, not just the current one.

Fix

Track whether USB audio is still loaded after the removal attempt (usb_audio_still_loaded) and tolerate the same failure on the shared ALSA-core modules it can keep busy: snd_hwdep, snd_rawmidi, snd_seq_device, snd_timer, snd, soundcore. This mirrors the existing tolerance already in place for snd_sof_intel_hda_common's SDW-BRA busy case a few lines above. Unrelated failures on these modules still abort normally, since the tolerance is conditional on USB audio itself having failed to unload.

Verification

Internally we carried an equivalent fix on our downstream fork and confirmed it resolves a cascade of ~38 failed test cases caused by a USB audio loopback device (WCL_HDA_AIOC) keeping shared modules busy during driver reload on an RVP DUT. This PR ports the same fix onto the current upstream module ordering (which already differs from our fork, e.g. the snd_usb_offload/soc_usb reordering and the snd_ump handling).

sof_remove.sh runs under 'set -e'. If a USB audio device (e.g. a
loopback/offload device under test) is briefly busy when
snd_usb_audio/snd_usbmidi_lib are removed, the script aborts right
there. That leaves snd_sof removed but never reloaded, breaking the
DSP for the rest of the test run, since reload_drivers() never
completes.

Track whether USB audio is still loaded after the removal attempt and
tolerate the same failure on the shared ALSA-core modules it can keep
busy (snd_hwdep, snd_rawmidi, snd_seq_device, snd_timer, snd,
soundcore), the same way snd_sof_intel_hda_common's SDW-BRA busy case
is already tolerated above. Unrelated failures on these modules still
abort, since the tolerance only applies when USB audio itself failed
to unload.
@harajend
harajend requested review from a team, lgirdwood, marc-hb and plbossart as code owners November 23, 2026 01:57
@harajend harajend self-assigned this Nov 23, 2026
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.

1 participant