ALSA: usb-audio: Fix implicit sync clearance at stopping stream
authorTakashi Iwai <tiwai@suse.de>
Mon, 26 Apr 2021 06:33:49 +0000 (08:33 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 26 Apr 2021 06:37:05 +0000 (08:37 +0200)
The recent endpoint management change for implicit feedback mode added
a clearance of ep->sync_sink (formerly ep->sync_slave) pointer at
snd_usb_endpoint_stop() to assure no leftover for the feedback from
the already stopped capture stream.  This turned out to cause a
regression, however, when full-duplex streams were running and only a
capture was stopped.  Because of the above clearance of ep->sync_sink
pointer, no more feedback is done, hence the playback will stall.

This patch fixes the ep->sync_sink clearance to be done only after all
endpoints are released, for addressing the regression.

Reported-and-tested-by: Lucas Endres <jaffa225man@gmail.com>
Fixes: bf6313a0ff76 ("ALSA: usb-audio: Refactor endpoint management")
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210426063349.18601-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/endpoint.c

index f4c3d2b38abbe224ccda9a7974d89fc8b1b5bfd6..014c438628262b26136ab7c27f657a692830cf97 100644 (file)
@@ -1443,11 +1443,11 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep)
        if (snd_BUG_ON(!atomic_read(&ep->running)))
                return;
 
-       if (ep->sync_source)
-               WRITE_ONCE(ep->sync_source->sync_sink, NULL);
-
-       if (!atomic_dec_return(&ep->running))
+       if (!atomic_dec_return(&ep->running)) {
+               if (ep->sync_source)
+                       WRITE_ONCE(ep->sync_source->sync_sink, NULL);
                stop_urbs(ep, false);
+       }
 }
 
 /**