Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969597AbdADWh3 (ORCPT ); Wed, 4 Jan 2017 17:37:29 -0500 Received: from mail-wj0-f196.google.com ([209.85.210.196]:36016 "EHLO mail-wj0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S969439AbdADWhY (ORCPT ); Wed, 4 Jan 2017 17:37:24 -0500 From: Ioan-Adrian Ratiu 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 Message-Id: <20170104223747.2742-3-adi@adirat.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170104223747.2742-1-adi@adirat.com> References: <20170104223747.2742-1-adi@adirat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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