lkml.org 
[lkml]   [2013]   [May]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/2] regmap: Make regmap-mmio usable from different contexts
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


\
 
 \ /
  Last update: 2013-05-23 17:01    [W:0.068 / U:1.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site