public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Cc: "Mark Brown" <broonie@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Heiko Stübner" <heiko@sntech.de>,
	"Andy Yan" <andy.yan@rock-chips.com>,
	kernel@collabora.com, linux-kernel@vger.kernel.org,
	linux-rockchip@lists.infradead.org
Subject: Re: [PATCH RFC] regmap: maple: Switch to use irq-safe locking
Date: Wed, 14 Aug 2024 06:25:51 +0200	[thread overview]
Message-ID: <2024081459-paralyses-antarctic-2499@gregkh> (raw)
In-Reply-To: <20240814-regcache-maple-irq-safe-v1-1-1b454c5767de@collabora.com>

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@collabora.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

  reply	other threads:[~2024-08-14  4:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-13 22:20 [PATCH RFC] regmap: maple: Switch to use irq-safe locking Cristian Ciocaltea
2024-08-14  4:25 ` Greg Kroah-Hartman [this message]
2024-08-14 19:04 ` Mark Brown
2024-08-14 19:25   ` Mark Brown
2024-08-16 20:11   ` Cristian Ciocaltea
2024-08-16 23:35     ` Mark Brown
2024-08-19 10:18     ` Andy Yan
2024-08-20  6:19   ` Andy Yan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2024081459-paralyses-antarctic-2499@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=andy.yan@rock-chips.com \
    --cc=broonie@kernel.org \
    --cc=cristian.ciocaltea@collabora.com \
    --cc=heiko@sntech.de \
    --cc=kernel@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox