[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2024081459-paralyses-antarctic-2499@gregkh>
Date: Wed, 14 Aug 2024 06:25:51 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Cristian Ciocaltea <cristian.ciocaltea@...labora.com>
Cc: Mark Brown <broonie@...nel.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Heiko Stübner <heiko@...ech.de>,
Andy Yan <andy.yan@...k-chips.com>, kernel@...labora.com,
linux-kernel@...r.kernel.org, linux-rockchip@...ts.infradead.org
Subject: Re: [PATCH RFC] regmap: maple: Switch to use irq-safe locking
On Wed, Aug 14, 2024 at 01:20:21AM +0300, Cristian Ciocaltea wrote:
> Commit 3d59c22bbb8d ("drm/rockchip: vop2: Convert to use maple tree
> register cache") enabled the use of maple tree register cache in
> Rockchip VOP2 driver. However, building the kernel with lockdep support
> indicates locking rules violation when trying to unload the rockchipdrm
> module:
>
> [ 48.360258] ========================================================
> [ 48.360829] WARNING: possible irq lock inversion dependency detected
> [ 48.361400] 6.11.0-rc1 #40 Not tainted
> [ 48.361743] --------------------------------------------------------
> [ 48.362311] modprobe/685 just changed the state of lock:
> [ 48.362790] ffff0000087fa798 (&mt->ma_lock){+...}-{2:2}, at: regcache_maple_exit+0x6c/0xe0
> [ 48.363554] but this lock was taken by another, HARDIRQ-safe lock in the past:
> [ 48.364212] (rockchip_drm_vop2:3114:(&vop2_regmap_config)->lock){-.-.}-{2:2}
> [ 48.364226]
>
> and interrupts could create inverse lock ordering between them.
>
> [ 48.365874]
> other info that might help us debug this:
> [ 48.366460] Possible interrupt unsafe locking scenario:
>
> [ 48.367069] CPU0 CPU1
> [ 48.367478] ---- ----
> [ 48.367889] lock(&mt->ma_lock);
> [ 48.368197] local_irq_disable();
> [ 48.368729] lock(rockchip_drm_vop2:3114:(&vop2_regmap_config)->lock);
> [ 48.369551] lock(&mt->ma_lock);
> [ 48.370081] <Interrupt>
> [ 48.370336] lock(rockchip_drm_vop2:3114:(&vop2_regmap_config)->lock);
> [ 48.370957]
> *** DEADLOCK ***
>
> [ 48.371489] 2 locks held by modprobe/685:
> [ 48.371854] #0: ffff0000018898f8 (&dev->mutex){....}-{3:3}, at: device_release_driver_internal+0x54/0x210
> [ 48.372739] #1: ffff800081c6ca80 (component_mutex){+.+.}-{3:3}, at: component_del+0x38/0x158
> [ 48.373522]
> the shortest dependencies between 2nd lock and 1st lock:
> [ 48.374235] -> (rockchip_drm_vop2:3114:(&vop2_regmap_config)->lock){-.-.}-{2:2} {
> [ 48.374941] IN-HARDIRQ-W at:
> [ 48.375239] lock_acquire+0x1d4/0x320
> [ 48.375739] _raw_spin_lock_irqsave+0x6c/0x98
> [ 48.376300] regmap_lock_spinlock+0x20/0x40
> [ 48.376845] regmap_read+0x44/0x88
> [ 48.377321] vop2_isr+0x90/0x290 [rockchipdrm]
> [ 48.377919] __handle_irq_event_percpu+0x114/0x2b0
> [ 48.378519] handle_irq_event+0x54/0xb8
> [ 48.379032] handle_fasteoi_irq+0x158/0x228
> [ 48.379577] generic_handle_domain_irq+0x34/0x58
> [ 48.380160] gic_handle_irq+0xa4/0x114
>
> [...]
>
> [ 48.466666] -> (&mt->ma_lock){+...}-{2:2} {
> [ 48.467066] HARDIRQ-ON-W at:
> [ 48.467360] lock_acquire+0x1d4/0x320
> [ 48.467849] _raw_spin_lock+0x50/0x70
> [ 48.468337] regcache_maple_exit+0x6c/0xe0
> [ 48.468864] regcache_exit+0x8c/0xa8
> [ 48.469344] regmap_exit+0x24/0x160
> [ 48.469815] devm_regmap_release+0x1c/0x28
> [ 48.470339] release_nodes+0x68/0xa8
> [ 48.470818] devres_release_group+0x120/0x180
> [ 48.471364] component_unbind+0x54/0x70
> [ 48.471867] component_unbind_all+0xb0/0xe8
> [ 48.472400] rockchip_drm_unbind+0x44/0x80 [rockchipdrm]
> [ 48.473059] component_del+0xc8/0x158
> [ 48.473545] dw_hdmi_rockchip_remove+0x28/0x40 [rockchipdrm]
>
> The problem is that the regmap lock could be taken by an IRQ context,
> interrupting the irq-unsafe maple tree lock, which may result in a lock
> inversion deadlock scenario.
>
> Switch to use irq-safe locking in the maple tree register cache.
>
> Fixes: f033c26de5a5 ("regmap: Add maple tree based register cache")
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@...labora.com>
> ---
> drivers/base/regmap/regcache-maple.c | 29 ++++++++++++++++++-----------
> 1 file changed, 18 insertions(+), 11 deletions(-)
>
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- You have marked a patch with a "Fixes:" tag for a commit that is in an
older released kernel, yet you do not have a cc: stable line in the
signed-off-by area at all, which means that the patch will not be
applied to any older kernel releases. To properly fix this, please
follow the documented rules in the
Documentation/process/stable-kernel-rules.rst file for how to resolve
this.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot
Powered by blists - more mailing lists