Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4487393imw; Tue, 19 Jul 2022 07:31:59 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vDI9rplTIozXyQEJ3a2ZSkDFvQM480xuHmGCQrtRbKw5Z1GDgZMEaSLxHDJNiwfAp9DZVi X-Received: by 2002:a17:907:970c:b0:72e:e972:5c73 with SMTP id jg12-20020a170907970c00b0072ee9725c73mr22394050ejc.352.1658241119580; Tue, 19 Jul 2022 07:31:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658241119; cv=none; d=google.com; s=arc-20160816; b=d5THzODq52kl3xKm5i78kNwoReEohbR9xpgFeXl8R0JnKsGE2H8UUGWxsGMO8GIOP8 3Mge8ILg1ClX2B3mBM9YXVSvCLqJ2ZrkgtxBqSgn/vfnFvHzHx0+53bns9FPKwh3yWcJ DQ/PwdNjxfBBWT4Ezt5Dqc/GiTvtCoPWiseVxVaXBkxZQ2IoVsy++LYOw3iPE1WJpcGk wQzOIxM9G+u5IRXRhAi7llCnSFmHwA0ImlDvFxrCiOAilBYuRI2JkjCk2KNybJn7t/6e nO/G2zUVbXD2vnC7Ti/7WfrMdh6bOHfqyMQyrN+45JnWDTap8nQSsGVboEBCzFV1LenG 3reg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=1iHcTYklM2n0jgLIgnKXAIqlrCeQtsoN+7ckvKvL4qs=; b=CgH2Pzcb+glc5Rin5nrxwBlCUwJcFb4Fg6pou+3g73bsSzfxp2UDYwahHF78THzabI JjoBJWh8h8JQNaNeiZo7oL9qzW3pOXoIY3/5MAley0JRnMu++p533IHSNLN2Z0Ti5e2I hHu4gyQT/+V8gGHrqY2pqsAS0P0UDoc7Cj+rU28mc92+a9H1XVRguPYq3w5f7pup0osq 3FY6WrnnBkv4LnMDI7khsfmtpvJPRgh2t5lBCdOzdTZ3iFNi/3HRoTPaPCqYfFkiWR2A LyK2jwmfjx6Lk1ZdB8QnbIYSdjUyZOUJZz4sG93R4YnHWROs0kOX+FtO1SIodrN+KnNc faqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=XGSiDLoU; 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=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn17-20020a1709070d1100b0072b6ef5fff3si22117492ejc.605.2022.07.19.07.31.34; Tue, 19 Jul 2022 07:31:59 -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=@cirrus.com header.s=PODMain02222019 header.b=XGSiDLoU; 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=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238281AbiGSOVS (ORCPT + 99 others); Tue, 19 Jul 2022 10:21:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241195AbiGSOPX (ORCPT ); Tue, 19 Jul 2022 10:15:23 -0400 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E879F72BEC for ; Tue, 19 Jul 2022 06:43:00 -0700 (PDT) Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26JBQGF5017217; Tue, 19 Jul 2022 08:42:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=PODMain02222019; bh=1iHcTYklM2n0jgLIgnKXAIqlrCeQtsoN+7ckvKvL4qs=; b=XGSiDLoU/mlSIQR+TSb0PRrfbM+GLI8zwV8/oopuG9KkteqEvuRdRcpj+MZ1Fad/qS3S 60mvw2/9429givTRB+NWffWhzNs4/8+QELWfk3X53dQXtaeS1KzXtM3A7cv1gEkLJkRB U1Cvef/XbwXCbMjvGgyXZ3ZcaR681MosuzzW3x3fZ/p2/lxZdEdW+kf6aO2vwP0tuKoH 21RdGsg8YF4vUy2j7a8s/YzqWbEfJ2nc2ybWgxYgOvLboAHRNqPjR7SW1O/omocDL+Sf 3wyc7yloPggKuP0zKAcdw3DeJyz2BhfeF6GLz/2fOtiM0MNKXGcqR01A61WUKda/9kTq Pg== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3hdrqfgd8b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 19 Jul 2022 08:42:53 -0500 Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.9; Tue, 19 Jul 2022 08:42:51 -0500 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by anon-ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1118.9 via Frontend Transport; Tue, 19 Jul 2022 08:42:51 -0500 Received: from ediswmail.ad.cirrus.com (ediswmail.ad.cirrus.com [198.61.86.93]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 57048477; Tue, 19 Jul 2022 13:42:51 +0000 (UTC) Date: Tue, 19 Jul 2022 13:42:51 +0000 From: Charles Keepax To: Krzysztof Kozlowski CC: Mark Brown , Greg Kroah-Hartman , "Rafael J. Wysocki" , , Srinivas Kandagatla , Kuninori Morimoto , Bjorn Andersson Subject: Re: [PATCH] regmap: support regmap_field_write() on non-readable fields Message-ID: <20220719134251.GB92394@ediswmail.ad.cirrus.com> References: <20220719121446.375095-1-krzysztof.kozlowski@linaro.org> <20220719125401.GA92394@ediswmail.ad.cirrus.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Proofpoint-ORIG-GUID: JNOgdpDeByc8GS1rmj71ADqVrXMhhYcN X-Proofpoint-GUID: JNOgdpDeByc8GS1rmj71ADqVrXMhhYcN X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 Tue, Jul 19, 2022 at 03:13:11PM +0200, Krzysztof Kozlowski wrote: > On 19/07/2022 14:54, Charles Keepax wrote: > > On Tue, Jul 19, 2022 at 02:14:46PM +0200, Krzysztof Kozlowski wrote: > >> Current implementation of regmap_field_write() performs an update of > >> register (read+write), therefore it ignores regmap read-restrictions and > >> is not suitable for write-only registers (e.g. interrupt clearing). > >> > >> Extend regmap_field_write() and regmap_field_force_write() to check if > >> register is readable and only then perform an update. In the other > >> case, it is expected that mask of field covers entire register thus a > >> full write is allowed. > >> > >> Signed-off-by: Krzysztof Kozlowski > >> > >> --- > >> + if (regmap_readable(field->regmap, field->reg)) > >> + return regmap_update_bits_base(field->regmap, field->reg, > >> + mask, val << field->shift, > >> + change, async, force); > >> + > > > > I think this will break other valid use-cases, regmap_readable (I > > believe) returns if the register is physically readable, however > > it should still be possible to use update bits if the register is > > in the cache even if it can't physically be read. So really you > > need to fall into this path if it is readable or in the cache. > > But what type of real use case this would be trying to solve? Either > register is readable or not. The presence of cache is just optimization > and does not change the fact that we cannot read from register thus no > need to go via updates. > > > > > Which does I guess also raise the question if your problem would > > be better solved with caching the register? > > And how the value would appear in the cache? Since register cannot be > read, I expect the cache to be filled on first update. First update > would be read+write, so we are stuck again. > The cache is initialised from the defaults table, so normal proceedure for unreadable registers is you start out with the hardware default and since you know when you wrote it the value stays in sync. Thanks, Charles