Message ID | 20230613-b4-regmap-check-readability-before-cache-v1-1-b144c0b01ed9@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp799954vqr; Tue, 13 Jun 2023 13:15:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5SzwK4600BDVwuvIZ1CpE4p/a6n4XMfeGlp+DObzeMbs1RrOV5M9I/GRgNUUeyJ9ah10ut X-Received: by 2002:a17:907:7291:b0:973:7096:60c2 with SMTP id dt17-20020a170907729100b00973709660c2mr12893054ejc.20.1686687300024; Tue, 13 Jun 2023 13:15:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686687300; cv=none; d=google.com; s=arc-20160816; b=NzrGto2JA8xflhKtHR+8TVeb56DjB649Fkom33a4QmiLh6kpyshftfCa5hzQlCIK9K a7xMyEU9Utx+bdXuIfAllFBhd2ax0O3YVX2WjPInoc0XXb8xQ7PUnSZnFP1Zgy8tUPLs QBHMtdaJr4Imx0Vh4lLIgrLuXhE3Y6zs+EXkuvOgRvR4Z6Dkn08zIzQAwPsO+QPai8TN cRE6uDATfQuAyZlcNTji5ABu5mwlezjMREkOk9sm6QZRDd3sSfJ9kMBT0DlhsrL0v+I1 +j2jHu/k/hGNF2sxIgV989JXBWEi5knTQr8crOJDOyaSJ0oCqCo8Qq1eejxEMtjLE+qf jwdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=H9jTYrOmd8b3J0G9R6tjbL0+izw0TOwkbJOEXGLG4+0=; b=yumQNFa2JF3Rv8fCGAO/jEcA6Yh9MEy/wrN6XSttilNXSUJ562JElL4N7KO3AYmtk9 F5bbsc5aShn04Vfppxv0ZANu8uRo6P9zFiA79chKeiOt7VC4A8nvw8Vl9C8kshaQNgFN 3PV6dk5AW13C0aWYfXBTB86SokIm7ojmupdW9jieJdQuaamAy765czQLV6Sr2FAGvE49 yFXDpnHSBuRG5yETM+C8Aa1mECi/jjQYy3k3U/UgiJ8do/wbq0CXWRBtnWmh33fEm1gv sTmoDQzVMnXhH+KYJvayKwsgRvLUKFWRZrSZlMkCc6BANvgh6h+FKcX+pXaPWvspnvHQ eZzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="jxX8Y/Xu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xo22-20020a170907bb9600b00976c99cc23csi6968909ejc.381.2023.06.13.13.14.35; Tue, 13 Jun 2023 13:15:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="jxX8Y/Xu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240002AbjFMUH1 (ORCPT <rfc822;lekhanya01809@gmail.com> + 99 others); Tue, 13 Jun 2023 16:07:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230221AbjFMUHY (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 13 Jun 2023 16:07:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AEC61BE8 for <linux-kernel@vger.kernel.org>; Tue, 13 Jun 2023 13:07:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 67BE761554 for <linux-kernel@vger.kernel.org>; Tue, 13 Jun 2023 20:07:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B1F0C433D9; Tue, 13 Jun 2023 20:07:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686686839; bh=cBzrkpEp4ssa1s3NzFCpArV7nF8Fv4V6npfoOqtTpFQ=; h=From:Date:Subject:To:Cc:From; b=jxX8Y/XuuLmoPqETf6kyvWegHhkrd9oKxJAY0IB33ftDOjcQkif8z8H7YsKIaIuGG rtL3eWjKloJpg/64Zl2n+V92gOlvbGxc/nSFZull1sypZ09yj/0kfz4hawSv6kk8Ef o0Ca9hLeLPr9zWboEAJhK+29nZUUm8PcrugYjpoy9BsqDhiJarXpJROrhZlXZ8ZRWD JdE3vwIbe4KtgUI0g4yV4uMIePgc2U+Rc3Tw/yTZshbmyicbX7BvHNWQdPTCbD7z0j OU1lyp6yINaHxjW8dON3LLpPrhJxgFdGPOFXdHH6Nf/GF8hznjRsmHtMdFLOa3stYR eR1KkA5ZNXKag== From: Mark Brown <broonie@kernel.org> Date: Tue, 13 Jun 2023 21:07:16 +0100 Subject: [PATCH] regmap: Check for register readability before checking cache during read MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230613-b4-regmap-check-readability-before-cache-v1-1-b144c0b01ed9@kernel.org> X-B4-Tracking: v=1; b=H4sIAHPMiGQC/x2OywqDMBBFf0Wy7oAxVWx/pbiYjBMz2EaZlD4Q/ 72xy3MuHO5mMqtwNtdqM8ovybKkAvZUGYqYJgYZC5umblzdWQf+DMrTA1egyDQXwBG93OX5Bc9 hUQbCMsEldG3vXI8tWVNyHjODV0wUj+B70fnQq3KQz//Bbdj3H4meuSiRAAAA To: linux-kernel@vger.kernel.org Cc: Mark Brown <broonie@kernel.org> X-Mailer: b4 0.13-dev-c6835 X-Developer-Signature: v=1; a=openpgp-sha256; l=1295; i=broonie@kernel.org; h=from:subject:message-id; bh=cBzrkpEp4ssa1s3NzFCpArV7nF8Fv4V6npfoOqtTpFQ=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBkiMx2Q1ZDGinfDW7oL7OUbC8y3p4UH2gOvcLAult3 6nq+NsaJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZIjMdgAKCRAk1otyXVSH0GSyB/ 4iAasEhoHy5gno6PFoPqaH1wwZlDHzctTNDPwNuGWE6MkKYtf3WMh2xPgEvsPX159CJDD6YrFusacT umaipFoS/CKQJSm5RfLoowk9UA288y6px9MT5KTlENS1CIywkhg/N0qRz3N7qXb1f943NDfiH+iun4 UdlQ8ztw47jI61/6zsIUvqsBSY3pAPg2Qar5/eKkeA2QE7lvcakNadyMuHUGy43MS+Lzv39BJvxDN8 nR3uBITpNQ6iDXmr5M+hrTteJdUj0RP31iMeMS4EDdyv/hhdX9fRPLQQ4S7PU5nmQZqLX0L0vEGYG1 TDT/j/K1PCLSY5AvTvvGdgMITTQVDV X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768619822338785719?= X-GMAIL-MSGID: =?utf-8?q?1768619822338785719?= |
Series |
regmap: Check for register readability before checking cache during read
|
|
Commit Message
Mark Brown
June 13, 2023, 8:07 p.m. UTC
Ensure that we don't return a spurious cache hit for unreadable registers
(eg, with the flat cache which doesn't understand sparseness) by checking
for readability before we do a cache lookup.
Signed-off-by: Mark Brown <broonie@kernel.org>
---
drivers/base/regmap/regmap.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
---
base-commit: 858fd168a95c5b9669aac8db6c14a9aeab446375
change-id: 20230613-b4-regmap-check-readability-before-cache-9f658338a5c1
Best regards,
Comments
On Tue, 13 Jun 2023 21:07:16 +0100, Mark Brown wrote: > Ensure that we don't return a spurious cache hit for unreadable registers > (eg, with the flat cache which doesn't understand sparseness) by checking > for readability before we do a cache lookup. > > Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next Thanks! [1/1] regmap: Check for register readability before checking cache during read commit: eab5abdeb79f0f694c007c3a76a97902705c86f0 All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark
On 13.06.2023 22:07, Mark Brown wrote: > Ensure that we don't return a spurious cache hit for unreadable registers > (eg, with the flat cache which doesn't understand sparseness) by checking > for readability before we do a cache lookup. > > Signed-off-by: Mark Brown <broonie@kernel.org> > --- (+CC Bjorn) Hi Mark, this patch breaks using regmap_field_force_write() on fields that are parts of registers marked as write-only (e.g. by regmap_access_table.no_ranges) Is that intended? What's the recommended fix? FWIW this breaks soc/qcom/icc-bwmon.c, causing an interrupt storm at boot due to the "clear the counters" register not being taken care of, so it'd be appreciated if we can sort this out quickly. Konrad > drivers/base/regmap/regmap.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c > index fa2d3fba6ac9..3efbe59ca1a7 100644 > --- a/drivers/base/regmap/regmap.c > +++ b/drivers/base/regmap/regmap.c > @@ -2897,6 +2897,9 @@ static int _regmap_read(struct regmap *map, unsigned int reg, > int ret; > void *context = _regmap_map_get_context(map); > > + if (!regmap_readable(map, reg)) > + return -EIO; > + > if (!map->cache_bypass) { > ret = regcache_read(map, reg, val); > if (ret == 0) > @@ -2906,9 +2909,6 @@ static int _regmap_read(struct regmap *map, unsigned int reg, > if (map->cache_only) > return -EBUSY; > > - if (!regmap_readable(map, reg)) > - return -EIO; > - > ret = map->reg_read(context, reg, val); > if (ret == 0) { > if (regmap_should_log(map)) > > --- > base-commit: 858fd168a95c5b9669aac8db6c14a9aeab446375 > change-id: 20230613-b4-regmap-check-readability-before-cache-9f658338a5c1 > > Best regards,
On Thu, Jun 15, 2023 at 10:45:53PM +0200, Konrad Dybcio wrote: > On 13.06.2023 22:07, Mark Brown wrote: > > Ensure that we don't return a spurious cache hit for unreadable registers > > (eg, with the flat cache which doesn't understand sparseness) by checking > > for readability before we do a cache lookup. > this patch breaks using regmap_field_force_write() on fields that are > parts of registers marked as write-only (e.g. by regmap_access_table.no_ranges) > Is that intended? > What's the recommended fix? Ugh, let's just drop it - it's just an optimisation.
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index fa2d3fba6ac9..3efbe59ca1a7 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -2897,6 +2897,9 @@ static int _regmap_read(struct regmap *map, unsigned int reg, int ret; void *context = _regmap_map_get_context(map); + if (!regmap_readable(map, reg)) + return -EIO; + if (!map->cache_bypass) { ret = regcache_read(map, reg, val); if (ret == 0) @@ -2906,9 +2909,6 @@ static int _regmap_read(struct regmap *map, unsigned int reg, if (map->cache_only) return -EBUSY; - if (!regmap_readable(map, reg)) - return -EIO; - ret = map->reg_read(context, reg, val); if (ret == 0) { if (regmap_should_log(map))