From: Greg Kroah-Hartman Date: Thu, 28 Jan 2021 13:13:24 +0000 (+0100) Subject: 4.14-stable patches X-Git-Tag: v4.4.254~27 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ed0ae7a37e45c8a375f59f2420189d08f600d2e0;p=thirdparty%2Fkernel%2Fstable-queue.git 4.14-stable patches added patches: gpio-mvebu-fix-pwm-.get_state-period-calculation.patch --- diff --git a/queue-4.14/gpio-mvebu-fix-pwm-.get_state-period-calculation.patch b/queue-4.14/gpio-mvebu-fix-pwm-.get_state-period-calculation.patch new file mode 100644 index 00000000000..a95711ba308 --- /dev/null +++ b/queue-4.14/gpio-mvebu-fix-pwm-.get_state-period-calculation.patch @@ -0,0 +1,80 @@ +From e73b0101ae5124bf7cd3fb5d250302ad2f16a416 Mon Sep 17 00:00:00 2001 +From: Baruch Siach +Date: Sun, 17 Jan 2021 15:17:02 +0200 +Subject: gpio: mvebu: fix pwm .get_state period calculation +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Baruch Siach + +commit e73b0101ae5124bf7cd3fb5d250302ad2f16a416 upstream. + +The period is the sum of on and off values. That is, calculate period as + + ($on + $off) / clkrate + +instead of + + $off / clkrate - $on / clkrate + +that makes no sense. + +Reported-by: Russell King +Reviewed-by: Uwe Kleine-König +Fixes: 757642f9a584e ("gpio: mvebu: Add limited PWM support") +Signed-off-by: Baruch Siach +Signed-off-by: Bartosz Golaszewski +[baruch: backport to kernels <= v5.10] +Reviewed-by: Uwe Kleine-König +Signed-off-by: Baruch Siach +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/gpio/gpio-mvebu.c | 25 ++++++++++--------------- + 1 file changed, 10 insertions(+), 15 deletions(-) + +--- a/drivers/gpio/gpio-mvebu.c ++++ b/drivers/gpio/gpio-mvebu.c +@@ -654,9 +654,8 @@ static void mvebu_pwm_get_state(struct p + + spin_lock_irqsave(&mvpwm->lock, flags); + +- val = (unsigned long long) +- readl_relaxed(mvebu_pwmreg_blink_on_duration(mvpwm)); +- val *= NSEC_PER_SEC; ++ u = readl_relaxed(mvebu_pwmreg_blink_on_duration(mvpwm)); ++ val = (unsigned long long) u * NSEC_PER_SEC; + do_div(val, mvpwm->clk_rate); + if (val > UINT_MAX) + state->duty_cycle = UINT_MAX; +@@ -665,21 +664,17 @@ static void mvebu_pwm_get_state(struct p + else + state->duty_cycle = 1; + +- val = (unsigned long long) +- readl_relaxed(mvebu_pwmreg_blink_off_duration(mvpwm)); ++ val = (unsigned long long) u; /* on duration */ ++ /* period = on + off duration */ ++ val += readl_relaxed(mvebu_pwmreg_blink_off_duration(mvpwm)); + val *= NSEC_PER_SEC; + do_div(val, mvpwm->clk_rate); +- if (val < state->duty_cycle) { ++ if (val > UINT_MAX) ++ state->period = UINT_MAX; ++ else if (val) ++ state->period = val; ++ else + state->period = 1; +- } else { +- val -= state->duty_cycle; +- if (val > UINT_MAX) +- state->period = UINT_MAX; +- else if (val) +- state->period = val; +- else +- state->period = 1; +- } + + regmap_read(mvchip->regs, GPIO_BLINK_EN_OFF + mvchip->offset, &u); + if (u) diff --git a/queue-4.14/series b/queue-4.14/series index 9e4bb0c32e5..06030556c97 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -34,3 +34,4 @@ ipv6-create-multicast-route-with-rtprot_kernel.patch net_sched-avoid-shift-out-of-bounds-in-tcindex_set_parms.patch net-dsa-b53-fix-an-off-by-one-in-checking-vlan-vid.patch futex-futex_wake_op-fix-sign_extend32-sign-bits.patch +gpio-mvebu-fix-pwm-.get_state-period-calculation.patch diff --git a/queue-5.10/series b/queue-5.10/series new file mode 100644 index 00000000000..89841a21297 --- /dev/null +++ b/queue-5.10/series @@ -0,0 +1 @@ +gpio-mvebu-fix-pwm-.get_state-period-calculation.patch diff --git a/queue-5.4/series b/queue-5.4/series new file mode 100644 index 00000000000..89841a21297 --- /dev/null +++ b/queue-5.4/series @@ -0,0 +1 @@ +gpio-mvebu-fix-pwm-.get_state-period-calculation.patch