Re: [BUG] removing and reinserting imx-media causes kernel to explode
On 8/14/19 2:25 AM, Russell King - ARM Linux admin wrote: I just did this: rmmod imx-media modprobe imx-media and was greeted by the below kernel messages. Yes this needs fixing, the CSI needs to check first that it is already registered before going through the ->registered() steps. Posting a patch. I don't think this has been the first issue I found with the iMX media stuff involving a module unload/reload cycle - may I suggest that this is added to the testing regime for this code? Thanks. I do test module unload/reload cycles, but v4l2-async does not support re-registering subdevices unless the subdevice is basically completely removed and re-probed, so there won't be a working media device if only imx-media is reloaded. So I have always unloaded/reloaded all modules for every entity in the graph, i.e.: rmmod imx6_media imx6_media_csi imx6_mipi_csi2 ov5640 video_mux imx_media_common (replace ov5640 with your imx219 sensor). But I'll make sure to test single module unload/reload cycles in the future. But note after applying the patch mentioned above to CSI ->registered() callback, there are list corruption backtraces, see [1]. The root cause is that both media_device_register_entity() and media_entity_pads_init() add the same graph objects for the entity's pads, so duplicate pad objects are added to the media device pads list. Removing the pad object creation in media_device_register_entity() fixes the list corruption. Sending a patch for that also. This is a problem for any entity that sets its ->num_pads to a non-zero value before media_device_register_entity() is called. For example, the following will produce the same list corruption backtrace: rmmod video-mux modprobe video-mux rmmod video-mux Steve [1] rmmod imx6-media modprobe imx6-media rmmod imx6-media [ 249.387953] WARNING: CPU: 2 PID: 843 at lib/list_debug.c:53 __list_del_entry_valid+0xa0/0xdc [ 249.396442] list_del corruption. prev->next should be e8fb0510, but was e93b5914 [ 249.404076] Modules linked in: imx6_media_csi(C) imx6_media(C-) imx6_mipi_csi2(C) bnep dw_hdmi_ahb_audio dw_hdmi_cec ov5640 mux_mmio video_mux mux_core dw_hdmi_imx dw_hdmi coda_vpu cec imx_vdoa videobuf2_vmalloc imx_media_common(C) v4l2_fwnode imx_ldb imxdrm imx_ipu_v3 [last unloaded: imx6_media_csi] [ 249.430956] CPU: 2 PID: 843 Comm: rmmod Tainted: G C 5.3.0-rc4-01115-g62119fd20fda #5 [ 249.440115] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree) [ 249.446689] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 249.454462] [] (show_stack) from [] (dump_stack+0xd8/0x110) [ 249.461804] [] (dump_stack) from [] (__warn+0xe0/0x10c) [ 249.468789] [] (__warn) from [] (warn_slowpath_fmt+0x44/0x6c) [ 249.476301] [] (warn_slowpath_fmt) from [] (__list_del_entry_valid+0xa0/0xdc) [ 249.485207] [] (__list_del_entry_valid) from [] (media_gobj_destroy.part.4+0x30/0x64) [ 249.494802] [] (media_gobj_destroy.part.4) from [] (__media_device_unregister_entity+0xa8/0xcc) [ 249.505259] [] (__media_device_unregister_entity) from [] (media_device_unregister_entity+0x2c/0x38) [ 249.516157] [] (media_device_unregister_entity) from [] (v4l2_device_unregister_subdev+0x90/0xb4) [ 249.526793] [] (v4l2_device_unregister_subdev) from [] (v4l2_async_cleanup+0x10/0x3c) [ 249.536382] [] (v4l2_async_cleanup) from [] (v4l2_async_notifier_unbind_all_subdevs+0x9c/0x10c) [ 249.546840] [] (v4l2_async_notifier_unbind_all_subdevs) from [] (v4l2_async_notifier_unbind_all_subdevs+0x6c/0x10c) [ 249.559035] [] (v4l2_async_notifier_unbind_all_subdevs) from [] (__v4l2_async_notifier_unregister.part.4+0xc/0x44) [ 249.571140] [] (__v4l2_async_notifier_unregister.part.4) from [] (v4l2_async_notifier_unregister+0x30/0x50) [ 249.582665] [] (v4l2_async_notifier_unregister) from [] (imx_media_remove+0x20/0x54 [imx6_media]) [ 249.593389] [] (imx_media_remove [imx6_media]) from [] (platform_drv_remove+0x20/0x40) [ 249.603068] [] (platform_drv_remove) from [] (device_release_driver_internal+0xdc/0x1ac) [ 249.612917] [] (device_release_driver_internal) from [] (driver_detach+0x44/0x80) [ 249.622164] [] (driver_detach) from [] (bus_remove_driver+0x5c/0xd8) [ 249.630287] [] (bus_remove_driver) from [] (sys_delete_module+0x17c/0x20c) [ 249.638926] [] (sys_delete_module) from [] (ret_fast_syscall+0x0/0x28) [ 249.647205] Exception stack(0xe90d5fa8 to 0xe90d5ff0) [ 249.652278] 5fa0: beed5d6c 0003 01401134 0800 4f13b6f4 2002 [ 249.660475] 5fc0: beed5d6c 0003 beed5b80 0081 beed5e78 0001 014010f8 [ 249.668669] 5fe0: 0003b2c4 beed5b4c 0001f248 4f1012dc [ 249.673859] irq event stamp: 4113 [ 249.677267] hardirqs last enabled at (4131): [] console_unlock+0x408/0x5f8 [ 249.685125] hardirqs last disabled at (4138): [] console_unlock+0x88/0x5f8 [ 249.692970] softirqs last enabled at (4154): [] __do_softirq+0x360/0x524 [ 249.700735] softirqs last disabled at
[BUG] removing and reinserting imx-media causes kernel to explode
I just did this: rmmod imx-media modprobe imx-media and was greeted by the below kernel messages. I don't think this has been the first issue I found with the iMX media stuff involving a module unload/reload cycle - may I suggest that this is added to the testing regime for this code? Thanks. imx-media: Removing imx-media ipu1_vdic: Removing ipu1_ic_prp: Removing ipu1_ic_prpenc: Removing ipu1_ic_prpvf: Removing ipu2_vdic: Removing ipu2_ic_prp: Removing ipu2_ic_prpenc: Removing ipu2_ic_prpvf: Removing imx_media: module is from the staging directory, the quality is unknown, you have been warned. ipu2_ic_prpvf: Registered ipu2_ic_prpvf capture as /dev/video2 imx-media: subdev ipu2_ic_prpvf bound ipu2_ic_prpenc: Registered ipu2_ic_prpenc capture as /dev/video3 imx-media: subdev ipu2_ic_prpenc bound imx-media: subdev ipu2_ic_prp bound imx-media: subdev ipu2_vdic bound ipu1_ic_prpvf: Registered ipu1_ic_prpvf capture as /dev/video4 imx-media: subdev ipu1_ic_prpvf bound ipu1_ic_prpenc: Registered ipu1_ic_prpenc capture as /dev/video5 imx-media: subdev ipu1_ic_prpenc bound imx-media: subdev ipu1_ic_prp bound imx-media: subdev ipu1_vdic bound kobject (ddca68f0): tried to init an initialized object, something is seriously wrong. CPU: 1 PID: 31521 Comm: modprobe Tainted: G C5.2.0+ #325 Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree) [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (dump_stack+0x9c/0xd4) [] (dump_stack) from [] (kobject_init+0x74/0x94) [] (kobject_init) from [] (device_initialize+0x1c/0xec) [] (device_initialize) from [] (device_register+0xc/0x18) [] (device_register) from [] (__video_register_device+0x9b4/0x1228) [] (__video_register_device) from [] (imx_media_capture_device_register+0x44/0x1f4 [imx_media_capture]) [] (imx_media_capture_device_register [imx_media_capture]) from [] (csi_registered+0x154/0x19c [imx_media_csi]) [] (csi_registered [imx_media_csi]) from [] (v4l2_device_register_subdev+0xd0/0x164) [] (v4l2_device_register_subdev) from [] (v4l2_async_match_notify+0x1c/0x130) [] (v4l2_async_match_notify) from [] (v4l2_async_notifier_try_all_subdevs+0x48/0x94) [] (v4l2_async_notifier_try_all_subdevs) from [] (__v4l2_async_notifier_register+0xa8/0x110) [] (__v4l2_async_notifier_register) from [] (v4l2_async_notifier_register+0x3c/0x54) [] (v4l2_async_notifier_register) from [] (imx_media_dev_notifier_register+0x2c/0x70 [imx_media]) [] (imx_media_dev_notifier_register [imx_media]) from [] (imx_media_probe+0x3c/0x8c [imx_media]) [] (imx_media_probe [imx_media]) from [] (platform_drv_probe+0x48/0x98) [] (platform_drv_probe) from [] (really_probe+0x1d8/0x2c0) [] (really_probe) from [] (driver_probe_device+0x5c/0x174) [] (driver_probe_device) from [] (device_driver_attach+0x58/0x60) [] (device_driver_attach) from [] (__driver_attach+0x84/0xc0) [] (__driver_attach) from [] (bus_for_each_dev+0x58/0x7c) [] (bus_for_each_dev) from [] (bus_add_driver+0xd0/0x1cc) [] (bus_add_driver) from [] (driver_register+0x7c/0x110) [] (driver_register) from [] (do_one_initcall+0x74/0x308) [] (do_one_initcall) from [] (do_init_module+0x5c/0x1f4) [] (do_init_module) from [] (load_module+0x19a4/0x2020) [] (load_module) from [] (sys_finit_module+0x8c/0x98) [] (sys_finit_module) from [] (ret_fast_syscall+0x0/0x28) Exception stack(0xdb677fa8 to 0xdb677ff0) 7fa0: 00b04170 0003 007bd84c 00b05cb8 7fc0: 00b04170 1ee84500 017b 0004 00b04eb8 7fe0: be958178 be958168 007b54bb b6c28712 ipu1_csi0: Registered ipu1_csi0 capture as /dev/video6 imx-media: subdev ipu1_csi0 bound kobject (dcd780f0): tried to init an initialized object, something is seriously wrong. CPU: 1 PID: 31521 Comm: modprobe Tainted: G C5.2.0+ #325 Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree) [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (dump_stack+0x9c/0xd4) [] (dump_stack) from [] (kobject_init+0x74/0x94) [] (kobject_init) from [] (device_initialize+0x1c/0xec) [] (device_initialize) from [] (device_register+0xc/0x18) [] (device_register) from [] (__video_register_device+0x9b4/0x1228) [] (__video_register_device) from [] (imx_media_capture_device_register+0x44/0x1f4 [imx_media_capture]) [] (imx_media_capture_device_register [imx_media_capture]) from [] (csi_registered+0x154/0x19c [imx_media_csi]) [] (csi_registered [imx_media_csi]) from [] (v4l2_device_register_subdev+0xd0/0x164) [] (v4l2_device_register_subdev) from [] (v4l2_async_match_notify+0x1c/0x130) [] (v4l2_async_match_notify) from [] (v4l2_async_notifier_try_all_subdevs+0x48/0x94) [] (v4l2_async_notifier_try_all_subdevs) from [] (__v4l2_async_notifier_register+0xa8/0x110) [] (__v4l2_async_notifier_register) from [] (v4l2_async_notifier_register+0x3c/0x54) [] (v4l2_async_notifier_register) from [] (imx_media_dev_notifier_register+0x2c/0x70 [imx_media]) [] (imx_media_dev_notifier_register