diff mbox series

[6/9] media: rcar_drif.c: set lock before calling vb2_queue_init()

Message ID 31085af170e3cc9b4fe115d53a556ccf477751d3.1725285495.git.hverkuil-cisco@xs4all.nl (mailing list archive)
State New
Headers show
Series media: vb2: prepare for vb2_ops_wait_prepare/finish removal | expand

Commit Message

Hans Verkuil Sept. 2, 2024, 2:04 p.m. UTC
The vb2_queue_init() will expect the vb2_queue lock pointer to be set in
the future. So for those drivers that set the lock later, move it up to
before the vb2_queue_init() call.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Ramesh Shanmugasundaram <ramesh.shanmugasundaram@bp.renesas.com>
Cc: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 drivers/media/platform/renesas/rcar_drif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Laurent Pinchart Sept. 9, 2024, 2:51 p.m. UTC | #1
Hi Hans,

Thank you for the patch.

On Mon, Sep 02, 2024 at 04:04:52PM +0200, Hans Verkuil wrote:
> The vb2_queue_init() will expect the vb2_queue lock pointer to be set in
> the future. So for those drivers that set the lock later, move it up to
> before the vb2_queue_init() call.

The commit message doesn't match the change below, you're moving the
lock down, not up.

> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> Cc: Ramesh Shanmugasundaram <ramesh.shanmugasundaram@bp.renesas.com>
> Cc: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> ---
>  drivers/media/platform/renesas/rcar_drif.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/renesas/rcar_drif.c b/drivers/media/platform/renesas/rcar_drif.c
> index f21d05054341..5d3109940ded 100644
> --- a/drivers/media/platform/renesas/rcar_drif.c
> +++ b/drivers/media/platform/renesas/rcar_drif.c
> @@ -1071,7 +1071,6 @@ static int rcar_drif_sdr_register(struct rcar_drif_sdr *sdr)
>  	sdr->vdev->release = video_device_release;
>  	sdr->vdev->lock = &sdr->v4l2_mutex;
>  	sdr->vdev->queue = &sdr->vb_queue;
> -	sdr->vdev->queue->lock = &sdr->vb_queue_mutex;
>  	sdr->vdev->ctrl_handler = &sdr->ctrl_hdl;
>  	sdr->vdev->v4l2_dev = &sdr->v4l2_dev;
>  	sdr->vdev->device_caps = V4L2_CAP_SDR_CAPTURE | V4L2_CAP_TUNER |
> @@ -1316,6 +1315,7 @@ static int rcar_drif_sdr_probe(struct rcar_drif_sdr *sdr)
>  	sdr->vb_queue.ops = &rcar_drif_vb2_ops;
>  	sdr->vb_queue.mem_ops = &vb2_vmalloc_memops;
>  	sdr->vb_queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> +	sdr->vb_queue.lock = &sdr->vb_queue_mutex;
>  
>  	/* Init videobuf2 queue */
>  	ret = vb2_queue_init(&sdr->vb_queue);
Hans Verkuil Sept. 9, 2024, 2:55 p.m. UTC | #2
On 09/09/2024 16:51, Laurent Pinchart wrote:
> Hi Hans,
> 
> Thank you for the patch.
> 
> On Mon, Sep 02, 2024 at 04:04:52PM +0200, Hans Verkuil wrote:
>> The vb2_queue_init() will expect the vb2_queue lock pointer to be set in
>> the future. So for those drivers that set the lock later, move it up to
>> before the vb2_queue_init() call.
> 
> The commit message doesn't match the change below, you're moving the
> lock down, not up.

Actually, I am moving it up, as in 'set earlier', but in this case it is
a bit confusing in the patch.

Regards,

	Hans

> 
>> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
>> Cc: Ramesh Shanmugasundaram <ramesh.shanmugasundaram@bp.renesas.com>
>> Cc: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>> ---
>>  drivers/media/platform/renesas/rcar_drif.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/platform/renesas/rcar_drif.c b/drivers/media/platform/renesas/rcar_drif.c
>> index f21d05054341..5d3109940ded 100644
>> --- a/drivers/media/platform/renesas/rcar_drif.c
>> +++ b/drivers/media/platform/renesas/rcar_drif.c
>> @@ -1071,7 +1071,6 @@ static int rcar_drif_sdr_register(struct rcar_drif_sdr *sdr)
>>  	sdr->vdev->release = video_device_release;
>>  	sdr->vdev->lock = &sdr->v4l2_mutex;
>>  	sdr->vdev->queue = &sdr->vb_queue;
>> -	sdr->vdev->queue->lock = &sdr->vb_queue_mutex;
>>  	sdr->vdev->ctrl_handler = &sdr->ctrl_hdl;
>>  	sdr->vdev->v4l2_dev = &sdr->v4l2_dev;
>>  	sdr->vdev->device_caps = V4L2_CAP_SDR_CAPTURE | V4L2_CAP_TUNER |
>> @@ -1316,6 +1315,7 @@ static int rcar_drif_sdr_probe(struct rcar_drif_sdr *sdr)
>>  	sdr->vb_queue.ops = &rcar_drif_vb2_ops;
>>  	sdr->vb_queue.mem_ops = &vb2_vmalloc_memops;
>>  	sdr->vb_queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
>> +	sdr->vb_queue.lock = &sdr->vb_queue_mutex;
>>  
>>  	/* Init videobuf2 queue */
>>  	ret = vb2_queue_init(&sdr->vb_queue);
>
Laurent Pinchart Sept. 9, 2024, 3:02 p.m. UTC | #3
On Mon, Sep 09, 2024 at 04:55:32PM +0200, Hans Verkuil wrote:
> On 09/09/2024 16:51, Laurent Pinchart wrote:
> > On Mon, Sep 02, 2024 at 04:04:52PM +0200, Hans Verkuil wrote:
> >> The vb2_queue_init() will expect the vb2_queue lock pointer to be set in
> >> the future. So for those drivers that set the lock later, move it up to
> >> before the vb2_queue_init() call.
> > 
> > The commit message doesn't match the change below, you're moving the
> > lock down, not up.
> 
> Actually, I am moving it up, as in 'set earlier', but in this case it is
> a bit confusing in the patch.

Oops indeed, I thought both changes were in the same function.

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

> >> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> >> Cc: Ramesh Shanmugasundaram <ramesh.shanmugasundaram@bp.renesas.com>
> >> Cc: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> >> ---
> >>  drivers/media/platform/renesas/rcar_drif.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/media/platform/renesas/rcar_drif.c b/drivers/media/platform/renesas/rcar_drif.c
> >> index f21d05054341..5d3109940ded 100644
> >> --- a/drivers/media/platform/renesas/rcar_drif.c
> >> +++ b/drivers/media/platform/renesas/rcar_drif.c
> >> @@ -1071,7 +1071,6 @@ static int rcar_drif_sdr_register(struct rcar_drif_sdr *sdr)
> >>  	sdr->vdev->release = video_device_release;
> >>  	sdr->vdev->lock = &sdr->v4l2_mutex;
> >>  	sdr->vdev->queue = &sdr->vb_queue;
> >> -	sdr->vdev->queue->lock = &sdr->vb_queue_mutex;
> >>  	sdr->vdev->ctrl_handler = &sdr->ctrl_hdl;
> >>  	sdr->vdev->v4l2_dev = &sdr->v4l2_dev;
> >>  	sdr->vdev->device_caps = V4L2_CAP_SDR_CAPTURE | V4L2_CAP_TUNER |
> >> @@ -1316,6 +1315,7 @@ static int rcar_drif_sdr_probe(struct rcar_drif_sdr *sdr)
> >>  	sdr->vb_queue.ops = &rcar_drif_vb2_ops;
> >>  	sdr->vb_queue.mem_ops = &vb2_vmalloc_memops;
> >>  	sdr->vb_queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> >> +	sdr->vb_queue.lock = &sdr->vb_queue_mutex;
> >>  
> >>  	/* Init videobuf2 queue */
> >>  	ret = vb2_queue_init(&sdr->vb_queue);
diff mbox series

Patch

diff --git a/drivers/media/platform/renesas/rcar_drif.c b/drivers/media/platform/renesas/rcar_drif.c
index f21d05054341..5d3109940ded 100644
--- a/drivers/media/platform/renesas/rcar_drif.c
+++ b/drivers/media/platform/renesas/rcar_drif.c
@@ -1071,7 +1071,6 @@  static int rcar_drif_sdr_register(struct rcar_drif_sdr *sdr)
 	sdr->vdev->release = video_device_release;
 	sdr->vdev->lock = &sdr->v4l2_mutex;
 	sdr->vdev->queue = &sdr->vb_queue;
-	sdr->vdev->queue->lock = &sdr->vb_queue_mutex;
 	sdr->vdev->ctrl_handler = &sdr->ctrl_hdl;
 	sdr->vdev->v4l2_dev = &sdr->v4l2_dev;
 	sdr->vdev->device_caps = V4L2_CAP_SDR_CAPTURE | V4L2_CAP_TUNER |
@@ -1316,6 +1315,7 @@  static int rcar_drif_sdr_probe(struct rcar_drif_sdr *sdr)
 	sdr->vb_queue.ops = &rcar_drif_vb2_ops;
 	sdr->vb_queue.mem_ops = &vb2_vmalloc_memops;
 	sdr->vb_queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+	sdr->vb_queue.lock = &sdr->vb_queue_mutex;
 
 	/* Init videobuf2 queue */
 	ret = vb2_queue_init(&sdr->vb_queue);