* [PATCH for v6.14] media: rtl2832_sdr: assign vb2 lock before vb2_queue_init
@ 2025-02-24 14:40 Hans Verkuil
2025-03-03 1:10 ` Arthur Marsh
2025-03-12 15:39 ` Mauro Carvalho Chehab
0 siblings, 2 replies; 3+ messages in thread
From: Hans Verkuil @ 2025-02-24 14:40 UTC (permalink / raw)
To: Linux Media Mailing List; +Cc: Arthur Marsh
Commit c780d01cf1a6 ("media: vb2: vb2_core_queue_init(): sanity check lock and
wait_prepare/finish") added a sanity check to ensure that if there are no
wait_prepare/finish callbacks set by the driver, then the vb2_queue lock must
be set, since otherwise the vb2 core cannot do correct locking.
The rtl2832_sdr.c triggered this warning: it turns out that while the driver
does set this lock, it sets it too late. So move it up to before the
vb2_queue_init() call.
Reported-by: Arthur Marsh <arthur.marsh@internode.on.net>
Fixes: 8fcd2795d22a ("media: rtl2832_sdr: drop vb2_ops_wait_prepare/finish")
Cc: stable@vger.kernel.org
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
---
Arthur, it would be great if you can test this patch!
Regards,
Hans
---
diff --git a/drivers/media/dvb-frontends/rtl2832_sdr.c b/drivers/media/dvb-frontends/rtl2832_sdr.c
index 05254d8717db..0357624968f1 100644
--- a/drivers/media/dvb-frontends/rtl2832_sdr.c
+++ b/drivers/media/dvb-frontends/rtl2832_sdr.c
@@ -1363,6 +1363,7 @@ static int rtl2832_sdr_probe(struct platform_device *pdev)
dev->vb_queue.ops = &rtl2832_sdr_vb2_ops;
dev->vb_queue.mem_ops = &vb2_vmalloc_memops;
dev->vb_queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+ dev->vb_queue.lock = &dev->vb_queue_lock;
ret = vb2_queue_init(&dev->vb_queue);
if (ret) {
dev_err(&pdev->dev, "Could not initialize vb2 queue\n");
@@ -1421,7 +1422,6 @@ static int rtl2832_sdr_probe(struct platform_device *pdev)
/* Init video_device structure */
dev->vdev = rtl2832_sdr_template;
dev->vdev.queue = &dev->vb_queue;
- dev->vdev.queue->lock = &dev->vb_queue_lock;
video_set_drvdata(&dev->vdev, dev);
/* Register the v4l2_device structure */
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH for v6.14] media: rtl2832_sdr: assign vb2 lock before vb2_queue_init
2025-02-24 14:40 [PATCH for v6.14] media: rtl2832_sdr: assign vb2 lock before vb2_queue_init Hans Verkuil
@ 2025-03-03 1:10 ` Arthur Marsh
2025-03-12 15:39 ` Mauro Carvalho Chehab
1 sibling, 0 replies; 3+ messages in thread
From: Arthur Marsh @ 2025-03-03 1:10 UTC (permalink / raw)
To: Hans Verkuil, Linux Media Mailing List
On 25/2/25 01:10, Hans Verkuil wrote:
> Commit c780d01cf1a6 ("media: vb2: vb2_core_queue_init(): sanity check lock and
> wait_prepare/finish") added a sanity check to ensure that if there are no
> wait_prepare/finish callbacks set by the driver, then the vb2_queue lock must
> be set, since otherwise the vb2 core cannot do correct locking.
>
> The rtl2832_sdr.c triggered this warning: it turns out that while the driver
> does set this lock, it sets it too late. So move it up to before the
> vb2_queue_init() call.
>
> Reported-by: Arthur Marsh <arthur.marsh@internode.on.net>
> Fixes: 8fcd2795d22a ("media: rtl2832_sdr: drop vb2_ops_wait_prepare/finish")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
> ---
> Arthur, it would be great if you can test this patch!
>
> Regards,
>
> Hans
> ---
> diff --git a/drivers/media/dvb-frontends/rtl2832_sdr.c b/drivers/media/dvb-frontends/rtl2832_sdr.c
> index 05254d8717db..0357624968f1 100644
> --- a/drivers/media/dvb-frontends/rtl2832_sdr.c
> +++ b/drivers/media/dvb-frontends/rtl2832_sdr.c
> @@ -1363,6 +1363,7 @@ static int rtl2832_sdr_probe(struct platform_device *pdev)
> dev->vb_queue.ops = &rtl2832_sdr_vb2_ops;
> dev->vb_queue.mem_ops = &vb2_vmalloc_memops;
> dev->vb_queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + dev->vb_queue.lock = &dev->vb_queue_lock;
> ret = vb2_queue_init(&dev->vb_queue);
> if (ret) {
> dev_err(&pdev->dev, "Could not initialize vb2 queue\n");
> @@ -1421,7 +1422,6 @@ static int rtl2832_sdr_probe(struct platform_device *pdev)
> /* Init video_device structure */
> dev->vdev = rtl2832_sdr_template;
> dev->vdev.queue = &dev->vb_queue;
> - dev->vdev.queue->lock = &dev->vb_queue_lock;
> video_set_drvdata(&dev->vdev, dev);
>
> /* Register the v4l2_device structure */
I was able to successfully test this patch with DVB-T functionality but
haven't tested it with SDR functionality:
[ 15.946588] usb 1-6: dvb_usb_v2: found a 'Realtek RTL2832U reference
design' in warm state
[ 16.016516] dvbdev: DVB: registering new adapter (Realtek RTL2832U
reference design)
[ 16.122916] rtl2832 3-0010: Realtek RTL2832 successfully attached
[ 16.122931] usb 1-6: DVB: registering adapter 0 frontend 0 (Realtek
RTL2832 (DVB-T))...
[ 16.122938] dvbdev: dvb_create_media_entity: media entity 'Realtek
RTL2832 (DVB-T)' registered.
[ 16.417228] rtl2832_sdr rtl2832_sdr.1.auto: Registered as swradio0
[ 16.417231] rtl2832_sdr rtl2832_sdr.1.auto: Realtek RTL2832 SDR attached
[ 16.417232] rtl2832_sdr rtl2832_sdr.1.auto: SDR API is still slightly
experimental and functionality changes may follow
[ 16.453096] usb 1-6: dvb_usb_v2: 'Realtek RTL2832U reference design'
successfully initialized and connected
Regards,
Arthur.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH for v6.14] media: rtl2832_sdr: assign vb2 lock before vb2_queue_init
2025-02-24 14:40 [PATCH for v6.14] media: rtl2832_sdr: assign vb2 lock before vb2_queue_init Hans Verkuil
2025-03-03 1:10 ` Arthur Marsh
@ 2025-03-12 15:39 ` Mauro Carvalho Chehab
1 sibling, 0 replies; 3+ messages in thread
From: Mauro Carvalho Chehab @ 2025-03-12 15:39 UTC (permalink / raw)
To: Hans Verkuil; +Cc: Linux Media Mailing List, Arthur Marsh
Em Mon, 24 Feb 2025 15:40:58 +0100
Hans Verkuil <hverkuil@xs4all.nl> escreveu:
> Commit c780d01cf1a6 ("media: vb2: vb2_core_queue_init(): sanity check lock and
> wait_prepare/finish") added a sanity check to ensure that if there are no
> wait_prepare/finish callbacks set by the driver, then the vb2_queue lock must
> be set, since otherwise the vb2 core cannot do correct locking.
>
> The rtl2832_sdr.c triggered this warning: it turns out that while the driver
> does set this lock, it sets it too late. So move it up to before the
> vb2_queue_init() call.
>
> Reported-by: Arthur Marsh <arthur.marsh@internode.on.net>
> Fixes: 8fcd2795d22a ("media: rtl2832_sdr: drop vb2_ops_wait_prepare/finish")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Patch looks good to me. As Arthur already tested, it sounds ready to go.
Feel free to pick it and merge if you want:
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Otherwise, I'll try to do it later this week.
> ---
> Arthur, it would be great if you can test this patch!
>
> Regards,
>
> Hans
> ---
> diff --git a/drivers/media/dvb-frontends/rtl2832_sdr.c b/drivers/media/dvb-frontends/rtl2832_sdr.c
> index 05254d8717db..0357624968f1 100644
> --- a/drivers/media/dvb-frontends/rtl2832_sdr.c
> +++ b/drivers/media/dvb-frontends/rtl2832_sdr.c
> @@ -1363,6 +1363,7 @@ static int rtl2832_sdr_probe(struct platform_device *pdev)
> dev->vb_queue.ops = &rtl2832_sdr_vb2_ops;
> dev->vb_queue.mem_ops = &vb2_vmalloc_memops;
> dev->vb_queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
> + dev->vb_queue.lock = &dev->vb_queue_lock;
> ret = vb2_queue_init(&dev->vb_queue);
> if (ret) {
> dev_err(&pdev->dev, "Could not initialize vb2 queue\n");
> @@ -1421,7 +1422,6 @@ static int rtl2832_sdr_probe(struct platform_device *pdev)
> /* Init video_device structure */
> dev->vdev = rtl2832_sdr_template;
> dev->vdev.queue = &dev->vb_queue;
> - dev->vdev.queue->lock = &dev->vb_queue_lock;
> video_set_drvdata(&dev->vdev, dev);
>
> /* Register the v4l2_device structure */
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-12 15:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-24 14:40 [PATCH for v6.14] media: rtl2832_sdr: assign vb2 lock before vb2_queue_init Hans Verkuil
2025-03-03 1:10 ` Arthur Marsh
2025-03-12 15:39 ` Mauro Carvalho Chehab
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.