From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796055046; b=1kKiIUhYRrxHMUT+r7lhra00u9N10PEqDA3+vpFRHCtdkWWRU7fE5/HNnxMaIFBqI1Ny +kvlDi1xx5f38TlP9u1NTLQHEAwVoK5mlAALBWqXUWvooXUN1xPzhOnKjOp+JU1XIlaqH J0goKz5YDAoi7AEmmePGy/4CcVwnyOziRI2ulovtmawmAtv2S/xU3gcqO9g67YcN8n4MU vjLh8/yt8nblHHxkDPHzOvQ6LfZ2gceBvKcvexeG/y+071K5X37pJ+vuagzXCN2LAgKIL VzkVYiP6pau4QKxn+Fp5YPFughX6kuyJbFMHxEGZIwAa3Ki1aPFcmf4lFRbqMZUlJyw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796055046; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=AQerY+P4ueCywFpYTeZPTAWo1e9FZ+QvN/yCvqYJ860=; b=WE6Wwf0jLTHL9sybOy2JDMmn4GbWFzV7uj++Xz0GkQ66r3Pv8gW4nw5u8lTg4mOcxykk xhkCj4mgblVKcelPq0rbFoEG3WBnoctfjqjrCpd/j+uY1cl0eaEwHDztJzUwDxZkdYMv9 JF0dG1KDAtmCFFS4bfk9eFMsO4dxnD8hn+fVV1WFwVJD0Up/8sxZfFIe9rS6278cQutB3 crUcKLP00twcmNgwHLobJNFoNhIsJAkbD4SHHMw9k+KaeyIYDGrj1OA0oNSV3dEDfZsGy 1nlWU1Fn6QN6Ff9MM24yat6L+uvMlAOO73tpLcVg4CE0uE2SDqvEFnaZdTCoW3rrI0g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JnzR7TfU; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with UTF8SMTPS id 280DA606A325; Mon, 30 Nov 2026 16:10:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JnzR7TfU Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 182951F00897; Mon, 30 Nov 2026 16:10:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796055045; bh=AQerY+P4ueCywFpYTeZPTAWo1e9FZ+QvN/yCvqYJ860=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=JnzR7TfULC3Xnb+YJyojuk/6HJa6HnRjNxfcv1rgubGA3e0c2yyVQyc7/oD1mkV0u Fb0B7hXUr+31SmMlBnPHLb9KXoD0iKc4XFCuG9/91inGCPKZrjA9Uu/gb7Hd76mH/F 6brXfDZlqEXTzsG+6x0CmnD0DOwZQoCQt+BukLFsYnJfMvLWMcUkGvleK8YZKyGfu4 otQ33UAZ6VCtOPFHK7GVx4z0jndPdiDyi4N5z5XHwqIWElovK7KKvHvvtxcnEUSPZL /UjVINdAoKqKoNwnIrm2nCZCj5Fgjcaer5jR5Ci5czWwt8rmEjHkgjLvXhgMTTU3Yy V5mq3IANdz5xw== Date: Mon, 30 Nov 2026 17:10:43 +0100 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: keguang.zhang@gmail.com Cc: Binbin Zhou , linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v4 2/3] pwm: loongson: Reset the counters before enabling PWM Message-ID: References: <20260920-pwm-loongson-fix-v4-0-41b36b3c6497@gmail.com> <20260920-pwm-loongson-fix-v4-2-41b36b3c6497@gmail.com> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="j3qjadi5m6b34qon" Content-Disposition: inline In-Reply-To: <20260920-pwm-loongson-fix-v4-2-41b36b3c6497@gmail.com> --j3qjadi5m6b34qon Content-Type: text/plain; protected-headers=v1; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH v4 2/3] pwm: loongson: Reset the counters before enabling PWM MIME-Version: 1.0 On Sun, Sep 20, 2026 at 08:02:07PM +0800, Keguang Zhang via B4 Relay wrote: > From: Keguang Zhang >=20 > The PWM controller may retain its initial hardware state when the driver > binds. Reset the counters before enabling to ensure that the PWM starts > from a known state. >=20 > Fixes: 2b62c89448dd ("pwm: Add Loongson PWM controller support") > Fixes: 0de9b836a3bc ("pwm: loongson: Reload PWM configuration through cou= nter reset") > Cc: stable@vger.kernel.org > Suggested-by: Uwe Kleine-K=F6nig > Signed-off-by: Keguang Zhang > --- > drivers/pwm/pwm-loongson.c | 8 ++++++++ > 1 file changed, 8 insertions(+) >=20 > diff --git a/drivers/pwm/pwm-loongson.c b/drivers/pwm/pwm-loongson.c > index 7af5d4ce1060..977d867bdb8a 100644 > --- a/drivers/pwm/pwm-loongson.c > +++ b/drivers/pwm/pwm-loongson.c > @@ -110,6 +110,14 @@ static int pwm_loongson_enable(struct pwm_chip *chip= , struct pwm_device *pwm) > struct pwm_loongson_ddata *ddata =3D to_pwm_loongson_ddata(chip); > =20 > val =3D pwm_loongson_readl(ddata, LOONGSON_PWM_REG_CTRL); > + > + /* > + * Ensure that the values of LOW and PERIOD are sampled into > + * the shadow register when the hardware starts running. > + */ > + if (!(val & LOONGSON_PWM_CTRL_REG_RST)) > + pwm_loongson_writel(ddata, val | LOONGSON_PWM_CTRL_REG_RST, LOONGSON_P= WM_REG_CTRL); > + When the PWM transitions from one enabled state to another the driver doesn't go through pwm_loongson_disable() + pwm_loongson_enable(). The reference manual specifies to do that though (as I already noted in my review of patch #3). If this is kept (which might be ok if verified properly, and pointed out in a comment that this is against the recommendation of the docs), I wonder about If the register is reconfigured while PWM is running, it does not complete the currently running period. which is written at the top of the header. If the internel counter is not reset but stays at the current value it might happen to be bigger than the new period. What happens then? Best regards Uwe --j3qjadi5m6b34qon Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmsNoAEACgkQj4D7WH0S /k4M3Af/bdzRyQtAqgArbTAxryZh6kHf6wBtkFT2oBqylMf582BW05ApWC5YNnYv GXg6K8Bu+0BskANQ71ZW0BrHM88ux20oHbKqrk7hSPOKIZVk/Jt8EJb5xAMbleEQ iL20/BmfADU0O/Ig6K7H3NsBr/ThK5BXGCGI7OC1XfyQ7saLQDFNH0g962+07W7x +wmz0B7MLuYZU/1E7jfWGe8Ak2Bqnb7/7v4HLzY9SU1BRDG6GxUrWA/gn2OkhQlt Hkx0wDmZGlR8ZuIfXKzBFotjOaJWrxJTfjxlbA9Nmr6xmBjHNbT6E+7Ya7QfmwJV BzwRg/a3liJoG40wqqEXqoSMNFxOgw== =BMFT -----END PGP SIGNATURE----- --j3qjadi5m6b34qon--