All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ioan-Adrian Ratiu <adi@adirat.com>
To: tiwai@suse.com
Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org,
	perex@perex.cz
Subject: [PATCH v3 2/2] ALSA: usb-audio: test EP_FLAG_RUNNING at urb completion
Date: Thu,  5 Jan 2017 00:37:47 +0200	[thread overview]
Message-ID: <20170104223747.2742-3-adi@adirat.com> (raw)
In-Reply-To: <20170104223747.2742-1-adi@adirat.com>

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

  parent reply	other threads:[~2017-01-04 22:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-04 22:37 [PATCH v3 0/2] ALSA: Fix usb-audio races Ioan-Adrian Ratiu
2017-01-04 22:37 ` [PATCH v3 1/2] ALSA: usb-audio: Fix irq/process data synchronization Ioan-Adrian Ratiu
2017-01-04 22:37 ` Ioan-Adrian Ratiu [this message]
2017-01-05  6:36 ` [PATCH v3 0/2] ALSA: Fix usb-audio races Takashi Iwai
2017-01-05  6:36   ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170104223747.2742-3-adi@adirat.com \
    --to=adi@adirat.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.