linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] regmap: pass map name to lockdep
@ 2014-12-18 21:05 Antti Palosaari
  2014-12-18 21:05 ` [PATCH 2/2] rtl2832: add name for RegMap Antti Palosaari
  2014-12-18 21:34 ` [PATCH 1/2] regmap: pass map name to lockdep Lars-Peter Clausen
  0 siblings, 2 replies; 6+ messages in thread
From: Antti Palosaari @ 2014-12-18 21:05 UTC (permalink / raw)
  To: linux-media; +Cc: Antti Palosaari, Mark Brown

lockdep complains recursive locking and deadlock when two different
regmap instances are called in a nested order. That happen easily
for example when both I2C client and muxed/repeater I2C adapter are
using regmap. As a solution, pass regmap name for lockdep in order
to force lockdep validate regmap mutex per driver - not as all regmap
instances grouped together.

Here is example connection, where nested regmap is used to control
I2C mux.
 __________         ___________         ___________
|  USB IF  |       |   demod   |       |   tuner   |
|----------|       |-----------|       |-----------|
|          |--I2C--|-----/ ----|--I2C--|           |
|I2C master|       |  I2C mux  |       | I2C slave |
|__________|       |___________|       |___________|

Cc: Mark Brown <broonie@kernel.org>
Signed-off-by: Antti Palosaari <crope@iki.fi>
---
 drivers/base/regmap/regmap.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index d2f8a81..8d8ad37 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -559,6 +559,12 @@ struct regmap *regmap_init(struct device *dev,
 			mutex_init(&map->mutex);
 			map->lock = regmap_lock_mutex;
 			map->unlock = regmap_unlock_mutex;
+			if (config->name) {
+				static struct lock_class_key key;
+
+				lockdep_set_class_and_name(&map->mutex, &key,
+							   config->name);
+			}
 		}
 		map->lock_arg = map;
 	}
-- 
http://palosaari.fi/


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

end of thread, other threads:[~2014-12-19 14:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-18 21:05 [PATCH 1/2] regmap: pass map name to lockdep Antti Palosaari
2014-12-18 21:05 ` [PATCH 2/2] rtl2832: add name for RegMap Antti Palosaari
2014-12-18 21:34 ` [PATCH 1/2] regmap: pass map name to lockdep Lars-Peter Clausen
2014-12-19 10:58   ` Antti Palosaari
2014-12-19 13:45     ` Lars-Peter Clausen
2014-12-19 14:19       ` Antti Palosaari

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).