Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1487039pxb; Thu, 4 Mar 2021 12:37:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxj5Vmx9qNklJlmZ0vPNH8V4q8oWuJUcUf6r2v0PR0tucybfv9gksebUo3srGVxvfb3Ge4 X-Received: by 2002:aa7:d8da:: with SMTP id k26mr6517118eds.364.1614890223435; Thu, 04 Mar 2021 12:37:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614890223; cv=none; d=google.com; s=arc-20160816; b=yNA4Eq75NxBHSepzjLVxYtHMRn5D/Th6ztEfZlcAl/XT4Nsp1h987aDNV42W8wDXm6 Vob5dIjzDo9h+KkMmbz07OCKrdqkmkysUdz8G5nHAMuZ4RGBdh2/aGDp7/naYglxbHKq 4Wsac8sMhyjyZDvLzQsFvNUZeFjRnw0QPSSgVRpdxC47KV015dh2Ige8vkJnwU91Dvrs DFkJugN4E6+1xn0de85RigbL4PfLyulLJIupc3pmM4A6ypp4fDna5QfFUG85R9i1tQqy 17bdg/4YckK+O/qul+kAEkjhfpZgDAcvi8RaA/bi3DsjdnpQsyVV0Oj5j2WunG2/dNjq yh/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=fiAnoFjzacA0imTnyoKZQv76RqIEHnX2/K6oUxFXX4o=; b=o+gwT069Vq4Xf7hBXppnqMzEbZwb58z8R2FeD1vO7qspa/GvOSCDO8NxQmwi9zW+y2 lLrd/DyOQOkCLJmARHASo1rgteRC2vYbi1Uu5fHRjkAqtLILlpwv5ZkakAewQ2cpRmQL TOtD3u1QG7y2j88Hf9lguGWdrNT0pcnMV4dCsDkAyFlSAU75MEAbrzxZ08k8iwovDDiK +qKsO2n+pz75H3tr9H8IMZXjH3fnfR1MhCI0UNS+eOaMPVp4LctHU/jYeVxct7rI4r0q GWdNVTNNacv4h1sNxJu0UjZ3jIfk6olyjh2vfWYN4hMjs03gWrI9sH5ZbFNpv2vP1TMV f3nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EPlDnykT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j17si420076edw.10.2021.03.04.12.36.39; Thu, 04 Mar 2021 12:37:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EPlDnykT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357454AbhCCKtw (ORCPT + 99 others); Wed, 3 Mar 2021 05:49:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234069AbhCBX4L (ORCPT ); Tue, 2 Mar 2021 18:56:11 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 992D9C0617A7; Tue, 2 Mar 2021 15:42:36 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id r5so14871392pfh.13; Tue, 02 Mar 2021 15:42:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=fiAnoFjzacA0imTnyoKZQv76RqIEHnX2/K6oUxFXX4o=; b=EPlDnykTEOFwrrNi3VCTr2D0NAu7wA6HUJXPlvXRoxdtGjJWxudI+EHEjlDB+QbLsL /Dig1CEWUEbkI86kKdzt2MkqboP2zo9p5Csz/+Bp78OpGBZ2juV1ImJ/YI5pAxX/PMDx d8FEHsjy6PZ2z//B1TSxK6Fdra/ml7/EVUhs7bIIz2Ryc2QCoapDQYdt9q1j4hFYKr0R MSBdBTwNeUYpM9WAZxbngXJ5T7zB9gX4KIx4Za2BF/3n1Wuj6qcqKDrRHkDrn+dDdvIx WXHNJpMM+dwLkAri+AhVMV0Z8nlRjUSKAoQNXtgdmWkwxaGCUBT99J5aDWzs7DnGlN9R 72cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=fiAnoFjzacA0imTnyoKZQv76RqIEHnX2/K6oUxFXX4o=; b=NkP/i5FFNvw1SfP1ujJHZIH7gnrzWvtlSxm7Zir6euK/FK52QeyWr5BkGdydaYeqpS lmOCSdammJhh6VjKQdtt3RqnDLcuLN8iR07hERPlv7caCCLLDTNdjEN+cbW9Rva9dGkx GqCMLV5/MLTWSS/TCmmmyHl3R2zNWK6wloyYlY3avnELwt0VkHRDkK4LURAKcT/Y2HDn /uULLuaWcBJ50qzMsfQS/SyrjHIVKlV8lfmjlQOKsVraHSJ7lFsujdeWIUtBGuBs8+rQ ECJXsnuxd7flNoy2wWRGBYFktAkwzUv01JO3xvmlSlZzCK4b8FSChYFfu9Ns8deUKWul Ov2w== X-Gm-Message-State: AOAM532TIDiNVXHSRWqXL5VIX8YBpZbQu1C6pvwS/Dw/f8VwDPkjpFmB BfvpBOM3QMNNQzyHFpWSVrNlcmc6FbU= X-Received: by 2002:a65:5c85:: with SMTP id a5mr19936436pgt.355.1614728556132; Tue, 02 Mar 2021 15:42:36 -0800 (PST) Received: from shinobu ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id h186sm21599877pgc.38.2021.03.02.15.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 15:42:35 -0800 (PST) Date: Wed, 3 Mar 2021 08:42:30 +0900 From: William Breathitt Gray To: Fabrice Gasnier Cc: jic23@kernel.org, david@lechnology.com, alexandre.torgue@foss.st.com, mcoquelin.stm32@gmail.com, olivier.moysan@foss.st.com, linux-iio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] counter: stm32-timer-cnt: fix ceiling write max value Message-ID: References: <1614696235-24088-1-git-send-email-fabrice.gasnier@foss.st.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="bCkxX5gdifsBCD9i" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --bCkxX5gdifsBCD9i Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Mar 02, 2021 at 06:03:25PM +0100, Fabrice Gasnier wrote: > On 3/2/21 3:56 PM, William Breathitt Gray wrote: > > Side question: if priv->ceiling is tracking the current ceiling > > configuration, would it make sense to change stm32_count_ceiling_read() > > to print the value of priv->ceiling instead of doing a regmap_read() > > call? >=20 > Hi William, >=20 > Thanks for reviewing. >=20 > I'd be fine either way. So no objection to move to the priv->ceiling > (cached) value. It could also here here. > By looking at this, I figured out there's probably another thing to fix > here, for initial conditions. >=20 > At probe time priv->ceiling is initialized to max value (ex 65535 for a > 16 bits counter). But the register content is 0 (clear by mfd driver at > probe time). >=20 > - So, reading ceiling from sysfs currently reports 0 (regmap_read()) > after booting and probing. >=20 > I see two cases at this point: > - In case the counter gets enabled without any prior configuration, it > won't count: ceiling value (e.g. 65535) should be written to register > before it is enabled, so the counter will actually count. So there's > room for a fix here. >=20 > - In case function gets set (ex: quadrature x4), priv->ceiling (e.g. > 65535) gets written to the register (although it's been read earlier as > 0 from sysfs). > This could be fixed by reading the priv->ceiling in > stm32_count_ceiling_read() as you're asking (provided 1st case has been > fixed as well) >=20 > I'll probably prepare one or two patches for the above cases, if you agre= e ? >=20 > Best Regards, > Fabrice Looking through the driver, it doesn't seem like priv->ceiling is used in any performance critical code, just the callbacks for count_write() and function_set(). It might make more sense to remove priv->ceiling and replace it with the regmap_read() calls where necessary so that we always get the most current ceiling value from the device when needed. As for the default ceiling value for the device at probe time, this should probably be set to the max value because that is what a normal user would expect when loading a Counter driver (a ceiling value of 0 at startup is somewhat unintuitive). If you prepare those two patches, then that should resolve this. William Breathitt Gray --bCkxX5gdifsBCD9i Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEk5I4PDJ2w1cDf/bghvpINdm7VJIFAmA+zVsACgkQhvpINdm7 VJJFfhAApkmoM+QVO5Ye1YiRiaPZVc4EraJ5xZXent7IGzIjHmwT8Z0mPz32vpVb XI3Wab4NSUGT49jZxArKseAB8Q0ifCezMxTzgV10vAXPX1M7ys8rkT1lKQ77nuI0 3FGOVhSFX2Np29B1+TNTQWL9MqoH/vRk+IyZmWlMfoy2UkmxHo4zDCnAvx157bOD ltBOol8XHodbZ4aSTooW5CnflMzPOetWEkc2w7BQ4MZaMJbQ8QGFTrTHd8N/V17+ KITYs3f0OHPBJL66O4+fLTfi66EZcy44OH+9+flDF2js8YZRX548z8T8yv6Vn2UK eFHR0f1RTmBjL1BH6qvRdqZtwiBit6S40wcm7OxmC8HcLswReWLKd74v/ObEw9N9 2IfRhWtY+xw/G1G68OR4fuAw4xxU9K+lGXBF1G/UnD5zGCdBfDEbE3sIyHvheKWk RnWlHD2KHfZlNL7e8pPabTHh/dX46D2NjAZbZTPYwB4y3vUPpbBaVJXH7TBAneEo odk96y8aXnd9HItyeHVdb60Ie38NUsAhl0XOqI6ntrJ/XHzLHIeO313BXJ5p0J6y WJRyrlJO8tZcl/K5KeQXohhuRRwmkAToM5GNvCPOn81tPMRZodNniuy59Y81PGaJ 5TQOBetBgKfy+I2EDWzzyFg7rQLBSG7d4wm6gHAqw9pO7RhjuXw= =uxhN -----END PGP SIGNATURE----- --bCkxX5gdifsBCD9i--