* [PATCH] ALSA: usb-audio: midi2: Restart output URBs on resume
@ 2026-05-04 14:08 Cássio Gabriel
2026-05-04 15:55 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Cássio Gabriel @ 2026-05-04 14:08 UTC (permalink / raw)
To: Takashi Iwai, Jaroslav Kysela
Cc: linux-sound, linux-kernel, stable, Cássio Gabriel
USB MIDI 2.0 suspend saves the endpoint running state, clears it and
kills all endpoint URBs. Resume restores the running state, but only
restarts input endpoints.
For a running output endpoint, this leaves the endpoint marked running
with an empty URB queue. Output transfer progress depends on either the
rawmidi trigger path starting the queue or an output completion refilling
it. After suspend there is no completion left, and output data that
remains queued in the raw UMP or legacy rawmidi buffer can stay stalled
until userspace happens to trigger the stream again.
Restore the saved state with atomic accessors, keep input endpoints
restarted as before, and restart output endpoints that were running before
suspend. Clear the saved suspend state after restoring it.
Fixes: ff49d1df79ae ("ALSA: usb-audio: USB MIDI 2.0 UMP support")
Cc: stable@vger.kernel.org
Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
---
sound/usb/midi2.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/sound/usb/midi2.c b/sound/usb/midi2.c
index 3546ba926cb3..2785600d2312 100644
--- a/sound/usb/midi2.c
+++ b/sound/usb/midi2.c
@@ -227,7 +227,7 @@ static void kill_midi_urbs(struct snd_usb_midi2_endpoint *ep, bool suspending)
if (!ep)
return;
if (suspending)
- ep->suspended = ep->running;
+ atomic_set(&ep->suspended, atomic_read(&ep->running));
atomic_set(&ep->running, 0);
for (i = 0; i < ep->num_urbs; i++) {
if (!ep->urbs[i].urb)
@@ -1188,10 +1188,11 @@ void snd_usb_midi_v2_suspend_all(struct snd_usb_audio *chip)
static void resume_midi2_endpoint(struct snd_usb_midi2_endpoint *ep)
{
- ep->running = ep->suspended;
- if (ep->direction == STR_IN)
+ atomic_set(&ep->running, atomic_read(&ep->suspended));
+ atomic_set(&ep->suspended, 0);
+
+ if (ep->direction == STR_IN || atomic_read(&ep->running))
submit_io_urbs(ep);
- /* FIXME: does it all? */
}
void snd_usb_midi_v2_resume_all(struct snd_usb_audio *chip)
---
base-commit: fac9a31701803e4e41fdb7b5c71582c65cf47176
change-id: 20260422-usb-midi2-output-resume-3a2867b73ebe
Best regards,
--
Cássio Gabriel <cassiogabrielcontato@gmail.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] ALSA: usb-audio: midi2: Restart output URBs on resume
2026-05-04 14:08 [PATCH] ALSA: usb-audio: midi2: Restart output URBs on resume Cássio Gabriel
@ 2026-05-04 15:55 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-05-04 15:55 UTC (permalink / raw)
To: Cássio Gabriel
Cc: Takashi Iwai, Jaroslav Kysela, linux-sound, linux-kernel, stable
On Mon, 04 May 2026 16:08:45 +0200,
Cássio Gabriel wrote:
>
> USB MIDI 2.0 suspend saves the endpoint running state, clears it and
> kills all endpoint URBs. Resume restores the running state, but only
> restarts input endpoints.
>
> For a running output endpoint, this leaves the endpoint marked running
> with an empty URB queue. Output transfer progress depends on either the
> rawmidi trigger path starting the queue or an output completion refilling
> it. After suspend there is no completion left, and output data that
> remains queued in the raw UMP or legacy rawmidi buffer can stay stalled
> until userspace happens to trigger the stream again.
>
> Restore the saved state with atomic accessors, keep input endpoints
> restarted as before, and restart output endpoints that were running before
> suspend. Clear the saved suspend state after restoring it.
>
> Fixes: ff49d1df79ae ("ALSA: usb-audio: USB MIDI 2.0 UMP support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
Thanks, applied now.
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-04 15:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-04 14:08 [PATCH] ALSA: usb-audio: midi2: Restart output URBs on resume Cássio Gabriel
2026-05-04 15:55 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox