Skip to content

Commit

Permalink
ALSA: usb-audio: test EP_FLAG_RUNNING at urb completion
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
10ne1 authored and tiwai committed Jan 5, 2017
1 parent 1d0f953 commit 13a6c83
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sound/usb/endpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 13a6c83

Please sign in to comment.