From: Lars-Peter Clausen <lars@metafoo.de>
To: Mark Brown <broonie@kernel.org>
Cc: Davide Ciminaghi <ciminaghi@gnudd.com>,
Stephen Warren <swarren@wwwdotorg.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] regmap: Make regmap-mmio usable from different contexts
Date: Thu, 23 May 2013 16:20:27 +0200 [thread overview]
Message-ID: <519E25AB.4060406@metafoo.de> (raw)
In-Reply-To: <20130523140503.GD2412@sirena.org.uk>
On 05/23/2013 04:05 PM, Mark Brown wrote:
> On Thu, May 23, 2013 at 03:06:16PM +0200, Lars-Peter Clausen wrote:
>
>> This patch updates the adds a flags parameter to the regmap lock and unlock
>> callbacks and uses spin_lock_irqsave() and spin_unlock_restore() for the mmio
>> case. This allows us to use regmap-mmio from different contexts.
>
> This seems really invasive, why not just have the lock that gets passed
> in point to a struct which has both the lock and the flags? As far as
> the core is concerned the lock is just whatever data is required to do
> the locking, the fact that it's actually two values is an implementation
> detail of this locking implementation.
I think that won't work. spin_lock_irqsave() will write to the flags
parameter before it has successfully taken the look. So if a process running
on another CPU tries to acquire the the lock while it is already held we'll
end up overwriting the flags. E.g:
CPU0 CPU1
spin_lock_irqsave()
- write flags
spin_lock_irqsave()
- overwrite flags
spin_unlock_irqrestore()
- restore wrong flags
Hence flags needs to go onto the stack.
- Lars
next prev parent reply other threads:[~2013-05-23 14:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-23 13:06 [PATCH 1/2] regmap: regcache: Fixup locking for custom lock callbacks Lars-Peter Clausen
2013-05-23 13:06 ` [PATCH 2/2] regmap: Make regmap-mmio usable from different contexts Lars-Peter Clausen
2013-05-23 14:05 ` Mark Brown
2013-05-23 14:20 ` Lars-Peter Clausen [this message]
2013-05-23 14:31 ` Mark Brown
2013-05-23 14:36 ` Lars-Peter Clausen
2013-05-23 15:14 ` Mark Brown
2013-05-23 15:42 ` Stephen Warren
2013-05-23 15:50 ` Lars-Peter Clausen
2013-05-23 16:06 ` Stephen Warren
2013-05-23 16:10 ` Mark Brown
2013-05-23 16:01 ` Mark Brown
2013-05-23 14:08 ` [PATCH 1/2] regmap: regcache: Fixup locking for custom lock callbacks Mark Brown
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=519E25AB.4060406@metafoo.de \
--to=lars@metafoo.de \
--cc=broonie@kernel.org \
--cc=ciminaghi@gnudd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=swarren@wwwdotorg.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