mbox series

[0/3] media: videobuf2: Expose vb2_queue_is_busy() to drivers

Message ID 20220318211446.11543-1-laurent.pinchart+renesas@ideasonboard.com
Headers show
Series media: videobuf2: Expose vb2_queue_is_busy() to drivers | expand

Message

Laurent Pinchart March 18, 2022, 9:14 p.m. UTC
Hello,

This small patch series exposes the vb2_queue_is_busy() function,
currently internal to videobuf2-v4l2.c, to drivers. The rationale is
explained in patch 1/3, and the first use case shown in 3/3: it allows
implementing additional checks at streamon time while keeping the owner
check first (as it's cheap, compared to other checks that can be more
expensive).

Patch 2/3 is a driver-by cleanup.

Laurent Pinchart (3):
  media: videobuf2-v4l2: Expose vb2_queue_is_busy() to drivers
  media: vsp1: Don't open-code vb2_fop_release()
  media: vsp1: Use vb2_queue_is_busy()

 .../media/common/videobuf2/videobuf2-v4l2.c   | 26 +++++++------------
 .../media/platform/renesas/vsp1/vsp1_video.c  | 12 ++-------
 include/media/videobuf2-v4l2.h                | 23 ++++++++++++++--
 3 files changed, 33 insertions(+), 28 deletions(-)


base-commit: 71e6d0608e4d1b79069990c7dacb3600ced28a3b

Comments

Kieran Bingham March 18, 2022, 9:40 p.m. UTC | #1
Quoting Laurent Pinchart (2022-03-18 21:14:46)
> Use the new vb2_queue_is_busy() helper to replace the open-coded
> version.
> 

Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  drivers/media/platform/renesas/vsp1/vsp1_video.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/renesas/vsp1/vsp1_video.c b/drivers/media/platform/renesas/vsp1/vsp1_video.c
> index 8f53abc71db2..4da70b2b0869 100644
> --- a/drivers/media/platform/renesas/vsp1/vsp1_video.c
> +++ b/drivers/media/platform/renesas/vsp1/vsp1_video.c
> @@ -1032,7 +1032,7 @@ vsp1_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
>         struct vsp1_pipeline *pipe;
>         int ret;
>  
> -       if (video->queue.owner && video->queue.owner != file->private_data)
> +       if (vb2_queue_is_busy(&video->queue, file))
>                 return -EBUSY;
>  
>         /*
> -- 
> Regards,
> 
> Laurent Pinchart
>
Kieran Bingham March 18, 2022, 9:44 p.m. UTC | #2
Quoting Laurent Pinchart (2022-03-18 21:14:45)
> Use the vb2_fop_release() helper to replace the open-coded version. The
> video->lock is assigned to the queue lock, used by vb2_fop_release(), so
> the only functional difference is that v4l2_fh_release() is now called
> before vsp1_device_put(). This should be harmless.
> 

Seems to check out.

Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  drivers/media/platform/renesas/vsp1/vsp1_video.c | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/drivers/media/platform/renesas/vsp1/vsp1_video.c b/drivers/media/platform/renesas/vsp1/vsp1_video.c
> index 044eb5778820..8f53abc71db2 100644
> --- a/drivers/media/platform/renesas/vsp1/vsp1_video.c
> +++ b/drivers/media/platform/renesas/vsp1/vsp1_video.c
> @@ -1129,19 +1129,11 @@ static int vsp1_video_open(struct file *file)
>  static int vsp1_video_release(struct file *file)
>  {
>         struct vsp1_video *video = video_drvdata(file);
> -       struct v4l2_fh *vfh = file->private_data;
>  
> -       mutex_lock(&video->lock);
> -       if (video->queue.owner == vfh) {
> -               vb2_queue_release(&video->queue);
> -               video->queue.owner = NULL;
> -       }
> -       mutex_unlock(&video->lock);
> +       vb2_fop_release(file);
>  
>         vsp1_device_put(video->vsp1);
>  
> -       v4l2_fh_release(file);
> -
>         file->private_data = NULL;
>  
>         return 0;
> -- 
> Regards,
> 
> Laurent Pinchart
>