pwm: sun4i: Remove erroneous else branch
Subsystems (2)
PATCH 1/1 pwm: sun4i: Remove erroneous else branch
Commit d3817a647059 ("pwm: sun4i: Remove redundant needs_delay") changed the logic of an else branch so that the PWM_EN and PWM_CLK_GATING bits are now cleared if the PWM is to be disabled, whereas previously the condition was always false, and hence the branch never got executed.
This code is reported causing backlight issues on boards based on the Allwinner A20 SoC. Fix this by removing the else branch, which restores the behaviour prior to the offending commit.
Note that the PWM_EN and PWM_CLK_GATING bits still get cleared later in sun4i_pwm_apply() if the PWM is to be disabled.
--- drivers/pwm/pwm-sun4i.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/pwm/pwm-sun4i.c +1 -5
@@ -294,12 +294,8 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, ctrl |=BIT_CH (PWM_CLK_GATING , pwm->hwpwm); -if (state->enabled) { +if (state->enabled) ctrl |=BIT_CH (PWM_EN , pwm->hwpwm); - }else { - ctrl &= ~BIT_CH (PWM_EN , pwm->hwpwm); - ctrl &= ~BIT_CH (PWM_CLK_GATING , pwm->hwpwm); - }sun4i_pwm_writel (sun4i_pwm, ctrl,PWM_CTRL_REG );
Signature · 1 line
2.29.2
ср, 16 дек. 2020 г. в 20:43, Thierry Reding <[email protected]>:
Quoted 43 lines
Commit
d3817a647059("pwm: sun4i: Remove redundantneeds_delay") changed the logic of an else branch so that thePWM_ENandPWM_CLK_GATINGbits are now cleared if the PWM is to be disabled, whereas previously the condition was always false, and hence the branch never got executed.This code is reported causing backlight issues on boards based on the Allwinner A20 SoC. Fix this by removing the else branch, which restores the behaviour prior to the offending commit.
Note that the
PWM_ENandPWM_CLK_GATINGbits still get cleared later insun4i_pwm_apply()if the PWM is to be disabled.Fixes d3817a647059 ("pwm: sun4i: Remove redundant needs_delay")Reported-by Taras Galchenko <[email protected]>Suggested-by Taras Galchenko <[email protected]>Signed-off-by Thierry Reding <[email protected]>--- drivers/pwm/pwm-sun4i.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/pwm/pwm-sun4i.c +1
-6@@ -294,12 +294,8 @@ static int sun4i_pwm_apply(struct pwm_chip *chip,struct pwm_device *pwm, ctrl |= BIT_CH(PWM_CLK_GATING, pwm->hwpwm); -if (state->enabled) { +if (state->enabled) ctrl |=BIT_CH (PWM_EN , pwm->hwpwm); - }else { - ctrl &= ~BIT_CH (PWM_EN , pwm->hwpwm); - ctrl &= ~BIT_CH (PWM_CLK_GATING , pwm->hwpwm); - }sun4i_pwm_writel (sun4i_pwm, ctrl,PWM_CTRL_REG ); --2.29.2
Quoted 9 lines · Thierry Reding
Commit
d3817a647059("pwm: sun4i: Remove redundantneeds_delay") changed the logic of an else branch so that thePWM_ENandPWM_CLK_GATINGbits are now cleared if the PWM is to be disabled, whereas previously the condition was always false, and hence the branch never got executed.This code is reported causing backlight issues on boards based on the Allwinner A20 SoC. Fix this by removing the else branch, which restores the behaviour prior to the offending commit.
Quoted 5 lines
Note that the
PWM_ENandPWM_CLK_GATINGbits still get cleared later insun4i_pwm_apply()if the PWM is to be disabled.Fixes d3817a647059 ("pwm: sun4i: Remove redundant needs_delay")Reported-by Taras Galchenko <[email protected]>
This report didn't happen on the linux-pwm list, or did I miss it?
What is the reported problem? I would expect a short time where the backlight goes off completely (or on depending on polarity?) when only a small continuous change is expected.
Quoted 2 lines
Suggested-by Taras Galchenko <[email protected]>Signed-off-by Thierry Reding <[email protected]>
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Uwe,
It was my fault, I contacted Thierry directly when reporting the problem and did not write to the list.
The problem I saw is that the backlight never gets turned off on A20 SOC no matter what commands I send to /sys/class/backlight/backlight/bl_power . I've investigated the origin of the problem, that was not present in the kernel 5.6.14, and traced out the patch that broke the function.
Best regards
Taras
чт, 17 дек. 2020 г. в 14:31, Uwe Kleine-König <
[email protected]>:
Quoted 34 lines · Thierry Reding
Quoted 9 lines
Commit
d3817a647059("pwm: sun4i: Remove redundantneeds_delay") changed the logic of an else branch so that thePWM_ENandPWM_CLK_GATINGbits are now cleared if the PWM is to be disabled, whereas previously the condition was always false, and hence the branch never got executed.This code is reported causing backlight issues on boards based on the Allwinner A20 SoC. Fix this by removing the else branch, which restores the behaviour prior to the offending commit.
Quoted 5 lines
Note that the
PWM_ENandPWM_CLK_GATINGbits still get cleared later insun4i_pwm_apply()if the PWM is to be disabled.Fixes d3817a647059 ("pwm: sun4i: Remove redundant needs_delay")Reported-by Taras Galchenko <[email protected]>This report didn't happen on the linux-pwm list, or did I miss it?
What is the reported problem? I would expect a short time where the backlight goes off completely (or on depending on polarity?) when only a small continuous change is expected.
Quoted 2 lines
Suggested-by Taras Galchenko <[email protected]>Signed-off-by Thierry Reding <[email protected]>Reviewed-by Uwe Kleine-König <[email protected]>Best regards
Uwe--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |