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 07:06 AM, Lars-Peter Clausen wrote:
> regmap-mmio uses a spinlock with spin_lock() and spin_unlock() for locking.
> Which means in order to avoid race conditions the lock always needs to be taken
> from the same context.

I'm not really sure what this means. I assume contexts are
atomic-vs-nonatomic? If so, spinlocks should work fine for this, right?

I guess the core of the issue is that you want to replace spin_lock()
with spin_lock_irqsave(). I'd like to see that explicitly described in
the commit description, if that is the core aspect of this change.

Re: the other comments about the API change: I think this can be done
non-invasively:

static void regmap_lock_spinlock(void *__map)
{
struct regmap *map = __map;
unsigned long local_flags;

spin_lock_irqsave(&map->spinlock, local_flags);
/*
* Here, we have the lock locked, so we own the flags,
* and can write to them.
*/
map->spinlock_flags = local_flags;
}

static void regmap_unlock_spinlock(void *__map, unsigned long *flags)
{
struct regmap *map = __map;
spin_unlock_irqrestore(&map->spinlock, map->spinlock_flags);
}

... and obviously add a spinlock_flags field to struct regmap (perhaps
start unioning the mutex and spinlock data fields there if you want to
save space).


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