* [PATCH] ALSA: usb-audio: Complete cleanup after system-resume errors
@ 2026-08-24 22:57 Will Porter
2026-08-25 8:02 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Will Porter @ 2026-08-24 22:57 UTC (permalink / raw)
To: Takashi Iwai, linux-sound; +Cc: Jaroslav Kysela, Oliver Neukum, linux-kernel
A failed system resume can leave the card unusable until reboot.
usb_audio_resume() jumps to err_out when snd_usb_pcm_resume() or
snd_usb_mixer_resume() fails. The error path skips the out: block, which
restores D0 and decrements chip->num_suspended_intf.
The card stays in SNDRV_CTL_POWER_D3hot, so later control access blocks in
snd_power_ref_and_wait(). USB core logs an interface resume callback error.
It does not retry that callback, so a later callback cannot complete the
skipped cleanup.
usb_audio_suspend() increments num_suspended_intf before returning success.
A system-resume callback must consume the system-suspend count even if a
component resume fails. Otherwise, the stranded count skews later suspend
and resume cycles.
Do not apply this cleanup to runtime-resume errors. Runtime PM can retry
-EAGAIN or -EBUSY without another suspend callback. The count must continue
to describe that suspended interface. Other runtime-resume errors latch
runtime_error in the PM core and do not cause an immediate callback retry.
Both parts of the system-resume error path are longstanding. Commit
88a8516a2128a ("ALSA: usbaudio: implement USB autosuspend") introduced
err_out past the D0 restore. Commit 862b2509d157c ("ALSA: usb-audio: Fix
inconsistent card PM state after resume") later moved
num_suspended_intf-- into the out: block. The error path now skips both
operations.
No third-party code is needed to reach the error path.
snd_usb_mixer_resume() ends in snd_usb_mixer_activate(), which returns the
result of usb_submit_urb() for devices that have a mixer status URB. Its
mixer->private_resume hook can also fail through scarlett2_init_notify().
snd_usb_pcm_resume() issues a SET_CUR request to a UAC3 power domain. It
can return -EPIPE or -EIO when the device stalls the request.
Route a component error through out: only when system_suspend is nonzero.
Continue to return runtime-resume errors through err_out. Later component
resume stages remain skipped. The original error still reaches USB core.
A later transfer can fail if the device did not recover.
I reproduced the system-resume failure on an Audient iD14 MkI with an
out-of-tree diagnostic mixer resume hook. An injected -EIO on the unpatched
core left control readers in uninterruptible sleep in
snd_power_ref_and_wait() until a reboot. With this patch, the same failure
restored control access. A second system suspend and resume also succeeded
after I disabled fault injection.
Assisted-by: Claude:claude-opus-5
Assisted-by: Antigravity:gemini-3.1-pro-high
Assisted-by: Codex:gpt-5.6-sol
Fixes: 88a8516a2128a ("ALSA: usbaudio: implement USB autosuspend")
Fixes: 862b2509d157c ("ALSA: usb-audio: Fix inconsistent card PM state after resume")
Cc: <stable@vger.kernel.org>
Signed-off-by: Will Porter <mrwillporter@gmail.com>
---
sound/usb/card.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 24112e491779..9307da95efbe 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -1282,8 +1282,11 @@ static int usb_audio_resume(struct usb_interface *intf)
list_for_each_entry(as, &chip->pcm_list, list) {
err = snd_usb_pcm_resume(as);
- if (err < 0)
- goto err_out;
+ if (err < 0) {
+ if (!chip->system_suspend)
+ goto err_out;
+ goto out;
+ }
}
/*
@@ -1292,8 +1295,11 @@ static int usb_audio_resume(struct usb_interface *intf)
*/
list_for_each_entry(mixer, &chip->mixer_list, list) {
err = snd_usb_mixer_resume(mixer);
- if (err < 0)
- goto err_out;
+ if (err < 0) {
+ if (!chip->system_suspend)
+ goto err_out;
+ goto out;
+ }
}
list_for_each(p, &chip->midi_list) {
base-commit: e72d5659a2606056a0c34af212b46a3275a55bbf
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ALSA: usb-audio: Complete cleanup after system-resume errors
2026-08-24 22:57 [PATCH] ALSA: usb-audio: Complete cleanup after system-resume errors Will Porter
@ 2026-08-25 8:02 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-08-25 8:02 UTC (permalink / raw)
To: Will Porter
Cc: Takashi Iwai, linux-sound, Jaroslav Kysela, Oliver Neukum,
linux-kernel
On Tue, 25 Aug 2026 00:57:57 +0200,
Will Porter wrote:
>
> A failed system resume can leave the card unusable until reboot.
> usb_audio_resume() jumps to err_out when snd_usb_pcm_resume() or
> snd_usb_mixer_resume() fails. The error path skips the out: block, which
> restores D0 and decrements chip->num_suspended_intf.
>
> The card stays in SNDRV_CTL_POWER_D3hot, so later control access blocks in
> snd_power_ref_and_wait(). USB core logs an interface resume callback error.
> It does not retry that callback, so a later callback cannot complete the
> skipped cleanup.
>
> usb_audio_suspend() increments num_suspended_intf before returning success.
> A system-resume callback must consume the system-suspend count even if a
> component resume fails. Otherwise, the stranded count skews later suspend
> and resume cycles.
>
> Do not apply this cleanup to runtime-resume errors. Runtime PM can retry
> -EAGAIN or -EBUSY without another suspend callback. The count must continue
> to describe that suspended interface. Other runtime-resume errors latch
> runtime_error in the PM core and do not cause an immediate callback retry.
>
> Both parts of the system-resume error path are longstanding. Commit
> 88a8516a2128a ("ALSA: usbaudio: implement USB autosuspend") introduced
> err_out past the D0 restore. Commit 862b2509d157c ("ALSA: usb-audio: Fix
> inconsistent card PM state after resume") later moved
> num_suspended_intf-- into the out: block. The error path now skips both
> operations.
>
> No third-party code is needed to reach the error path.
> snd_usb_mixer_resume() ends in snd_usb_mixer_activate(), which returns the
> result of usb_submit_urb() for devices that have a mixer status URB. Its
> mixer->private_resume hook can also fail through scarlett2_init_notify().
> snd_usb_pcm_resume() issues a SET_CUR request to a UAC3 power domain. It
> can return -EPIPE or -EIO when the device stalls the request.
>
> Route a component error through out: only when system_suspend is nonzero.
> Continue to return runtime-resume errors through err_out. Later component
> resume stages remain skipped. The original error still reaches USB core.
> A later transfer can fail if the device did not recover.
>
> I reproduced the system-resume failure on an Audient iD14 MkI with an
> out-of-tree diagnostic mixer resume hook. An injected -EIO on the unpatched
> core left control readers in uninterruptible sleep in
> snd_power_ref_and_wait() until a reboot. With this patch, the same failure
> restored control access. A second system suspend and resume also succeeded
> after I disabled fault injection.
>
> Assisted-by: Claude:claude-opus-5
> Assisted-by: Antigravity:gemini-3.1-pro-high
> Assisted-by: Codex:gpt-5.6-sol
> Fixes: 88a8516a2128a ("ALSA: usbaudio: implement USB autosuspend")
> Fixes: 862b2509d157c ("ALSA: usb-audio: Fix inconsistent card PM state after resume")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Will Porter <mrwillporter@gmail.com>
Applied now. Thanks.
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-25 8:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-24 22:57 [PATCH] ALSA: usb-audio: Complete cleanup after system-resume errors Will Porter
2026-08-25 8:02 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox