Re: [PATCHv2 1/2] regmap: add configurable lock class key for lockdep

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/22/2014 02:44 PM, Mark Brown wrote:
On Sun, Dec 21, 2014 at 12:34:51AM +0200, Antti Palosaari wrote:
Lockdep validator complains recursive locking and deadlock when two
different regmap instances are called in a nested order, as regmap
groups locks by default. That happens easily for example when both

I don't know what "regmap groups locks by default" means.

It means, that lockdep does not track individual lock instances, but group of lock instances, which are called classes. In that case, there is 2 regmap mutexes, one in a I2C client driver and another in I2C adapter driver. Even those are different locks (mutexes) in a different driver, lockdep refers those as a single and same lock and due to that it thinks there is recursive lock => deadlock.

from: Documentation/locking/lockdep-design.txt

Lock-class
----------

The basic object the validator operates upon is a 'class' of locks.

A class of locks is a group of locks that are logically the same with
respect to locking rules, even if the locks may have multiple (possibly
tens of thousands of) instantiations. For example a lock in the inode
struct is one class, while each inode has its own instantiation of that
lock class.

The validator tracks the 'state' of lock-classes, and it tracks
dependencies between different lock-classes. The validator maintains a
rolling proof that the state and the dependencies are correct.

Unlike an lock instantiation, the lock-class itself never goes away: when
a lock-class is used for the first time after bootup it gets registered,
and all subsequent uses of that lock-class will be attached to this
lock-class.


I2C client and I2C adapter are using regmap. As a solution, add
configuration option to pass custom lock class key for lockdep
validator.

Why is this configurable, how would a device know if the system it is in
needs a custom locking class and can safely use one?

If RegMap instance is bus master, eg. I2C adapter, then you should define own custom key. If you don't define own key and there will be slave on that bus which uses RegMap too, there will be recursive locking from a lockdep point of view.


regards
Antti

--
http://palosaari.fi/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux