public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Arjan van de Ven <arjan@linux.intel.com>,
	Nicolas Boichat <drinkcat@chromium.org>,
	Mark Brown <broonie@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
	Antti Palosaari <crope@iki.fi>, Ingo Molnar <mingo@redhat.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, Bard Liao <bardliao@realtek.com>,
	Oder Chiou <oder_chiou@realtek.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>,
	alsa-devel@alsa-project.org,
	Anatol Pomozov <anatol.pomozov@gmail.com>
Subject: Re: [RFC PATCH 1/2] regmap: add configurable lock class key for lockdep
Date: Thu, 25 Jun 2015 17:03:00 +0200	[thread overview]
Message-ID: <558C1824.8020204@metafoo.de> (raw)
In-Reply-To: <558C0067.2000401@linux.intel.com>

On 06/25/2015 03:21 PM, Arjan van de Ven wrote:
> On 6/25/2015 2:35 AM, Nicolas Boichat wrote:
>> From: Antti Palosaari <crope@iki.fi>
>>
>> Lockdep validator complains about recursive locking and deadlock
>> when two different regmap instances are called in a nested order.
>> That happens anytime a regmap read/write call needs to access
>> another regmap.
>>
>> This is because, for performance reason, lockdep groups all locks
>> initialized by the same mutex_init() in the same lock class.
>> Therefore all regmap mutexes are in the same lock class, leading
>> to lockdep "nested locking" warnings if a regmap accesses another
>> regmap. However, depending on the specifics of the driver, this
>> can be perfectly safe (e.g. if there is a clear hierarchy between
>> a "master" regmap that uses another "slave" regmap). In these
>> cases, the warning is false and should be silenced.
>>
>> As a solution, add configuration option to pass custom lock class
>> key for lockdep validator, to be used in the regmap that needs to
>> access another regmap. This removes the need for uglier workarounds
>> in drivers, just to silence this warning (e.g. add custom mutex
>> lock/unlock functions).
>
> wouldn't it be better to use the mutex_lock_nested() and co to explicitly
> express your hierarchy?

That would require that the hierarchy is known in advance. The hierarchy 
depends on the hardware topology. Different systems will have different 
hierarchies where the relationship between locks can change and it will be 
hard to find a hierarchy that works across all topologies.

A simple hierarchy would be to say one lockdep subclass is bus masters and 
one lockdep subclass are bus slaves. E.g. the SPI bus controller gets the 
master subclass and the device on the SPI bus gets the slave subclass.

The problem is that a device that is a bus master on one bus that uses 
regmap can be a slave on a different bus that uses regmap. And this can be 
nested arbitrarily deep.

E.g. the rt5677, for which Nicolas is trying to solve the problem is, slave 
device on a I2C bus, but also has an internal bus, which is used to access 
the DSP, for which it is the master.

- Lars


  parent reply	other threads:[~2015-06-25 15:03 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-25  9:35 [RFC PATCH 1/2] regmap: add configurable lock class key for lockdep Nicolas Boichat
2015-06-25  9:35 ` [RFC PATCH 2/2] ASoC: rt5677: Add lockdep class to silence lockdep warnings Nicolas Boichat
2015-06-25 13:21 ` [RFC PATCH 1/2] regmap: add configurable lock class key for lockdep Arjan van de Ven
2015-06-25 14:29   ` Mark Brown
2015-06-25 15:03   ` Lars-Peter Clausen [this message]
2015-06-25 15:33     ` Mark Brown
2015-06-25 15:47       ` Lars-Peter Clausen
2015-06-25 16:08         ` Mark Brown
2015-06-26  3:16           ` Nicolas Boichat
2015-06-29 12:51             ` Nicolas Boichat
2015-06-29 12:59               ` Lars-Peter Clausen
2015-06-29 14:03                 ` Nicolas Boichat
2015-06-29 14:18                   ` Lars-Peter Clausen
2015-06-29 15:34                     ` Mark Brown
2015-06-30  4:56                       ` Nicolas Boichat
2015-06-30 11:02                         ` [alsa-devel] " Lars-Peter Clausen
2015-06-29 14:22                   ` Mark Brown
2015-06-29 14:35                     ` Arjan van de Ven
2015-06-29 15:32                       ` Mark Brown
2015-06-29 15:36                         ` Arjan van de Ven
2015-06-29 16:02                           ` Mark Brown
2015-06-29 14:19                 ` Mark Brown
2015-06-25 14:49 ` Mark Brown
2015-06-25 15:59 ` Lars-Peter Clausen
2015-06-26  2:34   ` Nicolas Boichat
2015-06-26  8:31     ` Lars-Peter Clausen

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=558C1824.8020204@metafoo.de \
    --to=lars@metafoo.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=anatol.pomozov@gmail.com \
    --cc=arjan@linux.intel.com \
    --cc=bardliao@realtek.com \
    --cc=broonie@kernel.org \
    --cc=crope@iki.fi \
    --cc=drinkcat@chromium.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@osg.samsung.com \
    --cc=mingo@redhat.com \
    --cc=oder_chiou@realtek.com \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.de \
    /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