Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1549264

[PATCH v2 2/2] ALSA: usb-audio: test EP_FLAG_RUNNING at urb completion

From Ioan-Adrian Ratiu <adi@adirat.com>
Newsgroups linux.kernel
Subject [PATCH v2 2/2] ALSA: usb-audio: test EP_FLAG_RUNNING at urb completion
Date 2017-01-02 16:50 +0100
Message-ID <sVd22-r2-27@gated-at.bofh.it> (permalink)
References <sVd22-r2-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
 sound/usb/endpoint.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index 2f0ea70a998c..c90607ebe155 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -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 */
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/2] ALSA: Fix usb-audio races Ioan-Adrian Ratiu <adi@adirat.com> - 2017-01-02 16:50 +0100
  [PATCH v2 2/2] ALSA: usb-audio: test EP_FLAG_RUNNING at urb completion Ioan-Adrian Ratiu <adi@adirat.com> - 2017-01-02 16:50 +0100
  [PATCH v2 1/2] ALSA: usb-audio: Fix irq/process data synchronization Ioan-Adrian Ratiu <adi@adirat.com> - 2017-01-02 17:00 +0100
  Re: [PATCH v2 0/2] ALSA: Fix usb-audio races Ioan-Adrian Ratiu <adi@adirat.com> - 2017-01-03 08:30 +0100
    Re: [PATCH v2 0/2] ALSA: Fix usb-audio races Ioan-Adrian Ratiu <adi@adirat.com> - 2017-01-03 09:50 +0100
      Re: [PATCH v2 0/2] ALSA: Fix usb-audio races Takashi Iwai <tiwai@suse.de> - 2017-01-03 10:20 +0100

csiph-web