Linux-Rockchip Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] mfd: syscon: Give each syscon its own lockdep class
@ 2026-11-28 19:06 Arun Iyengar via B4 Relay
  2026-11-28 19:06 ` [PATCH v3 1/2] regmap: Add an optional lockdep class to struct regmap_config Arun Iyengar via B4 Relay
  2026-11-28 19:06 ` [PATCH v3 2/2] mfd: syscon: Give each syscon its own lockdep class Arun Iyengar via B4 Relay
  0 siblings, 2 replies; 3+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-28 19:06 UTC (permalink / raw)
  To: Mark Brown, Lee Jones, Arnd Bergmann
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Johan Hovold, driver-core, mfd, linux-kernel, Heiko Stuebner,
	linux-rockchip, linux-arm-kernel, Arun Iyengar

All syscon regmaps share one lockdep class, so on RK3588 lockdep reports
a false circular dependency and turns itself off. Patch 1 adds an
optional lockdep key to regmap_config, patch 2 gives each syscon one.

Patch 2 needs patch 1, so both could go through regmap with Lee's ack,
or through mfd with Mark's. Based on regmap for-next; patch 2 also
merges cleanly with for-mfd-next.

Tested on an Orange Pi 5 (RK3588S) with a 7.3 based kernel that has
out-of-tree DisplayPort patches, lockdep and KASAN on. Without the series
lockdep reports the cycle during boot. With it there is no report and
lockdep stays on.

Developed with Claude (Anthropic), which wrote the code and the commit
messages. I reviewed every change.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
Changes in v3:
- Move the fix into regmap: new regmap_config.lock_key; syscon passes a
  per-syscon key and drops its own lock (Lee).
- Drop the prerequisite, it is in for-mfd-next.
- Link to v2: https://patch.msgid.link/20261122-syscon-lockdep-v2-1-868056a6a808@gmail.com

Changes in v2:
- __acquires/__releases: name the argument, not a local (Sashiko).
- Link to v1: https://patch.msgid.link/20261120-syscon-lockdep-v1-1-aed779a004b8@gmail.com

---
Arun Iyengar (2):
      regmap: Add an optional lockdep class to struct regmap_config
      mfd: syscon: Give each syscon its own lockdep class

 drivers/base/regmap/regmap.c | 3 +++
 drivers/mfd/syscon.c         | 6 ++++++
 include/linux/regmap.h       | 3 +++
 3 files changed, 12 insertions(+)
---
base-commit: 222b61e9c570dac6c7a786d039e4c226624b426d
change-id: 20261115-syscon-lockdep-d133fb58c2be

Best regards,
--  
Arun Iyengar <aiyengar1990@gmail.com>



_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v3 1/2] regmap: Add an optional lockdep class to struct regmap_config
  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
  2026-11-28 19:06 ` [PATCH v3 2/2] mfd: syscon: Give each syscon its own lockdep class Arun Iyengar via B4 Relay
  1 sibling, 0 replies; 3+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-28 19:06 UTC (permalink / raw)
  To: Mark Brown, Lee Jones, Arnd Bergmann
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Johan Hovold, driver-core, mfd, linux-kernel, Heiko Stuebner,
	linux-rockchip, linux-arm-kernel, Arun Iyengar

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



_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v3 2/2] mfd: syscon: Give each syscon its own lockdep class
  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 ` [PATCH v3 1/2] regmap: Add an optional lockdep class to struct regmap_config Arun Iyengar via B4 Relay
@ 2026-11-28 19:06 ` Arun Iyengar via B4 Relay
  1 sibling, 0 replies; 3+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-28 19:06 UTC (permalink / raw)
  To: Mark Brown, Lee Jones, Arnd Bergmann
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Johan Hovold, driver-core, mfd, linux-kernel, Heiko Stuebner,
	linux-rockchip, linux-arm-kernel, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

All syscon regmaps share the lockdep class of the regmap_init_mmio() call
site. On RK3588 the VO1 GRF calls clk_enable() under its regmap lock, while
the CRU's GRF gates take the SYS GRF regmap lock under enable_lock. Lockdep
reports a circular dependency and turns itself off.

Give each syscon its own class.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/mfd/syscon.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 21a7fcdd2737..e0d5558b3382 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -13,6 +13,7 @@
 #include <linux/err.h>
 #include <linux/hwspinlock.h>
 #include <linux/list.h>
+#include <linux/lockdep.h>
 #include <linux/mutex.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
@@ -29,6 +30,7 @@ struct syscon {
 	struct regmap *regmap;
 	struct reset_control *reset;
 	struct list_head list;
+	struct lock_class_key lock_key;
 };
 
 static const struct regmap_config syscon_regmap_config = {
@@ -62,6 +64,9 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_res)
 	if (!base)
 		return ERR_PTR(-ENOMEM);
 
+	lockdep_register_key(&syscon->lock_key);
+	syscon_config.lock_key = &syscon->lock_key;
+
 	/* Parse the device's DT node for an endianness specification */
 	if (of_property_read_bool(np, "big-endian"))
 		syscon_config.val_format_endian = REGMAP_ENDIAN_BIG;
@@ -162,6 +167,7 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_res)
 	regmap_exit(regmap);
 err_regmap:
 	iounmap(base);
+	lockdep_unregister_key(&syscon->lock_key);
 	return ERR_PTR(ret);
 }
 

-- 
2.55.0



_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-28 19:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH v3 1/2] regmap: Add an optional lockdep class to struct regmap_config Arun Iyengar via B4 Relay
2026-11-28 19:06 ` [PATCH v3 2/2] mfd: syscon: Give each syscon its own lockdep class Arun Iyengar via B4 Relay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox