alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: alsa-devel@alsa-project.org
Cc: John Ogness <john.ogness@linutronix.de>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	linux-usb@vger.kernel.org, Clemens Ladisch <clemens@ladisch.de>,
	Takashi Iwai <tiwai@suse.com>,
	tglx@linutronix.de
Subject: [PATCH 7/9] ALSA: usb-midi: use irqsave() in USB's complete callback
Date: Tue, 19 Jun 2018 23:55:19 +0200	[thread overview]
Message-ID: <20180619215521.13688-8-bigeasy@linutronix.de> (raw)
In-Reply-To: <20180619215521.13688-1-bigeasy@linutronix.de>

From: John Ogness <john.ogness@linutronix.de>

The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Cc: Clemens Ladisch <clemens@ladisch.de>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 sound/usb/midi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sound/usb/midi.c b/sound/usb/midi.c
index 2c1aaa3292bf..dcfc546d81b9 100644
--- a/sound/usb/midi.c
+++ b/sound/usb/midi.c
@@ -281,15 +281,16 @@ static void snd_usbmidi_out_urb_complete(struct urb *urb)
 	struct out_urb_context *context = urb->context;
 	struct snd_usb_midi_out_endpoint *ep = context->ep;
 	unsigned int urb_index;
+	unsigned long flags;
 
-	spin_lock(&ep->buffer_lock);
+	spin_lock_irqsave(&ep->buffer_lock, flags);
 	urb_index = context - ep->urbs;
 	ep->active_urbs &= ~(1 << urb_index);
 	if (unlikely(ep->drain_urbs)) {
 		ep->drain_urbs &= ~(1 << urb_index);
 		wake_up(&ep->drain_wait);
 	}
-	spin_unlock(&ep->buffer_lock);
+	spin_unlock_irqrestore(&ep->buffer_lock, flags);
 	if (urb->status < 0) {
 		int err = snd_usbmidi_urb_error(urb);
 		if (err < 0) {
-- 
2.17.1

  parent reply	other threads:[~2018-06-19 21:55 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-19 21:55 ALSA: use irqsave() in URB completion + usb_fill_int_urb Sebastian Andrzej Siewior
2018-06-19 21:55 ` [PATCH 1/9] ALSA: 6fire: use usb_fill_int_urb() Sebastian Andrzej Siewior
2018-06-19 21:55 ` [PATCH 2/9] ALSA: line6: " Sebastian Andrzej Siewior
2018-06-19 21:55 ` [PATCH 3/9] ALSA: ua101: " Sebastian Andrzej Siewior
2018-06-19 21:55 ` [PATCH 4/9] ALSA: usb-audio: " Sebastian Andrzej Siewior
2018-06-20  8:23   ` Sergei Shtylyov
2018-06-20  9:38     ` [PATCH 4/9 v2] " Sebastian Andrzej Siewior
2018-06-20 13:21       ` Takashi Iwai
2018-06-20 13:52         ` Sebastian Andrzej Siewior
2018-06-20 13:56           ` Takashi Iwai
2018-06-20 14:00             ` Takashi Iwai
2018-06-19 21:55 ` [PATCH 5/9] ALSA: usb: caiaq: audio: use irqsave() in USB's complete callback Sebastian Andrzej Siewior
2018-06-21 20:18   ` Daniel Mack
2018-06-19 21:55 ` [PATCH 6/9] ALSA: usb: caiaq: use usb_fill_int_urb() Sebastian Andrzej Siewior
2018-06-21 20:19   ` Daniel Mack
2018-06-21 21:16     ` Sebastian Andrzej Siewior
2018-06-22  8:49       ` Takashi Iwai
2018-06-22 10:01       ` Daniel Mack
2018-06-22 10:14         ` Sebastian Andrzej Siewior
2018-06-19 21:55 ` Sebastian Andrzej Siewior [this message]
2018-06-19 21:55 ` [PATCH 8/9] ALSA: usx2y: usbusx2yaudio: " Sebastian Andrzej Siewior
2018-06-20 12:51   ` Takashi Iwai
2018-06-20 14:39     ` Sebastian Andrzej Siewior
2018-06-20 14:52       ` Takashi Iwai
2018-06-20 15:38         ` Sebastian Andrzej Siewior
2018-06-20 15:47           ` Sebastian Andrzej Siewior
2018-06-20 16:20             ` Takashi Iwai
2018-06-19 21:55 ` [PATCH 9/9] ALSA: usx2y: usx2yhwdeppcm: " Sebastian Andrzej Siewior
2018-06-20 12:55 ` ALSA: use irqsave() in URB completion + usb_fill_int_urb 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=20180619215521.13688-8-bigeasy@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=john.ogness@linutronix.de \
    --cc=linux-usb@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).