linux icon indicating copy to clipboard operation
linux copied to clipboard

imx708: lockdep warnings

Open pobrn opened this issue 8 months ago • 3 comments

Describe the bug

Using 86696c76f473cda363711572fee851c5a3e114ea (was rpi-6.15.y) I get a lot of lockdep warnings when the sensor is used.

One offender is imx708_get_format_code(), which has lockdep_assert_held(&imx708->mutex). The other is __v4l2_ctrl_modify_range(), which has lockdep_assert_held(ctrl->handler->lock).

Steps to reproduce the behaviour

  1. enable lockdep in the kernel
  2. boot with the camera connected (this should already cause some warnings)
  3. run cam -l (from libcamera)

Device (s)

Raspberry Pi 4 Mod. B

System

Linux <hostname> 6.15.0-rc2-v8+ #1 SMP PREEMPT Wed Apr 23 17:55:44 CEST 2025 aarch64 GNU/Linux

Logs

[   17.089543] ------------[ cut here ]------------
[   17.089556] WARNING: CPU: 0 PID: 205 at drivers/media/v4l2-core/v4l2-ctrls-api.c:973 __v4l2_ctrl_modify_range+0x1a0/0x220 [videodev]
[   17.094830] bcm2835-codec bcm2835-codec: Device registered as /dev/video11
[   17.094896] bcm2835-codec bcm2835-codec: Loaded V4L2 encode
[   17.103384] bcm2835-isp bcm2835-isp: Register capture node 3 with media controller
[   17.183807] Modules linked in: cec v3d(+) bcm2835_isp(C+) drm_client_lib bcm2835_codec(C+) bcm2835_v4l2(C) drm_dma_helper gpu_sched imx708(+) dw9807_vcm rpi_hevc_dec drm_shmem_helper snd_soc_core drm_kms_help
er bcm2835_mmal_vchiq(C) bcm2835_unicam_legacy snd_compress vc_sm_cma(C) snd_pcm_dmaengine v4l2_dv_timings v4l2_mem2mem drm v4l2_fwnode v4l2_async snd_bcm2835(C) videobuf2_dma_contig brcmfmac videobuf2_vmalloc videobuf2_memops raspberrypi_hwmon snd_pcm drm_panel_orientation_quirks i2c_mux_pinctrl videobuf2_v4l2 i2c_mux brcmutil snd_timer i2c_brcmstb snd videodev raspberrypi_gpiomem i2c_bcm2835 cfg80211 backlight videobuf2_common mc nvmem_rmem rfkill uio_pdrv_genirq uio sch_fq_codel fuse nfnetlink ipv6
[   17.246412] CPU: 0 UID: 0 PID: 205 Comm: (udev-worker) Tainted: G         C          6.15.0-rc2-v8+ #1 PREEMPT 
[   17.256497] Tainted: [C]=CRAP
[   17.259456] Hardware name: Raspberry Pi 4 Model B Rev 1.5 (DT)
[   17.265281] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   17.272237] pc : __v4l2_ctrl_modify_range+0x1a0/0x220 [videodev]
[   17.278302] lr : __v4l2_ctrl_modify_range+0x19c/0x220 [videodev]
[   17.284341] sp : ffff800081383800
[   17.287648] x29: ffff800081383800 x28: ffff800081383d10 x27: 00000000009e0908
[   17.294784] x26: ffff1e6906ca8020 x25: ffffc25050347770 x24: 0000000000000001
[   17.301920] x23: 00000000237a0800 x22: 00000000237a0800 x21: 00000000237a0800
[   17.309055] x20: ffff1e6902fec080 x19: ffff1e6902cca600 x18: 00000000ffffffff
[   17.316190] x17: ffff5c1939b8e000 x16: ffffc2508132faa8 x15: 0000000000000001
[   17.323324] x14: 0000000000000000 x13: 0000010000000100 x12: ffffc2508241e9f0
[   17.330459] x11: ffffc2508276dc90 x10: ffffc250819b636c x9 : ffffc250503295e0
[   17.337594] x8 : ffff1e6904018000 x7 : ffffc25081a95000 x6 : 0000000000000000
[   17.344728] x5 : 0000000000000001 x4 : 00000000237a0800 x3 : 0000000000000001
[   17.351863] x2 : ffff5c1939b8e000 x1 : 0000000000000000 x0 : 0000000000000000
[   17.358998] Call trace:
[   17.361437]  __v4l2_ctrl_modify_range+0x1a0/0x220 [videodev] (P)
[   17.367479]  imx708_set_framing_limits+0x38/0x90 [imx708]
[   17.372880]  imx708_probe+0x5a8/0x738 [imx708]
[   17.377322]  i2c_device_probe+0x150/0x2c0
[   17.381335]  really_probe+0xc4/0x2d0
[   17.384907]  __driver_probe_device+0x80/0x130
[   17.389259]  driver_probe_device+0x44/0x168
[   17.393437]  __driver_attach+0xa0/0x1c0
[   17.397267]  bus_for_each_dev+0x84/0x100
[   17.401184]  driver_attach+0x2c/0x40
[   17.404753]  bus_add_driver+0xec/0x228
[   17.408497]  driver_register+0x70/0x138
[   17.412328]  i2c_register_driver+0x50/0xe0
[   17.416419]  imx708_i2c_driver_init+0x28/0xff8 [imx708]
[   17.421643]  do_one_initcall+0x88/0x380
[   17.425476]  do_init_module+0x5c/0x230
[   17.429222]  load_module+0x1b68/0x21f8
[   17.432967]  __do_sys_init_module+0x180/0x258
[   17.437319]  __arm64_sys_init_module+0x24/0x40
[   17.441757]  invoke_syscall+0x50/0x120
[   17.445501]  el0_svc_common.constprop.0+0xc8/0xf0
[   17.450200]  do_el0_svc+0x24/0x38
[   17.453509]  el0_svc+0x48/0x110
[   17.456647]  el0t_64_sync_handler+0x10c/0x140
[   17.461000]  el0t_64_sync+0x198/0x1a0
[   17.464656] irq event stamp: 39578
[   17.468050] hardirqs last  enabled at (39577): [<ffffc2508133fddc>] _raw_spin_unlock_irqrestore+0x74/0x80
[   17.477615] hardirqs last disabled at (39578): [<ffffc2508132d034>] el1_dbg+0x24/0x90
[   17.485440] softirqs last  enabled at (39392): [<ffffc250804c8d90>] handle_softirqs+0x448/0x4a0
[   17.494134] softirqs last disabled at (39367): [<ffffc250804102c4>] __do_softirq+0x1c/0x28
[   17.502392] ---[ end trace 0000000000000000 ]---

[0:13:25.636102998] [355]  INFO Camera camera_manager.cpp:326 libcamera v0.5.0+154-c113b0e6-dirty (2025-04-24)
[  806.217218] ------------[ cut here ]------------
[  806.217234] WARNING: CPU: 2 PID: 361 at drivers/media/i2c/imx708.c:979 imx708_get_format_code+0x80/0x90 [imx708]
[  806.232041] Modules linked in: vc4 snd_soc_hdmi_codec drm_exec drm_display_helper cec v3d bcm2835_isp(C) drm_client_lib bcm2835_codec(C) bcm2835_v4l2(C) drm_dma_helper gpu_sched imx708 dw9807_vcm rpi_hevc_dec
 drm_shmem_helper snd_soc_core drm_kms_helper bcm2835_mmal_vchiq(C) bcm2835_unicam_legacy snd_compress vc_sm_cma(C) snd_pcm_dmaengine v4l2_dv_timings v4l2_mem2mem drm v4l2_fwnode v4l2_async snd_bcm2835(C) videob
uf2_dma_contig brcmfmac videobuf2_vmalloc videobuf2_memops raspberrypi_hwmon snd_pcm drm_panel_orientation_quirks i2c_mux_pinctrl videobuf2_v4l2 i2c_mux brcmutil snd_timer i2c_brcmstb snd videodev raspberrypi_gp
iomem i2c_bcm2835 cfg80211 backlight videobuf2_common mc nvmem_rmem rfkill uio_pdrv_genirq uio sch_fq_codel fuse nfnetlink ipv6
[  806.298391] CPU: 2 UID: 0 PID: 361 Comm: cam Tainted: G        WC          6.15.0-rc2-v8+ #1 PREEMPT 
[  806.307608] Tainted: [W]=WARN, [C]=CRAP
[  806.311435] Hardware name: Raspberry Pi 4 Model B Rev 1.5 (DT)
[  806.317260] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[  806.324216] pc : imx708_get_format_code+0x80/0x90 [imx708]
[  806.329699] lr : imx708_get_format_code+0x7c/0x90 [imx708]
[  806.335180] sp : ffff8000812dbb40
[  806.338487] x29: ffff8000812dbb40 x28: 00000000c0305602 x27: 0000000000000000
[  806.345623] x26: 0000000000000000 x25: 0000000000000000 x24: ffff1e6902fec080
[  806.352759] x23: 0000000000000000 x22: 0000000000000000 x21: 0000000000000000
[  806.359894] x20: ffff1e6902fec080 x19: ffff1e6902fec080 x18: 0000000000000000
[  806.367028] x17: 0000000000000000 x16: ffffc2508132faa8 x15: 0000ffff7dbecc80
[  806.374163] x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000
[  806.381297] x11: ffff1e6906e66690 x10: ffffc250819b636c x9 : ffffc25050329560
[  806.388432] x8 : 0000000000000000 x7 : 0000000000000000 x6 : ffff8000812dbcf8
[  806.395566] x5 : ffff1e6902fb0000 x4 : 0000000000000003 x3 : ffffc25050329528
[  806.402700] x2 : ffff5c1939bd4000 x1 : 0000000000000000 x0 : 0000000000000000
[  806.409835] Call trace:
[  806.412274]  imx708_get_format_code+0x80/0x90 [imx708] (P)
[  806.417758]  imx708_enum_mbus_code+0x38/0x80 [imx708]
[  806.422806]  call_enum_mbus_code_state+0x8c/0x130 [videodev]
[  806.428521]  subdev_do_ioctl+0x870/0xd40 [videodev]
[  806.433432]  subdev_do_ioctl_lock+0x1dc/0x230 [videodev]
[  806.438776]  video_usercopy+0x2f4/0x890 [videodev]
[  806.443598]  subdev_ioctl+0x20/0x38 [videodev]
[  806.448073]  v4l2_ioctl+0x48/0x78 [videodev]
[  806.452374]  __arm64_sys_ioctl+0xbc/0x100
[  806.456383]  invoke_syscall+0x50/0x120
[  806.460127]  el0_svc_common.constprop.0+0xc8/0xf0
[  806.464826]  do_el0_svc+0x24/0x38
[  806.468135]  el0_svc+0x48/0x110
[  806.471273]  el0t_64_sync_handler+0x10c/0x140
[  806.475626]  el0t_64_sync+0x198/0x1a0
[  806.479283] irq event stamp: 93050
[  806.482676] hardirqs last  enabled at (93049): [<ffffc250805bbcac>] ktime_get_coarse_real_ts64+0x104/0x128
[  806.492329] hardirqs last disabled at (93050): [<ffffc2508132d034>] el1_dbg+0x24/0x90
[  806.500155] softirqs last  enabled at (92902): [<ffffc250804c8d90>] handle_softirqs+0x448/0x4a0
[  806.508849] softirqs last disabled at (92895): [<ffffc250804102c4>] __do_softirq+0x1c/0x28
[  806.517107] ---[ end trace 0000000000000000 ]---

Additional context

No response

pobrn avatar Apr 24 '25 15:04 pobrn

Agreed. We don't tend to run with lockdep enabled, and it isn't in our standard defconfigs.

imx477 has the same issue in enum_mbus_code and enum_frame_size not taking the mutex.

I'll fix both up.

6by9 avatar Apr 24 '25 15:04 6by9

See #6813

6by9 avatar Apr 24 '25 16:04 6by9

See #6813

I can't see any more warnings related to this. Thanks!

pobrn avatar Apr 25 '25 15:04 pobrn