All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH REPOST 0/2] ALSA: use irqsave in USB's completion callback
@ 2018-07-01 15:28 Sebastian Andrzej Siewior
  2018-07-01 15:28 ` [PATCH REPOST 1/2] ALSA: usb: caiaq: audio: use irqsave() in USB's complete callback Sebastian Andrzej Siewior
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-07-01 15:28 UTC (permalink / raw)
  To: alsa-devel; +Cc: tglx, Takashi Iwai

This series is about using _irqsave() primitives in the completion callback in
order to get rid of local_irq_save() in __usb_hcd_giveback_urb().

Sebastian

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH REPOST 1/2] ALSA: usb: caiaq: audio: use irqsave() in USB's complete callback
  2018-07-01 15:28 [PATCH REPOST 0/2] ALSA: use irqsave in USB's completion callback Sebastian Andrzej Siewior
@ 2018-07-01 15:28 ` Sebastian Andrzej Siewior
  2018-07-01 18:46   ` Daniel Mack
  2018-07-01 15:28 ` [PATCH REPOST 2/2] ALSA: usb-midi: " Sebastian Andrzej Siewior
  2018-07-02 13:52 ` [PATCH REPOST 0/2] ALSA: use irqsave in USB's completion callback Takashi Iwai
  2 siblings, 1 reply; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-07-01 15:28 UTC (permalink / raw)
  To: alsa-devel
  Cc: John Ogness, Sebastian Andrzej Siewior, Takashi Iwai, Daniel Mack, tglx

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: Daniel Mack <zonque@gmail.com>
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/caiaq/audio.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c
index f35d29f49ffe..15344d39a6cd 100644
--- a/sound/usb/caiaq/audio.c
+++ b/sound/usb/caiaq/audio.c
@@ -636,6 +636,7 @@ static void read_completed(struct urb *urb)
 	struct device *dev;
 	struct urb *out = NULL;
 	int i, frame, len, send_it = 0, outframe = 0;
+	unsigned long flags;
 	size_t offset = 0;
 
 	if (urb->status || !info)
@@ -672,10 +673,10 @@ static void read_completed(struct urb *urb)
 		offset += len;
 
 		if (len > 0) {
-			spin_lock(&cdev->spinlock);
+			spin_lock_irqsave(&cdev->spinlock, flags);
 			fill_out_urb(cdev, out, &out->iso_frame_desc[outframe]);
 			read_in_urb(cdev, urb, &urb->iso_frame_desc[frame]);
-			spin_unlock(&cdev->spinlock);
+			spin_unlock_irqrestore(&cdev->spinlock, flags);
 			check_for_elapsed_periods(cdev, cdev->sub_playback);
 			check_for_elapsed_periods(cdev, cdev->sub_capture);
 			send_it = 1;
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH REPOST 2/2] ALSA: usb-midi: use irqsave() in USB's complete callback
  2018-07-01 15:28 [PATCH REPOST 0/2] ALSA: use irqsave in USB's completion callback Sebastian Andrzej Siewior
  2018-07-01 15:28 ` [PATCH REPOST 1/2] ALSA: usb: caiaq: audio: use irqsave() in USB's complete callback Sebastian Andrzej Siewior
@ 2018-07-01 15:28 ` Sebastian Andrzej Siewior
  2018-07-01 20:12   ` Clemens Ladisch
  2018-07-02 13:52 ` [PATCH REPOST 0/2] ALSA: use irqsave in USB's completion callback Takashi Iwai
  2 siblings, 1 reply; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-07-01 15:28 UTC (permalink / raw)
  To: alsa-devel
  Cc: John Ogness, Sebastian Andrzej Siewior, Clemens Ladisch,
	Takashi Iwai, tglx

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.18.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH REPOST 1/2] ALSA: usb: caiaq: audio: use irqsave() in USB's complete callback
  2018-07-01 15:28 ` [PATCH REPOST 1/2] ALSA: usb: caiaq: audio: use irqsave() in USB's complete callback Sebastian Andrzej Siewior
@ 2018-07-01 18:46   ` Daniel Mack
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Mack @ 2018-07-01 18:46 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior, alsa-devel
  Cc: tglx, Daniel Mack, Takashi Iwai, John Ogness

On Sunday, July 01, 2018 05:28 PM, Sebastian Andrzej Siewior wrote:
> 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.

Acked-by: Daniel Mack <daniel@zonque.org>

> 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/caiaq/audio.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c
> index f35d29f49ffe..15344d39a6cd 100644
> --- a/sound/usb/caiaq/audio.c
> +++ b/sound/usb/caiaq/audio.c
> @@ -636,6 +636,7 @@ static void read_completed(struct urb *urb)
>   	struct device *dev;
>   	struct urb *out = NULL;
>   	int i, frame, len, send_it = 0, outframe = 0;
> +	unsigned long flags;
>   	size_t offset = 0;
>   
>   	if (urb->status || !info)
> @@ -672,10 +673,10 @@ static void read_completed(struct urb *urb)
>   		offset += len;
>   
>   		if (len > 0) {
> -			spin_lock(&cdev->spinlock);
> +			spin_lock_irqsave(&cdev->spinlock, flags);
>   			fill_out_urb(cdev, out, &out->iso_frame_desc[outframe]);
>   			read_in_urb(cdev, urb, &urb->iso_frame_desc[frame]);
> -			spin_unlock(&cdev->spinlock);
> +			spin_unlock_irqrestore(&cdev->spinlock, flags);
>   			check_for_elapsed_periods(cdev, cdev->sub_playback);
>   			check_for_elapsed_periods(cdev, cdev->sub_capture);
>   			send_it = 1;
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH REPOST 2/2] ALSA: usb-midi: use irqsave() in USB's complete callback
  2018-07-01 15:28 ` [PATCH REPOST 2/2] ALSA: usb-midi: " Sebastian Andrzej Siewior
@ 2018-07-01 20:12   ` Clemens Ladisch
  0 siblings, 0 replies; 6+ messages in thread
From: Clemens Ladisch @ 2018-07-01 20:12 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior, alsa-devel; +Cc: tglx, Takashi Iwai, John Ogness

Sebastian Andrzej Siewior wrote:
> 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>

Acked-by: Clemens Ladisch <clemens@ladisch.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) {

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH REPOST 0/2] ALSA: use irqsave in USB's completion callback
  2018-07-01 15:28 [PATCH REPOST 0/2] ALSA: use irqsave in USB's completion callback Sebastian Andrzej Siewior
  2018-07-01 15:28 ` [PATCH REPOST 1/2] ALSA: usb: caiaq: audio: use irqsave() in USB's complete callback Sebastian Andrzej Siewior
  2018-07-01 15:28 ` [PATCH REPOST 2/2] ALSA: usb-midi: " Sebastian Andrzej Siewior
@ 2018-07-02 13:52 ` Takashi Iwai
  2 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2018-07-02 13:52 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior; +Cc: alsa-devel, tglx

On Sun, 01 Jul 2018 17:28:06 +0200,
Sebastian Andrzej Siewior wrote:
> 
> This series is about using _irqsave() primitives in the completion callback in
> order to get rid of local_irq_save() in __usb_hcd_giveback_urb().

Applied both patches now.  Thanks.


Takashi

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-07-02 22:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-01 15:28 [PATCH REPOST 0/2] ALSA: use irqsave in USB's completion callback Sebastian Andrzej Siewior
2018-07-01 15:28 ` [PATCH REPOST 1/2] ALSA: usb: caiaq: audio: use irqsave() in USB's complete callback Sebastian Andrzej Siewior
2018-07-01 18:46   ` Daniel Mack
2018-07-01 15:28 ` [PATCH REPOST 2/2] ALSA: usb-midi: " Sebastian Andrzej Siewior
2018-07-01 20:12   ` Clemens Ladisch
2018-07-02 13:52 ` [PATCH REPOST 0/2] ALSA: use irqsave in USB's completion callback Takashi Iwai

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.