ALSA: usb-audio: test EP_FLAG_RUNNING at urb completion
authorIoan-Adrian Ratiu <adi@adirat.com>
Wed, 4 Jan 2017 22:37:47 +0000 (00:37 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 5 Jan 2017 06:35:17 +0000 (07:35 +0100)
Testing EP_FLAG_RUNNING in snd_complete_urb() before running the completion
logic allows us to save a few cpu cycles by returning early, skipping the
pending urb in case the stream was stopped; the stop logic handles the urb
and sets the completion callbacks to NULL.

Signed-off-by: Ioan-Adrian Ratiu <adi@adirat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/endpoint.c

index 2f0ea70a998ce719e762b22ca789a1788222505e..c90607ebe155b4dce4cfa8aa75fc14ecab953d52 100644 (file)
@@ -384,6 +384,9 @@ static void snd_complete_urb(struct urb *urb)
        if (unlikely(atomic_read(&ep->chip->shutdown)))
                goto exit_clear;
 
+       if (unlikely(!test_bit(EP_FLAG_RUNNING, &ep->flags)))
+               goto exit_clear;
+
        if (usb_pipeout(ep->pipe)) {
                retire_outbound_urb(ep, ctx);
                /* can be stopped during retire callback */