Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1666733rwd; Thu, 15 Jun 2023 13:56:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ChH21+wM7T3k/L2sDn8O8PtRRcZb4ZumfaZl7LRRZY4sssfVAd3+ohB05/msfshItTHfW X-Received: by 2002:a05:6359:c29:b0:129:c394:ef62 with SMTP id gn41-20020a0563590c2900b00129c394ef62mr14982604rwb.16.1686862614044; Thu, 15 Jun 2023 13:56:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686862614; cv=none; d=google.com; s=arc-20160816; b=FeUycWc9U13sUffvD3my1Y2XgbnLI0siKItqIZj/nQshXzMbvGsaE2HJc/c2+r5v1u kDDD0siw/kA6R7GUe82TIjeDVnB1zLpbIfvAFEvwyqORwpHWJbdD/oqJzFt0UHeJ+PvM 0Usy6dSnF4U2MIFvCIa3Jp1FyxGD6NZm26q4PWfnbhDrwzLrEZGkXqrm/8EDbTy1qF99 Vy8Rj6YOJxiAU5vkAuGPOIqnpsGh1CHgR3zdZwBvyTB27kpZmCvnNkli8OTL1BVTusVl ZZ++n1mH+dAN0m5CtMLewOjxOKni4yw3bFzz+8CVwjpv3522SOWrwb9ViP4tIVh1s0Yo HmGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from:cc :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=4GRBLErb6cuIgbtU5P67VozPo5Us+dXD6G6zW7zdEbw=; b=tbmCpW/ltunEW34wH+7ZYdeA456gqn0hZLhU3uQZ9O0dGQVG0ewQd4o/+lrRn8AlxI 296xZSHvoCu677ZYI+k98j54xBqT+ZY1HKBxieWu7oSNqpEcjyHb9nRlIA5zZhVUt9hl As8CRqDAyrA3YT4Rd5uOwKEviSegSIkwikAeZ5uSBZRswdCRS40XYS7riSBr4FIwZfhv 45mOzjle25sXGGIsFiElp/pVfjWcEHO235z8vYXeKhXR3sfShK6WUACcYlp5YKsZSw5u y7ec8994GVWMLJuLobKtaan0BPJH3KU89aXmBtvb6CM2P4lFquuRi6BXTkRp2elS0q33 OQ6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ILI0n7N5; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q193-20020a632aca000000b0053fc9f253basi4242093pgq.403.2023.06.15.13.56.39; Thu, 15 Jun 2023 13:56:53 -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=ILI0n7N5; 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 S229719AbjFOUp7 (ORCPT + 99 others); Thu, 15 Jun 2023 16:45:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbjFOUp6 (ORCPT ); Thu, 15 Jun 2023 16:45:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80F7F26AA for ; Thu, 15 Jun 2023 13:45:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 166DD60F90 for ; Thu, 15 Jun 2023 20:45:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8929C433C8; Thu, 15 Jun 2023 20:45:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686861956; bh=4kFWV9+xv5jLSm4U5yuODKQvD7AuhX6h1oB5batCmX0=; h=Date:Subject:To:References:Cc:From:In-Reply-To:From; b=ILI0n7N5PkVo1QKZhgos9zEUJzNQl5Sog0tSUKB/ACsfRmt+Ds5rFK+4lUruEpZlz 4QH7SBxihgDuiKmKot2AkCdgqyjIQIEkZGQr2Tx7d+KRopRHn2WG6z03fnQPhfqOPh YwLKE4BR+KzeZJPubD4oGrWjm+dsOetdw8rn/jc0WIh1BTzW9fIvcbQpTQUqlnSn70 9Wbfo1cULYm98sPlMM2M13BK3075p6rZrFejx4Fe0B/xKZSDu6X/TPMemEcwLS6IU/ lzZpoTYcGSw7mWwzPC+90tZDpLqCEs8lbpmrE9dr0orM821swnQHXoUSf5XgTex4Wc 7bUHoDH+WAjog== Message-ID: Date: Thu, 15 Jun 2023 22:45:53 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: [PATCH] regmap: Check for register readability before checking cache during read Content-Language: en-US To: Mark Brown , lkml References: <20230613-b4-regmap-check-readability-before-cache-v1-1-b144c0b01ed9@kernel.org> Cc: Bjorn Andersson From: Konrad Dybcio In-Reply-To: <20230613-b4-regmap-check-readability-before-cache-v1-1-b144c0b01ed9@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,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: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- (+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,