public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Ricardo Ribalda <ribalda@chromium.org>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/4] media: uvcvideo: Allow changing noparam on the fly
Date: Thu, 19 Dec 2024 01:27:01 +0200	[thread overview]
Message-ID: <20241218232701.GC5518@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20241218-uvc-deprecate-v2-3-ab814139e983@chromium.org>

On Wed, Dec 18, 2024 at 09:39:10PM +0000, Ricardo Ribalda wrote:
> Right now the parameter value is read during video_registration and
> cannot be changed afterwards, despite its permissions 0644, that makes
> the user believe that the value can be written.

Well, it can still be written, and will apply to new devices. There's
value in making it fully dynamic though.

> 
> The parameter only affects the beviour of uvc_queue_buffer_complete(),

s/beviour/behaviour/

> with only one check per buffer.
> 
> We can read the value directly from uvc_queue_buffer_complete() and
> therefore allowing changing it with sysfs on the fly.
> 
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
>  drivers/media/usb/uvc/uvc_driver.c | 2 +-
>  drivers/media/usb/uvc/uvc_queue.c  | 6 ++----
>  drivers/media/usb/uvc/uvcvideo.h   | 4 +---
>  3 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
> index 091145743872..10812a841587 100644
> --- a/drivers/media/usb/uvc/uvc_driver.c
> +++ b/drivers/media/usb/uvc/uvc_driver.c
> @@ -1995,7 +1995,7 @@ int uvc_register_video_device(struct uvc_device *dev,
>  	int ret;
>  
>  	/* Initialize the video buffers queue. */
> -	ret = uvc_queue_init(queue, type, !uvc_no_drop_param);
> +	ret = uvc_queue_init(queue, type);
>  	if (ret)
>  		return ret;
>  
> diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c
> index f8464f0aae1b..2ee142621042 100644
> --- a/drivers/media/usb/uvc/uvc_queue.c
> +++ b/drivers/media/usb/uvc/uvc_queue.c
> @@ -208,8 +208,7 @@ static const struct vb2_ops uvc_meta_queue_qops = {
>  	.stop_streaming = uvc_stop_streaming,
>  };
>  
> -int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
> -		    int drop_corrupted)
> +int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type)
>  {
>  	int ret;
>  
> @@ -239,7 +238,6 @@ int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
>  	mutex_init(&queue->mutex);
>  	spin_lock_init(&queue->irqlock);
>  	INIT_LIST_HEAD(&queue->irqqueue);
> -	queue->flags = drop_corrupted ? UVC_QUEUE_DROP_CORRUPTED : 0;
>  
>  	return 0;
>  }
> @@ -472,7 +470,7 @@ static void uvc_queue_buffer_complete(struct kref *ref)
>  	struct vb2_buffer *vb = &buf->buf.vb2_buf;
>  	struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue);
>  
> -	if ((queue->flags & UVC_QUEUE_DROP_CORRUPTED) && buf->error) {
> +	if (buf->error && !uvc_no_drop_param) {

As this is the only location where the uvc_no_drop_param variable is
read, I don't expect any race condition.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  		uvc_queue_buffer_requeue(queue, buf);
>  		return;
>  	}
> diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
> index 07f9921d83f2..ebbd8afcf136 100644
> --- a/drivers/media/usb/uvc/uvcvideo.h
> +++ b/drivers/media/usb/uvc/uvcvideo.h
> @@ -316,7 +316,6 @@ struct uvc_buffer {
>  };
>  
>  #define UVC_QUEUE_DISCONNECTED		(1 << 0)
> -#define UVC_QUEUE_DROP_CORRUPTED	(1 << 1)
>  
>  struct uvc_video_queue {
>  	struct vb2_queue queue;
> @@ -674,8 +673,7 @@ extern struct uvc_driver uvc_driver;
>  struct uvc_entity *uvc_entity_by_id(struct uvc_device *dev, int id);
>  
>  /* Video buffers queue management. */
> -int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
> -		   int drop_corrupted);
> +int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type);
>  void uvc_queue_release(struct uvc_video_queue *queue);
>  int uvc_request_buffers(struct uvc_video_queue *queue,
>  			struct v4l2_requestbuffers *rb);

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2024-12-18 23:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-18 21:39 [PATCH v2 0/4] media: uvcvideo: Prepare deprecation of nodrop Ricardo Ribalda
2024-12-18 21:39 ` [PATCH v2 1/4] media: uvcvideo: Propagate buf->error to userspace Ricardo Ribalda
2024-12-18 23:26   ` Laurent Pinchart
2024-12-18 21:39 ` [PATCH v2 2/4] media: uvcvideo: Invert default value for nodrop module param Ricardo Ribalda
2024-12-18 23:26   ` Laurent Pinchart
2024-12-18 21:39 ` [PATCH v2 3/4] media: uvcvideo: Allow changing noparam on the fly Ricardo Ribalda
2024-12-18 23:27   ` Laurent Pinchart [this message]
2024-12-18 21:39 ` [PATCH v2 4/4] media: uvcvideo: Announce the user our deprecation intentions Ricardo Ribalda
2024-12-18 23:27   ` Laurent Pinchart
2024-12-18 21:52 ` [PATCH v2 0/4] media: uvcvideo: Prepare deprecation of nodrop Hans de Goede
2024-12-18 22:01   ` Ricardo Ribalda

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=20241218232701.GC5518@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=hdegoede@redhat.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