Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp266833lqn; Fri, 12 Apr 2024 00:07:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUhter51a8JX4xymnaN0GmSOJLjbqLH4KPfCuBLhgulCEVpJkkThoM7SWA9BqznJVGgeDVglF1NfCcWEh7MmOdCcpOmvTfQbgitTI6v3A== X-Google-Smtp-Source: AGHT+IHlbvo+FamztafQdRy2iacfLKYwBZwfKJ3HsTrzxZ+MckZlIcOQRXRjPwFjrQ2xsxw+6NkU X-Received: by 2002:a0d:cc03:0:b0:615:17f3:55e9 with SMTP id o3-20020a0dcc03000000b0061517f355e9mr1639663ywd.15.1712905659606; Fri, 12 Apr 2024 00:07:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712905659; cv=pass; d=google.com; s=arc-20160816; b=u/+t6Zc9Zb3tYcUVL6WOifq3P5rlybpAfMuIFjXRX3esVb8sVj3kLZ/99tq7JhVrvD OpbdxilO2jS+xUrSr9F78a+5UfbukorGk0bKsQu7lTm/c+mKeoOzL3MnEHluDc/lH6TT wvdZEzSYYVxnV/9umEqf7nz3to5WJLu2EAGZhZZUDg3HVpOcTFkuOo6gyEUdGjPdz2MU Ob1IcZutioXWxlooDPE6MhnW6sd2ELOnaxP19E8gZtAeeep2mv7JQ3p9jo+rO/Q34MD6 jSGeOS2h4lZ4PqsFL0VJdtxdRZ027y99AqMqvekf/APISEWxl+1xiURQ3wZ/AaKsvY7/ OUhw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=YYORLWAvhwHAr8B5pflXKd2EwP6cGhtlOKRJmXB64mw=; fh=wArVu5OKVZMaGn4FP6E6GnmFn3I2/GahAiXSpV3u1VI=; b=XV/+Hl78qatnVADg1eC+4/JTl20GLqpg5RuVRKiRLDUFkWL4uG0qWQ//zxMqL3BIzf QlHQnF6mcov4fKesYmowAzpTGE3ygUl3soMBWrxvu2P6sZUrjcQwZK4wwxIk3WRxss4P eOmY0l7Fvzp+n+wIGnP5w6m5nazYzs9QmEJMoYB10o86M5jGMX6RwNzgt+Rk8WOHqrAs wjxnRrROUlRVUa7Vxc2kKf02jPqR6MqghYK8SomWLEc8hhhXSZTE5ILBDEX3u0rVbNyF jlgo0oBO1LSBuwoXDv/sJ+MWzulNHgWVrOyDcE3qMkx5YyTEOm7Bfktqi9PWImtBMSiW pCWQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-142106-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142106-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id vv7-20020a05620a562700b0078ec559475esi2263566qkn.750.2024.04.12.00.07.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:07:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142106-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-142106-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142106-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3C1721C210D3 for ; Fri, 12 Apr 2024 07:07:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 85F8452F70; Fri, 12 Apr 2024 07:05:40 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82B0452F99 for ; Fri, 12 Apr 2024 07:05:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712905540; cv=none; b=qqnDQlq9tc1IujvZ8H3RJTzKC9ifn5x8PQwq84FcmcLEYAfj5n1YGwyLr1vu8roP30BTkGDb2LMU2CE5FlYGHSqast6oN2VwMeTsgPxwc/hONiRjW1XyHFJoFxXK3TCbc8MmfrG0OWWA2uPpVaTbfi/iSVv3pZucjKb4/ccrwWw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712905540; c=relaxed/simple; bh=xibTtOM7xMiZd16Ap7dAaQ4ltDSATcoqeP9GxusGiIs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cLUeN0y3s0aTG9TvmRXo/Zl5W35WdHVH0WbHORj3uRATAyMUJgga7bQKR4Onra6Zh/iPAmauGvrtNnHCOhOH8DMJzMRTFowF6rautsvQKkKKJ4pscEIPC4XSWz1H5cnk0TBUgnZUyzjlB4A9f8K+gDVOvqH2ztETpOFzgoUsj2k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rvAyb-0002TQ-3q; Fri, 12 Apr 2024 09:05:33 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rvAya-00Bpko-Dt; Fri, 12 Apr 2024 09:05:32 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rvAya-0011ip-14; Fri, 12 Apr 2024 09:05:32 +0200 Date: Fri, 12 Apr 2024 09:05:32 +0200 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Nylon Chen Cc: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, conor@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu, thierry.reding@gmail.com, vincent.chen@sifive.com, zong.li@sifive.com, nylon7717@gmail.com Subject: Re: [PATCH v9 3/3] pwm: sifive: Fix the error in the idempotent test within the pwm_apply_state_debug function Message-ID: References: <20240222081231.213406-1-nylon.chen@sifive.com> <20240222081231.213406-4-nylon.chen@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="q2q3dixgumi352xf" Content-Disposition: inline In-Reply-To: X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org --q2q3dixgumi352xf Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 02, 2024 at 10:01:39AM +0800, Nylon Chen wrote: > Uwe Kleine-K=C3=B6nig =E6=96=BC 2024=E5= =B9=B43=E6=9C=8819=E6=97=A5 =E9=80=B1=E4=BA=8C =E4=B8=8A=E5=8D=882:17=E5=AF= =AB=E9=81=93=EF=BC=9A > > > > Hello, > > > > On Thu, Feb 22, 2024 at 04:12:31PM +0800, Nylon Chen wrote: > > > Round the result to the nearest whole number. This ensures that > > > real_period is always a reasonable integer that is not lower than the > > > actual value. > > > > > > e.g. > > > $ echo 110 > /sys/devices/platform/led-controller-1/leds/d12/brightne= ss > > > $ .apply is not idempotent (ena=3D1 pol=3D0 1739692/4032985) -> (ena= =3D1 pol=3D0 1739630/4032985) > > > > > > Co-developed-by: Zong Li > > > Signed-off-by: Zong Li > > > Signed-off-by: Nylon Chen > > > --- > > > drivers/pwm/pwm-sifive.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c > > > index a586cfe4191b..bebcbebacccd 100644 > > > --- a/drivers/pwm/pwm-sifive.c > > > +++ b/drivers/pwm/pwm-sifive.c > > > @@ -101,7 +101,7 @@ static void pwm_sifive_update_clock(struct pwm_si= five_ddata *ddata, > > > > > > /* As scale <=3D 15 the shift operation cannot overflow. */ > > > num =3D (unsigned long long)NSEC_PER_SEC << (PWM_SIFIVE_CMPWIDT= H + scale); > > > - ddata->real_period =3D div64_ul(num, rate); > > > + ddata->real_period =3D DIV_ROUND_UP_ULL(num, rate); > > > dev_dbg(ddata->chip.dev, > > > "New real_period =3D %u ns\n", ddata->real_period); > > > } > Hi Uwe > > > > pwm_sifive_apply has a DIV64_U64_ROUND_CLOSEST(). I wonder if that needs > > adaption, too?! > According to my experiments, no adjustment is necessary. Did you enable PWM_DEBUG and tested with something like: seq 5000 100000 | while read p; do echo p > /sys/class/pwm/pwmchipX/pwmY/p= eriod; done and then verified that this test didn't result in kernel messages about wrong settings? Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=C3=B6nig = | Industrial Linux Solutions | https://www.pengutronix.de/ | --q2q3dixgumi352xf Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmYY3TsACgkQj4D7WH0S /k5FmwgAhyTeX2Ko0mzYcNZo9k+LH+bFP8d3VU9un+janzbRfN4UG64QH80Ls1jD 1lWgqzrf5b9lxnjZqX58GN92ZEbi7F78BS5FyTZT+cQieFtdunkHI1SPXBa2ujhX NaLiKPSuxY6HTwDvNhkFLo0hJ9SEVXhWKfZBRdKI2pKDYbkMuqSQYOkL5UQcia9V 3LJCyqVdJemdb1AfTHMCM0wJxx7MJlDE/WIZVISQFI05FQ8ttx/61zQ5ehIaVvAZ 0+YhpDDxiGpiy6RVDTfaF48m0y49BUQ6vU4C+H2awBayeFgjeM6SIxq0aQLgyLC9 vtD3qVxYIgKze58pKVRfmGyQ4BINxg== =jwk9 -----END PGP SIGNATURE----- --q2q3dixgumi352xf--