From patchwork Mon Feb 1 22:54:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej S. Szmigiero" X-Patchwork-Id: 8184771 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AD50F9F1C1 for ; Mon, 1 Feb 2016 22:55:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D9DDF202AE for ; Mon, 1 Feb 2016 22:55:10 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id C081220204 for ; Mon, 1 Feb 2016 22:55:09 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 6B905265090; Mon, 1 Feb 2016 23:55:08 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E63C42606DD; Mon, 1 Feb 2016 23:54:59 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 7ACA72606FB; Mon, 1 Feb 2016 23:54:59 +0100 (CET) Received: from vps-vb.mhejs.net (vi37-28-154-113.vibiznes.pl [37.28.154.113]) by alsa0.perex.cz (Postfix) with ESMTP id 8D0042606C1 for ; Mon, 1 Feb 2016 23:54:52 +0100 (CET) Received: by vps-vb.mhejs.net with esmtps (TLSv1:DHE-RSA-CAMELLIA256-SHA:256) (Exim 4.82) (envelope-from ) id 1aQNMu-0007xs-Oz; Mon, 01 Feb 2016 23:54:48 +0100 Message-ID: <56AFE233.10701@maciej.szmigiero.name> Date: Mon, 01 Feb 2016 23:54:43 +0100 From: "Maciej S. Szmigiero" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: Mark Brown , Fabio Estevam References: <1454362695-10682-1-git-send-email-broonie@kernel.org> <1454362695-10682-2-git-send-email-broonie@kernel.org> <20160201214139.GI4455@sirena.org.uk> <20160201221346.GJ4455@sirena.org.uk> In-Reply-To: <20160201221346.GJ4455@sirena.org.uk> Cc: Nicolin Chen , "alsa-devel@alsa-project.org" , linux-kernel Subject: Re: [alsa-devel] [PATCH 2/2] regmap: cache: Fall back to register by register read for cache defaults X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP On 01.02.2016 23:13, Mark Brown wrote: > On Mon, Feb 01, 2016 at 07:58:54PM -0200, Fabio Estevam wrote: >> On Mon, Feb 1, 2016 at 7:41 PM, Mark Brown wrote: >>> On Mon, Feb 01, 2016 at 09:38:15PM +0000, Mark Brown wrote: >>>> If we are unable to read the cache defaults for a regmap then fall back >>>> on attempting to read them word by word. This is going to be painfully >>>> slow for large regmaps but might be adequate for smaller ones. > >>> Competely untested, hopefully it helps fix the issues with the SSI. > >> After applying this series I get: > > Please try to fix it yourself, probably needs setting cache_bypass > around the manual fill. Thanks for patches. I was able to make SSI work again after modifying second patch with cache_bypass around read and skipping of unreadable regs: Tested-by: Fabio Estevam diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index 5c5090b..4170b7d 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -30,7 +30,7 @@ static int regcache_hw_init(struct regmap *map) int i, j; int ret; int count; - unsigned int val; + unsigned int reg, val; void *tmp_buf; if (!map->num_reg_defaults_raw) @@ -67,27 +67,46 @@ static int regcache_hw_init(struct regmap *map) ret = regmap_raw_read(map, 0, tmp_buf, map->cache_size_raw); map->cache_bypass = cache_bypass; - if (ret < 0) - goto err_cache_free; - - map->reg_defaults_raw = tmp_buf; - map->cache_free = 1; + if (ret == 0) { + map->reg_defaults_raw = tmp_buf; + map->cache_free = 1; + } else { + kfree(tmp_buf); + } } /* fill the reg_defaults */ for (i = 0, j = 0; i < map->num_reg_defaults_raw; i++) { - if (regmap_volatile(map, i * map->reg_stride)) + reg = i * map->reg_stride; + + if (!regmap_readable(map, reg)) continue; - val = regcache_get_val(map, map->reg_defaults_raw, i); - map->reg_defaults[j].reg = i * map->reg_stride; + + if (regmap_volatile(map, reg)) + continue; + + if (map->reg_defaults_raw) { + val = regcache_get_val(map, map->reg_defaults_raw, i); + } else { + bool cache_bypass = map->cache_bypass; + + map->cache_bypass = true; + ret = regmap_read(map, reg, &val); + map->cache_bypass = cache_bypass; + if (ret != 0) { + dev_err(map->dev, "Failed to read %d: %d\n", + reg, ret); + goto err_free; + } + } + + map->reg_defaults[j].reg = reg; map->reg_defaults[j].def = val; j++; } return 0; -err_cache_free: - kfree(tmp_buf); err_free: kfree(map->reg_defaults);