public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH V1] regmap: Bypassing cache when initializing cache
@ 2012-02-17 13:27 Laxman Dewangan
  2012-02-17 17:21 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Laxman Dewangan @ 2012-02-17 13:27 UTC (permalink / raw)
  To: broonie, gregkh, lars, linux-kernel; +Cc: linux-tegra, ldewangan

During regcache_init, if client has not passed the
default data of cached register then it is directly
read from the hw to initialize cache. This hw register
read happens before cache ops are initialized and hence
avoiding register read to check for the data available
on cache or not by enabling flag of cache_bypass.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
Observed that regcache_hw_init() is gettign called before
cache->ops->init() hapens. The function regcache_hw_init()
is calling the regmap_bulk_read() which internally calls the
regcache-read() and ending with cache->ops->read() and this
cause of system crash as the cache ops are not initialized.
With this patch, avoiding the regcache-read() from
regmap_bulk_read() by enabling cache bypass.


 drivers/base/regmap/regcache.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index a10e81c..853dfff 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -35,12 +35,17 @@ static int regcache_hw_init(struct regmap *map)
 		return -EINVAL;
 
 	if (!map->reg_defaults_raw) {
+		u32 cache_bypass = map->cache_bypass;
 		dev_warn(map->dev, "No cache defaults, reading back from HW\n");
+
+		/* Bypass the cache access till data read from HW*/
+		map->cache_bypass = 1;
 		tmp_buf = kmalloc(map->cache_size_raw, GFP_KERNEL);
 		if (!tmp_buf)
 			return -EINVAL;
 		ret = regmap_bulk_read(map, 0, tmp_buf,
 				       map->num_reg_defaults_raw);
+		map->cache_bypass = cache_bypass;
 		if (ret < 0) {
 			kfree(tmp_buf);
 			return ret;
-- 
1.7.1.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH V1] regmap: Bypassing cache when initializing cache
  2012-02-17 13:27 [PATCH V1] regmap: Bypassing cache when initializing cache Laxman Dewangan
@ 2012-02-17 17:21 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2012-02-17 17:21 UTC (permalink / raw)
  To: Laxman Dewangan; +Cc: gregkh, lars, linux-kernel, linux-tegra

[-- Attachment #1: Type: text/plain, Size: 528 bytes --]

On Fri, Feb 17, 2012 at 06:57:26PM +0530, Laxman Dewangan wrote:
> During regcache_init, if client has not passed the
> default data of cached register then it is directly
> read from the hw to initialize cache. This hw register
> read happens before cache ops are initialized and hence
> avoiding register read to check for the data available
> on cache or not by enabling flag of cache_bypass.

Applied, thanks.  This only affects the code after the addition of cache
integration for bulk I/O so I've added it to that branch.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-02-17 17:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-17 13:27 [PATCH V1] regmap: Bypassing cache when initializing cache Laxman Dewangan
2012-02-17 17:21 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox