From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab <mchehab@kernel.org>, linux-usb@vger.kernel.org, tglx@linutronix.de, Sebastian Andrzej Siewior <bigeasy@linutronix.de>, Hans Verkuil <hans.verkuil@cisco.com> Subject: [PATCH 10/27] media: go7007: use irqsave() in USB's complete callback Date: Wed, 20 Jun 2018 13:00:48 +0200 [thread overview] Message-ID: <20180620110105.19955-11-bigeasy@linutronix.de> (raw) In-Reply-To: <20180620110105.19955-1-bigeasy@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: Hans Verkuil <hans.verkuil@cisco.com> Cc: Mauro Carvalho Chehab <mchehab@kernel.org> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- drivers/media/usb/go7007/go7007-driver.c | 9 +++++---- drivers/media/usb/go7007/snd-go7007.c | 11 ++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/media/usb/go7007/go7007-driver.c b/drivers/media/usb/go7007/go7007-driver.c index 05b1126f263e..62aeebcdd7f7 100644 --- a/drivers/media/usb/go7007/go7007-driver.c +++ b/drivers/media/usb/go7007/go7007-driver.c @@ -448,13 +448,14 @@ static struct go7007_buffer *frame_boundary(struct go7007 *go, struct go7007_buf { u32 *bytesused; struct go7007_buffer *vb_tmp = NULL; + unsigned long flags; if (vb == NULL) { - spin_lock(&go->spinlock); + spin_lock_irqsave(&go->spinlock, flags); if (!list_empty(&go->vidq_active)) vb = go->active_buf = list_first_entry(&go->vidq_active, struct go7007_buffer, list); - spin_unlock(&go->spinlock); + spin_unlock_irqrestore(&go->spinlock, flags); go->next_seq++; return vb; } @@ -468,7 +469,7 @@ static struct go7007_buffer *frame_boundary(struct go7007 *go, struct go7007_buf vb->vb.vb2_buf.timestamp = ktime_get_ns(); vb_tmp = vb; - spin_lock(&go->spinlock); + spin_lock_irqsave(&go->spinlock, flags); list_del(&vb->list); if (list_empty(&go->vidq_active)) vb = NULL; @@ -476,7 +477,7 @@ static struct go7007_buffer *frame_boundary(struct go7007 *go, struct go7007_buf vb = list_first_entry(&go->vidq_active, struct go7007_buffer, list); go->active_buf = vb; - spin_unlock(&go->spinlock); + spin_unlock_irqrestore(&go->spinlock, flags); vb2_buffer_done(&vb_tmp->vb.vb2_buf, VB2_BUF_STATE_DONE); return vb; } diff --git a/drivers/media/usb/go7007/snd-go7007.c b/drivers/media/usb/go7007/snd-go7007.c index f84a2130f033..137fc253b122 100644 --- a/drivers/media/usb/go7007/snd-go7007.c +++ b/drivers/media/usb/go7007/snd-go7007.c @@ -75,13 +75,14 @@ static void parse_audio_stream_data(struct go7007 *go, u8 *buf, int length) struct go7007_snd *gosnd = go->snd_context; struct snd_pcm_runtime *runtime = gosnd->substream->runtime; int frames = bytes_to_frames(runtime, length); + unsigned long flags; - spin_lock(&gosnd->lock); + spin_lock_irqsave(&gosnd->lock, flags); gosnd->hw_ptr += frames; if (gosnd->hw_ptr >= runtime->buffer_size) gosnd->hw_ptr -= runtime->buffer_size; gosnd->avail += frames; - spin_unlock(&gosnd->lock); + spin_unlock_irqrestore(&gosnd->lock, flags); if (gosnd->w_idx + length > runtime->dma_bytes) { int cpy = runtime->dma_bytes - gosnd->w_idx; @@ -92,13 +93,13 @@ static void parse_audio_stream_data(struct go7007 *go, u8 *buf, int length) } memcpy(runtime->dma_area + gosnd->w_idx, buf, length); gosnd->w_idx += length; - spin_lock(&gosnd->lock); + spin_lock_irqsave(&gosnd->lock, flags); if (gosnd->avail < runtime->period_size) { - spin_unlock(&gosnd->lock); + spin_unlock_irqrestore(&gosnd->lock, flags); return; } gosnd->avail -= runtime->period_size; - spin_unlock(&gosnd->lock); + spin_unlock_irqrestore(&gosnd->lock, flags); if (gosnd->capturing) snd_pcm_period_elapsed(gosnd->substream); } -- 2.17.1
WARNING: multiple messages have this Message-ID (diff)
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab <mchehab@kernel.org>, linux-usb@vger.kernel.org, tglx@linutronix.de, Sebastian Andrzej Siewior <bigeasy@linutronix.de>, Hans Verkuil <hans.verkuil@cisco.com> Subject: [10/27] media: go7007: use irqsave() in USB's complete callback Date: Wed, 20 Jun 2018 13:00:48 +0200 [thread overview] Message-ID: <20180620110105.19955-11-bigeasy@linutronix.de> (raw) 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: Hans Verkuil <hans.verkuil@cisco.com> Cc: Mauro Carvalho Chehab <mchehab@kernel.org> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- drivers/media/usb/go7007/go7007-driver.c | 9 +++++---- drivers/media/usb/go7007/snd-go7007.c | 11 ++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/media/usb/go7007/go7007-driver.c b/drivers/media/usb/go7007/go7007-driver.c index 05b1126f263e..62aeebcdd7f7 100644 --- a/drivers/media/usb/go7007/go7007-driver.c +++ b/drivers/media/usb/go7007/go7007-driver.c @@ -448,13 +448,14 @@ static struct go7007_buffer *frame_boundary(struct go7007 *go, struct go7007_buf { u32 *bytesused; struct go7007_buffer *vb_tmp = NULL; + unsigned long flags; if (vb == NULL) { - spin_lock(&go->spinlock); + spin_lock_irqsave(&go->spinlock, flags); if (!list_empty(&go->vidq_active)) vb = go->active_buf = list_first_entry(&go->vidq_active, struct go7007_buffer, list); - spin_unlock(&go->spinlock); + spin_unlock_irqrestore(&go->spinlock, flags); go->next_seq++; return vb; } @@ -468,7 +469,7 @@ static struct go7007_buffer *frame_boundary(struct go7007 *go, struct go7007_buf vb->vb.vb2_buf.timestamp = ktime_get_ns(); vb_tmp = vb; - spin_lock(&go->spinlock); + spin_lock_irqsave(&go->spinlock, flags); list_del(&vb->list); if (list_empty(&go->vidq_active)) vb = NULL; @@ -476,7 +477,7 @@ static struct go7007_buffer *frame_boundary(struct go7007 *go, struct go7007_buf vb = list_first_entry(&go->vidq_active, struct go7007_buffer, list); go->active_buf = vb; - spin_unlock(&go->spinlock); + spin_unlock_irqrestore(&go->spinlock, flags); vb2_buffer_done(&vb_tmp->vb.vb2_buf, VB2_BUF_STATE_DONE); return vb; } diff --git a/drivers/media/usb/go7007/snd-go7007.c b/drivers/media/usb/go7007/snd-go7007.c index f84a2130f033..137fc253b122 100644 --- a/drivers/media/usb/go7007/snd-go7007.c +++ b/drivers/media/usb/go7007/snd-go7007.c @@ -75,13 +75,14 @@ static void parse_audio_stream_data(struct go7007 *go, u8 *buf, int length) struct go7007_snd *gosnd = go->snd_context; struct snd_pcm_runtime *runtime = gosnd->substream->runtime; int frames = bytes_to_frames(runtime, length); + unsigned long flags; - spin_lock(&gosnd->lock); + spin_lock_irqsave(&gosnd->lock, flags); gosnd->hw_ptr += frames; if (gosnd->hw_ptr >= runtime->buffer_size) gosnd->hw_ptr -= runtime->buffer_size; gosnd->avail += frames; - spin_unlock(&gosnd->lock); + spin_unlock_irqrestore(&gosnd->lock, flags); if (gosnd->w_idx + length > runtime->dma_bytes) { int cpy = runtime->dma_bytes - gosnd->w_idx; @@ -92,13 +93,13 @@ static void parse_audio_stream_data(struct go7007 *go, u8 *buf, int length) } memcpy(runtime->dma_area + gosnd->w_idx, buf, length); gosnd->w_idx += length; - spin_lock(&gosnd->lock); + spin_lock_irqsave(&gosnd->lock, flags); if (gosnd->avail < runtime->period_size) { - spin_unlock(&gosnd->lock); + spin_unlock_irqrestore(&gosnd->lock, flags); return; } gosnd->avail -= runtime->period_size; - spin_unlock(&gosnd->lock); + spin_unlock_irqrestore(&gosnd->lock, flags); if (gosnd->capturing) snd_pcm_period_elapsed(gosnd->substream); }
next prev parent reply other threads:[~2018-06-20 11:01 UTC|newest] Thread overview: 100+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-06-20 11:00 medial: use irqsave() in URB completion + usb_fill_int_urb Sebastian Andrzej Siewior 2018-06-20 11:00 ` [PATCH 01/27] media: b2c2: use usb_fill_int_urb() Sebastian Andrzej Siewior 2018-06-20 11:00 ` [01/27] " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [PATCH 02/27] media: cpia2_usb: " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [02/27] " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [PATCH 03/27] media: cx231xx: use usb_fill_XXX_urb() Sebastian Andrzej Siewior 2018-06-20 11:00 ` [03/27] " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [PATCH 04/27] media: cx231xx: use irqsave() in USB's complete callback Sebastian Andrzej Siewior 2018-06-20 11:00 ` [04/27] " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [PATCH 05/27] media: dvb-usb: use usb_fill_int_urb() Sebastian Andrzej Siewior 2018-06-20 11:00 ` [05/27] " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [PATCH 06/27] media: dvb_usb_v2: " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [06/27] " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [PATCH 07/27] media: em28xx-audio: use GFP_KERNEL for memory allocation during init Sebastian Andrzej Siewior 2018-06-20 11:00 ` [07/27] " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [PATCH 08/27] media: em28xx-audio: use irqsave() in USB's complete callback Sebastian Andrzej Siewior 2018-06-20 11:00 ` [08/27] " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [PATCH 09/27] media: em28xx-audio: use usb_fill_int_urb() Sebastian Andrzej Siewior 2018-06-20 11:00 ` [09/27] " Sebastian Andrzej Siewior 2018-06-20 11:00 ` Sebastian Andrzej Siewior [this message] 2018-06-20 11:00 ` [10/27] media: go7007: use irqsave() in USB's complete callback Sebastian Andrzej Siewior 2018-06-20 11:00 ` [PATCH 11/27] media: gspca: benq: use usb_fill_int_urb() Sebastian Andrzej Siewior 2018-06-20 11:00 ` [11/27] " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [PATCH 12/27] media: gspca: gspca: use usb_fill_XXX_urb() Sebastian Andrzej Siewior 2018-06-20 11:00 ` [12/27] " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [PATCH 13/27] media: gspca: konica: use usb_fill_int_urb() Sebastian Andrzej Siewior 2018-06-20 11:00 ` [13/27] " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [PATCH 14/27] media: gspca: sq930x: use GFP_KERNEL in sd_dq_callback() Sebastian Andrzej Siewior 2018-06-20 11:00 ` [14/27] " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [PATCH 15/27] media: msi2500: use usb_fill_int_urb() Sebastian Andrzej Siewior 2018-06-20 11:00 ` [15/27] " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [PATCH 16/27] media: pwc: " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [16/27] " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [PATCH 17/27] media: stk1160: " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [17/27] " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [PATCH 18/27] media: stkwebcam: " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [18/27] " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [PATCH 19/27] media: tm6000: use irqsave() in USB's complete callback Sebastian Andrzej Siewior 2018-06-20 11:00 ` [19/27] " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [PATCH 20/27] media: ttusb-budget: use usb_fill_int_urb() Sebastian Andrzej Siewior 2018-06-20 11:00 ` [20/27] " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [PATCH 21/27] media: ttusb-dec: " Sebastian Andrzej Siewior 2018-06-20 11:00 ` [21/27] " Sebastian Andrzej Siewior 2018-06-20 11:01 ` [PATCH 22/27] media: ttusbir: " Sebastian Andrzej Siewior 2018-06-20 11:01 ` [22/27] " Sebastian Andrzej Siewior 2018-06-20 20:50 ` [PATCH 22/27] " Sean Young 2018-06-20 20:50 ` [22/27] " Sean Young 2018-06-21 7:37 ` [PATCH 22/27] " Sebastian Andrzej Siewior 2018-06-21 7:37 ` [22/27] " Sebastian Andrzej Siewior 2018-06-20 11:01 ` [PATCH 23/27] media: usbtv: use irqsave() in USB's complete callback Sebastian Andrzej Siewior 2018-06-20 11:01 ` [23/27] " Sebastian Andrzej Siewior 2018-06-20 11:01 ` [PATCH 24/27] media: usbtv: use usb_fill_int_urb() Sebastian Andrzej Siewior 2018-06-20 11:01 ` [24/27] " Sebastian Andrzej Siewior 2018-06-20 11:01 ` [PATCH 25/27] media: usbvision: remove time_in_irq Sebastian Andrzej Siewior 2018-06-20 11:01 ` [25/27] " Sebastian Andrzej Siewior 2018-06-20 11:01 ` [PATCH 26/27] media: usbvision: use usb_fill_int_urb() Sebastian Andrzej Siewior 2018-06-20 11:01 ` [26/27] " Sebastian Andrzej Siewior 2018-06-20 11:01 ` [PATCH 27/27] media: uvcvideo: " Sebastian Andrzej Siewior 2018-06-20 11:01 ` [27/27] " Sebastian Andrzej Siewior 2018-06-20 11:55 ` [PATCH 27/27] " Laurent Pinchart 2018-06-20 11:55 ` [27/27] " Laurent Pinchart 2018-06-20 13:21 ` [PATCH 27/27] " Sebastian Andrzej Siewior 2018-06-20 13:21 ` [27/27] " Sebastian Andrzej Siewior 2018-06-20 14:14 ` [PATCH 27/27] " Laurent Pinchart 2018-06-20 14:14 ` [27/27] " Laurent Pinchart 2018-06-20 15:20 ` [PATCH] USB: note that usb_fill_int_urb() can be used used for ISOC urbs Sebastian Andrzej Siewior 2018-06-20 15:20 ` Sebastian Andrzej Siewior 2018-06-20 15:35 ` [PATCH] " Alan Stern 2018-06-20 15:35 ` Alan Stern 2018-06-20 16:02 ` [PATCH] " Sebastian Andrzej Siewior 2018-06-20 16:02 ` Sebastian Andrzej Siewior 2018-06-20 16:21 ` [PATCH] " Alan Stern 2018-06-20 16:21 ` Alan Stern 2018-06-20 16:49 ` [PATCH] " Sebastian Andrzej Siewior 2018-06-20 16:49 ` Sebastian Andrzej Siewior 2018-06-20 17:23 ` [PATCH] " Alan Stern 2018-06-20 17:23 ` Alan Stern 2018-07-12 22:35 ` [PATCH RFC] usb: add usb_fill_iso_urb() Sebastian Andrzej Siewior 2018-07-12 22:35 ` [RFC] " Sebastian Andrzej Siewior 2018-07-13 7:29 ` [PATCH RFC] " Greg Kroah-Hartman 2018-07-13 7:29 ` [RFC] " Greg Kroah-Hartman 2018-07-13 7:47 ` [PATCH RFC] " Sebastian Andrzej Siewior 2018-07-13 7:47 ` [RFC] " Sebastian Andrzej Siewior 2018-07-16 22:53 ` [PATCH RFC] " Sebastian Andrzej Siewior 2018-07-16 22:53 ` [RFC] " Sebastian Andrzej Siewior 2018-07-17 6:54 ` [PATCH RFC] " Clemens Ladisch 2018-07-17 6:54 ` Clemens Ladisch 2018-07-17 6:54 ` [RFC] " Clemens Ladisch 2018-08-06 21:21 ` [PATCH RFC] " Laurent Pinchart 2018-08-06 21:21 ` [RFC] " Laurent Pinchart 2018-08-06 22:02 ` [PATCH RFC] " Sebastian Andrzej Siewior 2018-08-06 22:02 ` [RFC] " Sebastian Andrzej Siewior 2018-07-13 8:01 ` [PATCH RFC] " Laurent Pinchart 2018-07-13 8:01 ` [RFC] " Laurent Pinchart 2018-07-13 20:12 ` [PATCH RFC] " Alan Stern 2018-07-13 20:12 ` [RFC] " Alan Stern 2018-06-20 15:21 ` [PATCH 27/27 v2] media: uvcvideo: use usb_fill_int_urb() for the ->intarval value Sebastian Andrzej Siewior 2018-06-20 15:21 ` [27/27,v2] " Sebastian Andrzej Siewior 2018-06-20 15:40 ` [PATCH 27/27 v2] " Alan Stern 2018-06-20 15:40 ` [27/27,v2] " Alan Stern
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=20180620110105.19955-11-bigeasy@linutronix.de \ --to=bigeasy@linutronix.de \ --cc=hans.verkuil@cisco.com \ --cc=linux-media@vger.kernel.org \ --cc=linux-usb@vger.kernel.org \ --cc=mchehab@kernel.org \ --cc=tglx@linutronix.de \ /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: linkBe 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.