The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Arun Iyengar via B4 Relay <devnull+aiyengar1990.gmail.com@kernel.org>
To: Mark Brown <broonie@kernel.org>, Lee Jones <lee@kernel.org>,
	 Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 "Rafael J. Wysocki" <rafael@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>,
	 Johan Hovold <johan@kernel.org>,
	driver-core@lists.linux.dev,  mfd@lists.linux.dev,
	linux-kernel@vger.kernel.org,  Heiko Stuebner <heiko@sntech.de>,
	linux-rockchip@lists.infradead.org,
	 linux-arm-kernel@lists.infradead.org,
	Arun Iyengar <aiyengar1990@gmail.com>
Subject: [PATCH v3 1/2] regmap: Add an optional lockdep class to struct regmap_config
Date: Sat, 28 Nov 2026 19:06:24 +0000	[thread overview]
Message-ID: <20261128-syscon-lockdep-v3-1-2c786aa075bf@gmail.com> (raw)
In-Reply-To: <20261128-syscon-lockdep-v3-0-2c786aa075bf@gmail.com>

From: Arun Iyengar <aiyengar1990@gmail.com>

The lockdep class of regmap's own lock is per regmap_init_*() call site.
Maps made at one call site, such as all syscons, share it, so lockdep
mixes up their unrelated lock chains.

Let the caller give each map its own class with config->lock_key.

Suggested-by: Lee Jones <lee@kernel.org>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/base/regmap/regmap.c | 3 +++
 include/linux/regmap.h       | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 0ba82fcc55bf..3534d27909a0 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -720,6 +720,9 @@ static int regmap_set_lock(struct regmap *map, const struct regmap_config *confi
 		return 0;
 	}
 
+	if (config->lock_key)
+		lock_key = config->lock_key;
+
 	if (fast_io) {
 		if (config->use_raw_spinlock) {
 			raw_spin_lock_init(&map->raw_spinlock);
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 6194948ff9ed..872de9b3dcd5 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -347,6 +347,8 @@ typedef void (*regmap_unlock)(void *);
  * @lock_arg:	  This field is passed as the only argument of lock/unlock
  *		  functions (ignored in case regular lock/unlock functions
  *		  are not overridden).
+ * @lock_key:	  Optional lockdep class for regmap's own lock, instead of
+ *		  one per call site. Must stay registered while the map exists.
  * @max_register: Optional, specifies the maximum valid register address.
  * @max_register_is_0: Optional, specifies that zero value in @max_register
  *                     should be taken into account. This is a workaround to
@@ -445,6 +447,7 @@ struct regmap_config {
 	regmap_lock lock;
 	regmap_unlock unlock;
 	void *lock_arg;
+	struct lock_class_key *lock_key;
 
 	unsigned int max_register;
 	bool max_register_is_0;

-- 
2.55.0



  reply	other threads:[~2026-11-28 19:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28 19:06 [PATCH v3 0/2] mfd: syscon: Give each syscon its own lockdep class Arun Iyengar via B4 Relay
2026-11-28 19:06 ` Arun Iyengar via B4 Relay [this message]
2026-11-28 19:06 ` [PATCH v3 2/2] " Arun Iyengar via B4 Relay

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=20261128-syscon-lockdep-v3-1-2c786aa075bf@gmail.com \
    --to=devnull+aiyengar1990.gmail.com@kernel.org \
    --cc=aiyengar1990@gmail.com \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=dakr@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=heiko@sntech.de \
    --cc=johan@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mfd@lists.linux.dev \
    --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