Skip to contentSkip to conversation

media: rtl2832_sdr: assign vb2 lock before vb2_queue_init

PATCH New Arthur Marsh 1 participant 1 message Feb 26, 2025 1 message not in the archive Media (V4L/DVB)

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 media: rtl2832_sdr: assign vb2 lock before vb2_queue_init

Quoted 33 lines · Hans Verkuil

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.

Fixes 8fcd2795d22a ("media: rtl2832_sdr: drop vb2_ops_wait_prepare/finish")

---
Arthur, it would be great if you can test this patch!

Regards,

Hans
---

drivers/media/dvb-frontends/rtl2832_sdr.c +1 -0
index 05254d8717db..0357624968f1 100644
@@ -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");

drivers/media/dvb-frontends/rtl2832_sdr.c static int rtl2832_sdr_probe(struct platform_device *pdev) · line 1427

Quoted 7 lines
drivers/media/dvb-frontends/rtl2832_sdr.c +0 -1
@@ -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 */

Hi and thanks, I applied the above patch to kernel 6.14.0-rc4, built and rebooted into the patched kernel, and ran:

dmesg|egrep '(rtl|2832)'
[  396.972457] usb 2-3: dvb_usb_v2: found a 'Realtek RTL2832U reference design' in warm state
[  397.004068] dvbdev: DVB: registering new adapter (Realtek RTL2832U reference design)
[  397.194478] rtl2832 5-0010: Realtek RTL2832 successfully attached [  397.194497] usb 2-3: DVB: registering adapter 0 frontend 0 (Realtek RTL2832 ( DVB-T))...
[  397.194505] dvbdev: dvb_create_media_entity: media entity 'Realtek RTL2832 (D VB-T)' registered.
[  397.822338] rtl2832_sdr rtl2832_sdr.1.auto: Registered as swradio0 [  397.822342] rtl2832_sdr rtl2832_sdr.1.auto: Realtek RTL2832 SDR attached [  397.822343] rtl2832_sdr rtl2832_sdr.1.auto: SDR API is still slightly experim ental and functionality changes may follow
[  397.838919] usb 2-3: dvb_usb_v2: 'Realtek RTL2832U reference design' successf ully initialized and connected
[  397.840353] usbcore: registered new interface driver dvb_usb_rtl28xxu

I haven't used the Software Defined Radio functionality, but was able to successfully view and listen to a DVB-T stream from the RTL2832.

Regards,

Arthur.