Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933126AbbDYL1T (ORCPT ); Sat, 25 Apr 2015 07:27:19 -0400 Received: from smtp-out-189.synserver.de ([212.40.185.189]:1064 "EHLO smtp-out-189.synserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759103AbbDYL1Q (ORCPT ); Sat, 25 Apr 2015 07:27:16 -0400 X-SynServer-TrustedSrc: 1 X-SynServer-AuthUser: lars@metafoo.de X-SynServer-PPID: 31111 Message-ID: <553B7A11.7040706@metafoo.de> Date: Sat, 25 Apr 2015 13:27:13 +0200 From: Lars-Peter Clausen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.6.0 MIME-Version: 1.0 To: Kevin Cernekee , lgirdwood@gmail.com, broonie@kernel.org CC: dgreid@chromium.org, abrestic@chromium.org, olofj@chromium.org, alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V2 1/4] regmap: cache: Add "was_reset" argument to regcache_sync_region() References: <1429915008-22015-1-git-send-email-cernekee@chromium.org> <1429915008-22015-2-git-send-email-cernekee@chromium.org> In-Reply-To: <1429915008-22015-2-git-send-email-cernekee@chromium.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3788 Lines: 93 On 04/25/2015 12:36 AM, Kevin Cernekee wrote: > regcache_sync() and regcache_sync_region() currently assume that the > hardware has just emerged from a clean reset, and that all registers are > in their default states. But that isn't the only possibility; the device > may have been in a different state in which the registers were > inaccessible but have retained their contents, e.g. clock gating. > > So we will extend the more versatile of the two functions, > regcache_sync_region(), to let the caller decide what assumptions should > be made. > > One driver that can benefit from this is adau1977, which has hacks to > overwrite the registers that regcache_sync() might have missed. The issue with the adau1977 is slightly different, there is only one single register which is not affected, so we need special handling for that register. For all other registers the default behavior of regcache_sync() is correct. > Also, the powerdown pin on tas571x does not reset the register contents > either, so a similar feature will be required by that driver. > > This commit just adds the new argument by changing the function > declarations and call sites, but doesn't wire it up yet. I think a better approach is to introduce a new flag internally, similar to the cache_dirty flag. Set both this new flag and cache_dirty when regcache_mark_dirty() is called. But only cache_dirty when a write is performed when the regmap is marked as cache only. Now in regcache_sync() and friends check this new flag and only when it is set skip registers which match the default. At the end of regcache_sync() clear both flags. [...] > @@ -600,7 +605,8 @@ static bool regcache_reg_present(unsigned long *cache_present, unsigned int idx) > static int regcache_sync_block_single(struct regmap *map, void *block, > unsigned long *cache_present, > unsigned int block_base, > - unsigned int start, unsigned int end) > + unsigned int start, unsigned int end, > + bool was_reset) > { > unsigned int i, regtmp, val; > int ret; > @@ -614,10 +620,12 @@ static int regcache_sync_block_single(struct regmap *map, void *block, > > val = regcache_get_val(map, block, i); > > - /* Is this the hardware default? If so skip. */ > - ret = regcache_lookup_reg(map, regtmp); > - if (ret >= 0 && val == map->reg_defaults[ret].def) > - continue; > + if (was_reset) { > + /* Is this the hardware default? If so skip. */ > + ret = regcache_lookup_reg(map, regtmp); > + if (ret >= 0 && val == map->reg_defaults[ret].def) > + continue; > + } Probably factor the check whether wee need to sync or not into a helper function, that can be used here and below in sync_block_raw(). [...] > @@ -689,14 +697,17 @@ static int regcache_sync_block_raw(struct regmap *map, void *block, > > val = regcache_get_val(map, block, i); > > - /* Is this the hardware default? If so skip. */ > - ret = regcache_lookup_reg(map, regtmp); > - if (ret >= 0 && val == map->reg_defaults[ret].def) { > - ret = regcache_sync_block_raw_flush(map, &data, > - base, regtmp); > - if (ret != 0) > - return ret; > - continue; > + if (was_reset) { > + /* Is this the hardware default? If so skip. */ > + ret = regcache_lookup_reg(map, regtmp); > + if (ret >= 0 && val == map->reg_defaults[ret].def) { > + ret = regcache_sync_block_raw_flush(map, &data, > + base, > + regtmp); > + if (ret != 0) > + return ret; > + continue; > + } > } > [...] -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/