irq lock inversion detected
When testing the rk3588
branch with HEAD at commit ca520a6f and adding the CONFIG_PROVE_LOCKING=y config options to defconfig, I get an IRQ lock inversion splat from regmap_lock_spinlock
:
[ 119.308236] ========================================================
[ 119.308239] WARNING: possible irq lock inversion dependency detected
[ 119.308243] 6.12.0-rc1+ #2 Not tainted
[ 119.308248] --------------------------------------------------------
[ 119.308250] swapper/0/0 just changed the state of lock:
[ 119.308255] ffff6776cb475818 (rockchip_drm_vop2:3686:(&vop2_regmap_config)->lock){-...}-{2:2}, at: regmap_lock_spinlock+0x18/0x38
[ 119.308283] but this lock took another, HARDIRQ-unsafe lock in the past:
[ 119.308286] (&mt->ma_lock){+.+.}-{2:2}
[ 119.308294]
[ 119.308294]
[ 119.308294] and interrupts could create inverse lock ordering between them.
[ 119.308294]
[ 119.308297]
[ 119.308297] other info that might help us debug this:
[ 119.308300] Possible interrupt unsafe locking scenario:
[ 119.308300]
[ 119.308302] CPU0 CPU1
[ 119.308304] ---- ----
[ 119.308307] lock(&mt->ma_lock);
[ 119.308313] local_irq_disable();
[ 119.308316] lock(rockchip_drm_vop2:3686:(&vop2_regmap_config)->lock);
[ 119.308322] lock(&mt->ma_lock);
[ 119.308328] <Interrupt>
[ 119.308330] lock(rockchip_drm_vop2:3686:(&vop2_regmap_config)->lock);
[ 119.308337]
[ 119.308337] *** DEADLOCK ***
[ 119.308337]
[ 119.308339] no locks held by swapper/0/0.
[ 119.308343]
[ 119.308343] the shortest dependencies between 2nd lock and 1st lock:
[ 119.308348] -> (&mt->ma_lock){+.+.}-{2:2} {
[ 119.308360] HARDIRQ-ON-W at:
[ 119.308365] lock_acquire+0x188/0x33c
[ 119.308377] _raw_spin_lock+0x48/0x60
[ 119.308386] regcache_maple_write+0x1f8/0x330
[ 119.308394] regcache_write+0x68/0x80
[ 119.308400] _regmap_read+0x174/0x1dc
[ 119.308407] _regmap_update_bits+0xf4/0x13c
[ 119.308412] regmap_update_bits_base+0x64/0xa0
[ 119.308419] rk8xx_probe+0x16c/0x400
[ 119.308428] rk8xx_spi_probe+0x54/0x88
[ 119.308437] spi_probe+0x84/0xe4
[ 119.308444] really_probe+0xbc/0x2c0
[ 119.308453] __driver_probe_device+0x78/0x120
[ 119.308460] driver_probe_device+0x3c/0x160
[ 119.308467] __device_attach_driver+0xb8/0x140
[ 119.308474] bus_for_each_drv+0x88/0xe8
[ 119.308481] __device_attach+0xa0/0x198
[ 119.308488] device_initial_probe+0x14/0x20
[ 119.308495] bus_probe_device+0xb4/0xc0
[ 119.308501] deferred_probe_work_func+0x90/0xcc
[ 119.308508] process_one_work+0x214/0x640
[ 119.308517] worker_thread+0x1c0/0x358
[ 119.308523] kthread+0x11c/0x120
[ 119.308530] ret_from_fork+0x10/0x20
[ 119.308538] SOFTIRQ-ON-W at:
[ 119.308543] lock_acquire+0x188/0x33c
[ 119.308551] _raw_spin_lock+0x48/0x60
[ 119.308558] regcache_maple_write+0x1f8/0x330
[ 119.308564] regcache_write+0x68/0x80
[ 119.308570] _regmap_read+0x174/0x1dc
[ 119.308576] _regmap_update_bits+0xf4/0x13c
[ 119.308582] regmap_update_bits_base+0x64/0xa0
[ 119.308588] rk8xx_probe+0x16c/0x400
[ 119.308596] rk8xx_spi_probe+0x54/0x88
[ 119.308604] spi_probe+0x84/0xe4
[ 119.308611] really_probe+0xbc/0x2c0
[ 119.308617] __driver_probe_device+0x78/0x120
[ 119.308624] driver_probe_device+0x3c/0x160
[ 119.308631] __device_attach_driver+0xb8/0x140
[ 119.308638] bus_for_each_drv+0x88/0xe8
[ 119.308645] __device_attach+0xa0/0x198
[ 119.308652] device_initial_probe+0x14/0x20
[ 119.308659] bus_probe_device+0xb4/0xc0
[ 119.308665] deferred_probe_work_func+0x90/0xcc
[ 119.308672] process_one_work+0x214/0x640
[ 119.308679] worker_thread+0x1c0/0x358
[ 119.308685] kthread+0x11c/0x120
[ 119.308691] ret_from_fork+0x10/0x20
[ 119.308697] INITIAL USE at:
[ 119.308703] lock_acquire+0x188/0x33c
[ 119.308711] _raw_spin_lock+0x48/0x60
[ 119.308718] regcache_maple_write+0x1f8/0x330
[ 119.308725] regcache_write+0x68/0x80
[ 119.308731] _regmap_read+0x174/0x1dc
[ 119.308736] _regmap_update_bits+0xf4/0x13c
[ 119.308742] regmap_update_bits_base+0x64/0xa0
[ 119.308748] rk8xx_probe+0x16c/0x400
[ 119.308756] rk8xx_spi_probe+0x54/0x88
[ 119.308764] spi_probe+0x84/0xe4
[ 119.308771] really_probe+0xbc/0x2c0
[ 119.308778] __driver_probe_device+0x78/0x120
[ 119.308785] driver_probe_device+0x3c/0x160
[ 119.308791] __device_attach_driver+0xb8/0x140
[ 119.308798] bus_for_each_drv+0x88/0xe8
[ 119.308805] __device_attach+0xa0/0x198
[ 119.308811] device_initial_probe+0x14/0x20
[ 119.308818] bus_probe_device+0xb4/0xc0
[ 119.308825] deferred_probe_work_func+0x90/0xcc
[ 119.308832] process_one_work+0x214/0x640
[ 119.308839] worker_thread+0x1c0/0x358
[ 119.308845] kthread+0x11c/0x120
[ 119.308851] ret_from_fork+0x10/0x20
[ 119.308857] }
[ 119.308860] ... key at: [<ffffb014f3189b90>] __key.0+0x0/0x10
[ 119.308869] ... acquired at:
[ 119.308872] _raw_spin_lock+0x48/0x60
[ 119.308879] regcache_maple_write+0x1f8/0x330
[ 119.308886] regcache_write+0x68/0x80
[ 119.308892] _regmap_read+0x174/0x1dc
[ 119.308897] _regmap_update_bits+0xf4/0x13c
[ 119.308903] regmap_field_update_bits_base+0x6c/0xa0
[ 119.308910] vop2_plane_atomic_update+0x1178/0x1480 [rockchipdrm]
[ 119.308951] drm_atomic_helper_commit_planes+0xf4/0x308 [drm_kms_helper]
[ 119.309006] drm_atomic_helper_commit_tail_rpm+0x60/0xa0 [drm_kms_helper]
[ 119.309057] commit_tail+0xa0/0x1a0 [drm_kms_helper]
[ 119.309107] drm_atomic_helper_commit+0x1a8/0x1d0 [drm_kms_helper]
[ 119.309158] drm_atomic_commit+0xb8/0x100 [drm]
[ 119.309290] drm_client_modeset_commit_atomic+0x258/0x2d0 [drm]
[ 119.309415] drm_client_modeset_commit_locked+0x60/0x1b0 [drm]
[ 119.309543] drm_client_modeset_commit+0x2c/0x54 [drm]
[ 119.309671] __drm_fb_helper_restore_fbdev_mode_unlocked+0xa8/0xe8 [drm_kms_helper]
[ 119.309728] drm_fb_helper_set_par+0x30/0x54 [drm_kms_helper]
[ 119.309782] fbcon_init+0x3c0/0x524
[ 119.309791] visual_init+0xa8/0x100
[ 119.309800] do_bind_con_driver.isra.0+0x1c8/0x370
[ 119.309809] do_take_over_console+0x1a4/0x200
[ 119.309817] do_fbcon_takeover+0x6c/0xe0
[ 119.309824] fbcon_fb_registered+0x1dc/0x1e0
[ 119.309832] do_register_framebuffer+0x194/0x23c
[ 119.309838] register_framebuffer+0x30/0x54
[ 119.309844] __drm_fb_helper_initial_config_and_unlock+0x300/0x50c [drm_kms_helper]
[ 119.309896] drm_fb_helper_hotplug_event+0xf8/0xfc [drm_kms_helper]
[ 119.309948] drm_fbdev_dma_client_hotplug+0x24/0xd8 [drm_dma_helper]
[ 119.309964] drm_client_dev_hotplug+0xcc/0x130 [drm]
[ 119.310092] drm_helper_hpd_irq_event+0x140/0x150 [drm_kms_helper]
[ 119.310145] dw_hdmi_qp_rk3588_hpd_work+0x24/0x58 [rockchipdrm]
[ 119.310181] process_one_work+0x214/0x640
[ 119.310191] worker_thread+0x1c0/0x358
[ 119.310198] kthread+0x11c/0x120
[ 119.310204] ret_from_fork+0x10/0x20
[ 119.310211]
[ 119.310214] -> (rockchip_drm_vop2:3686:(&vop2_regmap_config)->lock){-...}-{2:2} {
[ 119.310229] IN-HARDIRQ-W at:
[ 119.310234] lock_acquire+0x188/0x33c
[ 119.310245] _raw_spin_lock_irqsave+0x60/0x88
[ 119.310254] regmap_lock_spinlock+0x18/0x38
[ 119.310263] regmap_read+0x3c/0x80
[ 119.310269] vop2_isr+0x90/0x2c0 [rockchipdrm]
[ 119.310297] __handle_irq_event_percpu+0x90/0x310
[ 119.310306] handle_irq_event+0x4c/0xc0
[ 119.310313] handle_fasteoi_irq+0xa0/0x1bc
[ 119.310323] generic_handle_domain_irq+0x2c/0x44
[ 119.310330] gic_handle_irq+0x4c/0x120
[ 119.310336] call_on_irq_stack+0x24/0x54
[ 119.310343] do_interrupt_handler+0x80/0x84
[ 119.310351] el1_interrupt+0x34/0x64
[ 119.310359] el1h_64_irq_handler+0x18/0x24
[ 119.310366] el1h_64_irq+0x64/0x68
[ 119.310372] cpuidle_enter_state+0x12c/0x678
[ 119.310380] cpuidle_enter+0x38/0x50
[ 119.310388] do_idle+0x200/0x280
[ 119.310395] cpu_startup_entry+0x34/0x3c
[ 119.310402] rest_init+0x174/0x180
[ 119.310409] console_on_rootfs+0x0/0x6c
[ 119.310419] __primary_switched+0x80/0x88
[ 119.310427] INITIAL USE at:
[ 119.310432] lock_acquire+0x188/0x33c
[ 119.310441] _raw_spin_lock_irqsave+0x60/0x88
[ 119.310448] regmap_lock_spinlock+0x18/0x38
[ 119.310456] regcache_init+0x1cc/0x46c
[ 119.310463] __regmap_init+0x8b0/0xe00
[ 119.310468] __devm_regmap_init+0x78/0xc8
[ 119.310474] __devm_regmap_init_mmio_clk+0x84/0xb4
[ 119.310482] vop2_bind+0xf0/0xd14 [rockchipdrm]
[ 119.310509] component_bind_all+0x100/0x23c
[ 119.310518] rockchip_drm_bind+0xb0/0x200 [rockchipdrm]
[ 119.310545] try_to_bring_up_aggregate_device+0x16c/0x1e0
[ 119.310553] component_master_add_with_match+0xb0/0xec
[ 119.310561] rockchip_drm_platform_probe+0x184/0x298 [rockchipdrm]
[ 119.310588] platform_probe+0x68/0xdc
[ 119.310596] really_probe+0xbc/0x2c0
[ 119.310603] __driver_probe_device+0x78/0x120
[ 119.310610] driver_probe_device+0x3c/0x160
[ 119.310617] __device_attach_driver+0xb8/0x140
[ 119.310624] bus_for_each_drv+0x88/0xe8
[ 119.310631] __device_attach+0xa0/0x198
[ 119.310638] device_initial_probe+0x14/0x20
[ 119.310645] bus_probe_device+0xb4/0xc0
[ 119.310651] deferred_probe_work_func+0x90/0xcc
[ 119.310658] process_one_work+0x214/0x640
[ 119.310666] worker_thread+0x1c0/0x358
[ 119.310672] kthread+0x11c/0x120
[ 119.310678] ret_from_fork+0x10/0x20
[ 119.310684] }
[ 119.310687] ... key at: [<ffffb014d08751d8>] _key.6+0x0/0xffffffffffffce28 [rockchipdrm]
[ 119.310716] ... acquired at:
[ 119.310718] __lock_acquire+0xfcc/0x21a8
[ 119.310727] lock_acquire+0x188/0x33c
[ 119.310735] _raw_spin_lock_irqsave+0x60/0x88
[ 119.310742] regmap_lock_spinlock+0x18/0x38
[ 119.310750] regmap_read+0x3c/0x80
[ 119.310756] vop2_isr+0x90/0x2c0 [rockchipdrm]
[ 119.310782] __handle_irq_event_percpu+0x90/0x310
[ 119.310790] handle_irq_event+0x4c/0xc0
[ 119.310798] handle_fasteoi_irq+0xa0/0x1bc
[ 119.310806] generic_handle_domain_irq+0x2c/0x44
[ 119.310814] gic_handle_irq+0x4c/0x120
[ 119.310819] call_on_irq_stack+0x24/0x54
[ 119.310826] do_interrupt_handler+0x80/0x84
[ 119.310833] el1_interrupt+0x34/0x64
[ 119.310841] el1h_64_irq_handler+0x18/0x24
[ 119.310848] el1h_64_irq+0x64/0x68
[ 119.310853] cpuidle_enter_state+0x12c/0x678
[ 119.310861] cpuidle_enter+0x38/0x50
[ 119.310868] do_idle+0x200/0x280
[ 119.310874] cpu_startup_entry+0x34/0x3c
[ 119.310880] rest_init+0x174/0x180
[ 119.310888] console_on_rootfs+0x0/0x6c
[ 119.310895] __primary_switched+0x80/0x88
[ 119.310902]
[ 119.310904]
[ 119.310904] stack backtrace:
[ 119.310909] CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Not tainted 6.12.0-rc1+ #2
[ 119.310918] Hardware name: Radxa ROCK 5B (DT)
[ 119.310922] Call trace:
[ 119.310925] dump_backtrace.part.0+0xd8/0xe4
[ 119.310932] show_stack+0x18/0x24
[ 119.310938] dump_stack_lvl+0x70/0x98
[ 119.310945] dump_stack+0x18/0x24
[ 119.310951] print_irq_inversion_bug.part.0+0x1e4/0x220
[ 119.310960] mark_lock+0x610/0x920
[ 119.310968] __lock_acquire+0xfcc/0x21a8
[ 119.310976] lock_acquire+0x188/0x33c
[ 119.310985] _raw_spin_lock_irqsave+0x60/0x88
[ 119.310992] regmap_lock_spinlock+0x18/0x38
[ 119.310999] regmap_read+0x3c/0x80
[ 119.311005] vop2_isr+0x90/0x2c0 [rockchipdrm]
[ 119.311032] __handle_irq_event_percpu+0x90/0x310
[ 119.311040] handle_irq_event+0x4c/0xc0
[ 119.311048] handle_fasteoi_irq+0xa0/0x1bc
[ 119.311056] generic_handle_domain_irq+0x2c/0x44
[ 119.311064] gic_handle_irq+0x4c/0x120
[ 119.311069] call_on_irq_stack+0x24/0x54
[ 119.311076] do_interrupt_handler+0x80/0x84
[ 119.311083] el1_interrupt+0x34/0x64
[ 119.311090] el1h_64_irq_handler+0x18/0x24
[ 119.311098] el1h_64_irq+0x64/0x68
[ 119.311103] cpuidle_enter_state+0x12c/0x678
[ 119.311111] cpuidle_enter+0x38/0x50
[ 119.311118] do_idle+0x200/0x280
[ 119.311124] cpu_startup_entry+0x34/0x3c
[ 119.311130] rest_init+0x174/0x180
[ 119.311138] console_on_rootfs+0x0/0x6c
[ 119.311146] __primary_switched+0x80/0x88