Re: [PATCH 3/7] regmap: Add a mutex to guard the sync operation

From: Dimitris Papastamos
Date: Wed Sep 28 2011 - 10:24:12 EST


On Wed, Sep 28, 2011 at 01:52:50PM +0100, Mark Brown wrote:
> On Wed, Sep 28, 2011 at 11:43:43AM +0100, Dimitris Papastamos wrote:
>
> > + mutex_lock(&map->sync_lock);
> > dev_dbg(map->dev, "Syncing %s cache\n",
> > map->cache_ops->name);
> > name = map->cache_ops->name;
> > @@ -254,6 +257,7 @@ int regcache_sync(struct regmap *map)
> > }
> > out:
> > trace_regcache_sync(map->dev, name, "stop");
> > + mutex_unlock(&map->sync_lock);
>
> Shouldn't we either be taking the regmap lock when doing the sync or
> otherwise guarding against something other than a cache sync?

Em the main issue is that the sync() implementation will use
regmap_write() which will grab map->lock. To avoid this we could have
gone and used directly the lockless _regmap_write() but that's
static. To be honest, it feels cleaner to have only 1 lock to guard
the map so maybe we should get rid of map->sync_lock.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/