* FAILED: patch "[PATCH] pwm: jz4740: Enhance precision in calculation of duty cycle" failed to apply to 5.4-stable tree
@ 2020-06-19 13:45 gregkh
2020-06-23 0:39 ` Sasha Levin
0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2020-06-19 13:45 UTC (permalink / raw)
To: paul, stable, thierry.reding, u.kleine-koenig; +Cc: stable
The patch below does not apply to the 5.4-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 9017dc4fbd59c09463019ce494cfe36d654495a8 Mon Sep 17 00:00:00 2001
From: Paul Cercueil <paul@crapouillou.net>
Date: Wed, 27 May 2020 13:52:23 +0200
Subject: [PATCH] pwm: jz4740: Enhance precision in calculation of duty cycle
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Calculating the hardware value for the duty from the hardware value of
the period resulted in a precision loss versus calculating it from the
clock rate directly.
(Also remove a cast that doesn't really need to be here)
Fixes: f6b8a5700057 ("pwm: Add Ingenic JZ4740 support")
Cc: <stable@vger.kernel.org>
Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c
index 3cd5c054ad9a..4fe9d99ac9a9 100644
--- a/drivers/pwm/pwm-jz4740.c
+++ b/drivers/pwm/pwm-jz4740.c
@@ -158,11 +158,11 @@ static int jz4740_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
/* Calculate period value */
tmp = (unsigned long long)rate * state->period;
do_div(tmp, NSEC_PER_SEC);
- period = (unsigned long)tmp;
+ period = tmp;
/* Calculate duty value */
- tmp = (unsigned long long)period * state->duty_cycle;
- do_div(tmp, state->period);
+ tmp = (unsigned long long)rate * state->duty_cycle;
+ do_div(tmp, NSEC_PER_SEC);
duty = period - tmp;
if (duty >= period)
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: FAILED: patch "[PATCH] pwm: jz4740: Enhance precision in calculation of duty cycle" failed to apply to 5.4-stable tree 2020-06-19 13:45 FAILED: patch "[PATCH] pwm: jz4740: Enhance precision in calculation of duty cycle" failed to apply to 5.4-stable tree gregkh @ 2020-06-23 0:39 ` Sasha Levin 2020-06-23 7:25 ` Uwe Kleine-König 0 siblings, 1 reply; 4+ messages in thread From: Sasha Levin @ 2020-06-23 0:39 UTC (permalink / raw) To: gregkh; +Cc: paul, stable, thierry.reding, u.kleine-koenig On Fri, Jun 19, 2020 at 03:45:07PM +0200, gregkh@linuxfoundation.org wrote: > >The patch below does not apply to the 5.4-stable tree. >If someone wants it applied there, or to any other stable or longterm >tree, then please email the backport, including the original git commit >id to <stable@vger.kernel.org>. > >thanks, > >greg k-h > >------------------ original commit in Linus's tree ------------------ > >From 9017dc4fbd59c09463019ce494cfe36d654495a8 Mon Sep 17 00:00:00 2001 >From: Paul Cercueil <paul@crapouillou.net> >Date: Wed, 27 May 2020 13:52:23 +0200 >Subject: [PATCH] pwm: jz4740: Enhance precision in calculation of duty cycle >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Calculating the hardware value for the duty from the hardware value of >the period resulted in a precision loss versus calculating it from the >clock rate directly. > >(Also remove a cast that doesn't really need to be here) > >Fixes: f6b8a5700057 ("pwm: Add Ingenic JZ4740 support") >Cc: <stable@vger.kernel.org> >Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> >Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> >Signed-off-by: Paul Cercueil <paul@crapouillou.net> >Signed-off-by: Thierry Reding <thierry.reding@gmail.com> I suspect that the fixes tag should have been pointing to ce1f9cece057 ("pwm: jz4740: Use clocks from TCU driver") instead. -- Thanks, Sasha ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: FAILED: patch "[PATCH] pwm: jz4740: Enhance precision in calculation of duty cycle" failed to apply to 5.4-stable tree 2020-06-23 0:39 ` Sasha Levin @ 2020-06-23 7:25 ` Uwe Kleine-König 2020-06-23 12:21 ` Greg KH 0 siblings, 1 reply; 4+ messages in thread From: Uwe Kleine-König @ 2020-06-23 7:25 UTC (permalink / raw) To: Sasha Levin; +Cc: gregkh, paul, stable, thierry.reding [-- Attachment #1: Type: text/plain, Size: 3599 bytes --] On Mon, Jun 22, 2020 at 08:39:43PM -0400, Sasha Levin wrote: > On Fri, Jun 19, 2020 at 03:45:07PM +0200, gregkh@linuxfoundation.org wrote: > > > > The patch below does not apply to the 5.4-stable tree. > > If someone wants it applied there, or to any other stable or longterm > > tree, then please email the backport, including the original git commit > > id to <stable@vger.kernel.org>. See below for a backport. > > thanks, > > > > greg k-h > > > > ------------------ original commit in Linus's tree ------------------ > > > > From 9017dc4fbd59c09463019ce494cfe36d654495a8 Mon Sep 17 00:00:00 2001 > > From: Paul Cercueil <paul@crapouillou.net> > > Date: Wed, 27 May 2020 13:52:23 +0200 > > Subject: [PATCH] pwm: jz4740: Enhance precision in calculation of duty cycle > > MIME-Version: 1.0 > > Content-Type: text/plain; charset=UTF-8 > > Content-Transfer-Encoding: 8bit > > > > Calculating the hardware value for the duty from the hardware value of > > the period resulted in a precision loss versus calculating it from the > > clock rate directly. > > > > (Also remove a cast that doesn't really need to be here) > > > > Fixes: f6b8a5700057 ("pwm: Add Ingenic JZ4740 support") > > Cc: <stable@vger.kernel.org> > > Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > > Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > > Signed-off-by: Paul Cercueil <paul@crapouillou.net> > > Signed-off-by: Thierry Reding <thierry.reding@gmail.com> > > I suspect that the fixes tag should have been pointing to ce1f9cece057 > ("pwm: jz4740: Use clocks from TCU driver") instead. No, f6b8a5700057 is right. The cast that was dropped isn't there, but the suboptimal calculation is. The backport on top of 5.4.y looks as follows: From b39d3d4c6ba4b7ba8b97a0f7e650924920e4d95c Mon Sep 17 00:00:00 2001 From: Paul Cercueil <paul@crapouillou.net> Date: Wed, 27 May 2020 13:52:23 +0200 Subject: [PATCH] pwm: jz4740: Enhance precision in calculation of duty cycle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 9017dc4fbd59c09463019ce494cfe36d654495a8 upstream. Calculating the hardware value for the duty from the hardware value of the period resulted in a precision loss versus calculating it from the clock rate directly. Fixes: f6b8a5700057 ("pwm: Add Ingenic JZ4740 support") Cc: <stable@vger.kernel.org> Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Paul Cercueil <paul@crapouillou.net> Signed-off-by: Thierry Reding <thierry.reding@gmail.com> [ukl: backport to v5.4.y and adapt commit log accordingly] Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/pwm/pwm-jz4740.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c index 9d78cc21cb12..d0f5c69930d0 100644 --- a/drivers/pwm/pwm-jz4740.c +++ b/drivers/pwm/pwm-jz4740.c @@ -108,8 +108,8 @@ static int jz4740_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, if (prescaler == 6) return -EINVAL; - tmp = (unsigned long long)period * state->duty_cycle; - do_div(tmp, state->period); + tmp = (unsigned long long)rate * state->duty_cycle; + do_div(tmp, NSEC_PER_SEC); duty = period - tmp; if (duty >= period) -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ | [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: FAILED: patch "[PATCH] pwm: jz4740: Enhance precision in calculation of duty cycle" failed to apply to 5.4-stable tree 2020-06-23 7:25 ` Uwe Kleine-König @ 2020-06-23 12:21 ` Greg KH 0 siblings, 0 replies; 4+ messages in thread From: Greg KH @ 2020-06-23 12:21 UTC (permalink / raw) To: Uwe Kleine-König; +Cc: Sasha Levin, paul, stable, thierry.reding On Tue, Jun 23, 2020 at 09:25:34AM +0200, Uwe Kleine-König wrote: > On Mon, Jun 22, 2020 at 08:39:43PM -0400, Sasha Levin wrote: > > On Fri, Jun 19, 2020 at 03:45:07PM +0200, gregkh@linuxfoundation.org wrote: > > > > > > The patch below does not apply to the 5.4-stable tree. > > > If someone wants it applied there, or to any other stable or longterm > > > tree, then please email the backport, including the original git commit > > > id to <stable@vger.kernel.org>. > > See below for a backport. > > > > thanks, > > > > > > greg k-h > > > > > > ------------------ original commit in Linus's tree ------------------ > > > > > > From 9017dc4fbd59c09463019ce494cfe36d654495a8 Mon Sep 17 00:00:00 2001 > > > From: Paul Cercueil <paul@crapouillou.net> > > > Date: Wed, 27 May 2020 13:52:23 +0200 > > > Subject: [PATCH] pwm: jz4740: Enhance precision in calculation of duty cycle > > > MIME-Version: 1.0 > > > Content-Type: text/plain; charset=UTF-8 > > > Content-Transfer-Encoding: 8bit > > > > > > Calculating the hardware value for the duty from the hardware value of > > > the period resulted in a precision loss versus calculating it from the > > > clock rate directly. > > > > > > (Also remove a cast that doesn't really need to be here) > > > > > > Fixes: f6b8a5700057 ("pwm: Add Ingenic JZ4740 support") > > > Cc: <stable@vger.kernel.org> > > > Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > > > Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > > > Signed-off-by: Paul Cercueil <paul@crapouillou.net> > > > Signed-off-by: Thierry Reding <thierry.reding@gmail.com> > > > > I suspect that the fixes tag should have been pointing to ce1f9cece057 > > ("pwm: jz4740: Use clocks from TCU driver") instead. > > No, f6b8a5700057 is right. The cast that was dropped isn't there, but > the suboptimal calculation is. > > The backport on top of 5.4.y looks as follows: > > From b39d3d4c6ba4b7ba8b97a0f7e650924920e4d95c Mon Sep 17 00:00:00 2001 > From: Paul Cercueil <paul@crapouillou.net> > Date: Wed, 27 May 2020 13:52:23 +0200 > Subject: [PATCH] pwm: jz4740: Enhance precision in calculation of duty cycle > MIME-Version: 1.0 > Content-Type: text/plain; charset=UTF-8 > Content-Transfer-Encoding: 8bit > > commit 9017dc4fbd59c09463019ce494cfe36d654495a8 upstream. > > Calculating the hardware value for the duty from the hardware value of > the period resulted in a precision loss versus calculating it from the > clock rate directly. > > Fixes: f6b8a5700057 ("pwm: Add Ingenic JZ4740 support") > Cc: <stable@vger.kernel.org> > Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > Signed-off-by: Paul Cercueil <paul@crapouillou.net> > Signed-off-by: Thierry Reding <thierry.reding@gmail.com> > [ukl: backport to v5.4.y and adapt commit log accordingly] > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > --- > drivers/pwm/pwm-jz4740.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c > index 9d78cc21cb12..d0f5c69930d0 100644 > --- a/drivers/pwm/pwm-jz4740.c > +++ b/drivers/pwm/pwm-jz4740.c > @@ -108,8 +108,8 @@ static int jz4740_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > if (prescaler == 6) > return -EINVAL; > > - tmp = (unsigned long long)period * state->duty_cycle; > - do_div(tmp, state->period); > + tmp = (unsigned long long)rate * state->duty_cycle; > + do_div(tmp, NSEC_PER_SEC); > duty = period - tmp; > > if (duty >= period) > Thanks, now queued up. greg k-h ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-06-23 12:21 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-06-19 13:45 FAILED: patch "[PATCH] pwm: jz4740: Enhance precision in calculation of duty cycle" failed to apply to 5.4-stable tree gregkh 2020-06-23 0:39 ` Sasha Levin 2020-06-23 7:25 ` Uwe Kleine-König 2020-06-23 12:21 ` Greg KH
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.