From patchwork Tue Aug 26 14:03:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Nikula X-Patchwork-Id: 4781951 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6373F9F2A9 for ; Tue, 26 Aug 2014 14:04:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B22E2201DD for ; Tue, 26 Aug 2014 14:04:07 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id A9D292015E for ; Tue, 26 Aug 2014 14:04:05 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 18DCE2651B8; Tue, 26 Aug 2014 16:04:03 +0200 (CEST) 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, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 26AF226517E; Tue, 26 Aug 2014 16:03:52 +0200 (CEST) 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 5F660265189; Tue, 26 Aug 2014 16:03:51 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by alsa0.perex.cz (Postfix) with ESMTP id DC8C826516B for ; Tue, 26 Aug 2014 16:03:42 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 26 Aug 2014 07:03:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,404,1406617200"; d="scan'208";a="581860796" Received: from mylly.fi.intel.com (HELO mylly.fi.intel.com.) ([10.237.72.53]) by fmsmga001.fm.intel.com with ESMTP; 26 Aug 2014 07:03:37 -0700 From: Jarkko Nikula To: alsa-devel@alsa-project.org Date: Tue, 26 Aug 2014 17:03:12 +0300 Message-Id: <1409061793-10495-2-git-send-email-jarkko.nikula@linux.intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1409061793-10495-1-git-send-email-jarkko.nikula@linux.intel.com> References: <1409061793-10495-1-git-send-email-jarkko.nikula@linux.intel.com> Cc: Mark Brown , Jarkko Nikula , linux-kernel@vger.kernel.org, Liam Girdwood Subject: [alsa-devel] [PATCH 1/2] regmap: cache: Fix regcache_sync_block for non-autoincrementing devices 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 75a5f89f635c ("regmap: cache: Write consecutive registers in a single block write") expected that autoincrementing writes are supported if hardware has a register format which can support raw writes. This is not necessarily true and thus for instance rbtree sync can fail when there is need to sync multiple consecutive registers but block write to device fails due not supported autoincrementing writes. Fix this by spliting raw block sync to series of single register writes for devices that don't support autoincrementing writes. Signed-off-by: Jarkko Nikula --- I noticed this with Realtek RT5642 audio codec which didn't resume properly since first block write having more data than for single register failed to not acknowledged I2C write during regcache_sync(). Chip acknowledges device address, register address and two data bytes for its word size registers but next data byte is not which then causes aborted I2C transfer and aborted register sync. --- drivers/base/regmap/regcache.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index 29b4128da0b0..54707e586ac8 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -629,6 +629,7 @@ static int regcache_sync_block_raw_flush(struct regmap *map, const void **data, { size_t val_bytes = map->format.val_bytes; int ret, count; + unsigned int i; if (*data == NULL) return 0; @@ -640,7 +641,18 @@ static int regcache_sync_block_raw_flush(struct regmap *map, const void **data, map->cache_bypass = 1; - ret = _regmap_raw_write(map, base, *data, count * val_bytes); + if (!map->use_single_rw) { + ret = _regmap_raw_write(map, base, *data, count * val_bytes); + } else { + for (i = 0; i < count; i++) { + ret = _regmap_raw_write(map, + base + (i * map->reg_stride), + *data + (i * val_bytes), + val_bytes); + if (ret != 0) + break; + } + } map->cache_bypass = 0;