From: Hans de Goede <hansg@kernel.org>
To: Ricardo Ribalda <ribalda@chromium.org>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Hans Verkuil <hans@jjverkuil.nl>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/5] media: uvcvideo: Handle locks in uvc_queue_return_buffers
Date: Mon, 16 Jun 2025 15:38:47 +0200 [thread overview]
Message-ID: <09cc5598-ade2-42c4-8a64-0981e4575d1b@kernel.org> (raw)
In-Reply-To: <20250602-uvc-fop-v3-3-a99e18f65640@chromium.org>
Hi Ricardo,
On 2-Jun-25 18:06, Ricardo Ribalda wrote:
> Most of the calls to uvc_queue_return_buffers() wrap the call with
> spin_lock_irq()/spin_unlock_irq().
>
> Rename uvc_queue_return_buffers to __uvc_queue_return_buffers to
> indicate that this is the version that does not handle locks and create
> a new version of the function that handles the lock.
>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Thanks, patch looks good to me:
Reviewed-by: Hans de Goede <hansg@kernel.org>
Regards,
Hans
> ---
> drivers/media/usb/uvc/uvc_queue.c | 20 +++++++++++++-------
> 1 file changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c
> index 72c5494dee9f46ff61072e7d293bfaddda40e615..8f9737ac729546683ca48f5e71ce3dfacbae2926 100644
> --- a/drivers/media/usb/uvc/uvc_queue.c
> +++ b/drivers/media/usb/uvc/uvc_queue.c
> @@ -42,13 +42,15 @@ static inline struct uvc_buffer *uvc_vbuf_to_buffer(struct vb2_v4l2_buffer *buf)
> *
> * This function must be called with the queue spinlock held.
> */
> -static void uvc_queue_return_buffers(struct uvc_video_queue *queue,
> - enum uvc_buffer_state state)
> +static void __uvc_queue_return_buffers(struct uvc_video_queue *queue,
> + enum uvc_buffer_state state)
> {
> enum vb2_buffer_state vb2_state = state == UVC_BUF_STATE_ERROR
> ? VB2_BUF_STATE_ERROR
> : VB2_BUF_STATE_QUEUED;
>
> + lockdep_assert_held(&queue->irqlock);
> +
> while (!list_empty(&queue->irqqueue)) {
> struct uvc_buffer *buf = list_first_entry(&queue->irqqueue,
> struct uvc_buffer,
> @@ -59,6 +61,14 @@ static void uvc_queue_return_buffers(struct uvc_video_queue *queue,
> }
> }
>
> +static void uvc_queue_return_buffers(struct uvc_video_queue *queue,
> + enum uvc_buffer_state state)
> +{
> + spin_lock_irq(&queue->irqlock);
> + __uvc_queue_return_buffers(queue, state);
> + spin_unlock_irq(&queue->irqlock);
> +}
> +
> /* -----------------------------------------------------------------------------
> * videobuf2 queue operations
> */
> @@ -171,9 +181,7 @@ static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count)
> if (ret == 0)
> return 0;
>
> - spin_lock_irq(&queue->irqlock);
> uvc_queue_return_buffers(queue, UVC_BUF_STATE_QUEUED);
> - spin_unlock_irq(&queue->irqlock);
>
> return ret;
> }
> @@ -187,9 +195,7 @@ static void uvc_stop_streaming(struct vb2_queue *vq)
> if (vq->type != V4L2_BUF_TYPE_META_CAPTURE)
> uvc_video_stop_streaming(uvc_queue_to_stream(queue));
>
> - spin_lock_irq(&queue->irqlock);
> uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR);
> - spin_unlock_irq(&queue->irqlock);
> }
>
> static const struct vb2_ops uvc_queue_qops = {
> @@ -263,7 +269,7 @@ void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect)
> unsigned long flags;
>
> spin_lock_irqsave(&queue->irqlock, flags);
> - uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR);
> + __uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR);
> /*
> * This must be protected by the irqlock spinlock to avoid race
> * conditions between uvc_buffer_queue and the disconnection event that
>
next prev parent reply other threads:[~2025-06-16 13:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-02 16:06 [PATCH v3 0/5] media: uvcvideo: use vb2 ioctl and fop helpers Ricardo Ribalda
2025-06-02 16:06 ` [PATCH v3 1/5] media: uvcvideo: Refactor uvc_queue_streamon Ricardo Ribalda
2025-06-02 16:06 ` [PATCH v3 2/5] media: uvcvideo: Use vb2 ioctl and fop helpers Ricardo Ribalda
2025-06-16 13:35 ` Hans de Goede
2025-06-02 16:06 ` [PATCH v3 3/5] media: uvcvideo: Handle locks in uvc_queue_return_buffers Ricardo Ribalda
2025-06-16 13:38 ` Hans de Goede [this message]
2025-06-02 16:06 ` [PATCH v3 4/5] media: uvcvideo: Split uvc_stop_streaming() Ricardo Ribalda
2025-06-16 13:39 ` Hans de Goede
2025-06-02 16:06 ` [PATCH v3 5/5] media: uvcvideo: Remove stream->is_streaming field Ricardo Ribalda
2025-06-16 13:42 ` Hans de Goede
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=09cc5598-ade2-42c4-8a64-0981e4575d1b@kernel.org \
--to=hansg@kernel.org \
--cc=hans@jjverkuil.nl \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=ribalda@chromium.org \
/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).