Skip to contentSkip to conversation

pwm: sun4i: Remove erroneous else branch

PATCH In review Thierry Reding 3 participants 4 messages Dec 16, 2020 – Dec 17, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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.

Fixes d3817a647059 ("pwm: sun4i: Remove redundant needs_delay")
---
 drivers/pwm/pwm-sun4i.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/pwm/pwm-sun4i.c +1 -5
index cc1eb0818648..ce5c4fc8da6f 100644
@@ -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
Tested-by on v1 1/1
#1 lore raw

ср, 16 дек. 2020 г. в 20:43, Thierry Reding <[email protected]>:

Quoted 43 lines

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.

Fixes d3817a647059 ("pwm: sun4i: Remove redundant needs_delay")
---
 drivers/pwm/pwm-sun4i.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/pwm/pwm-sun4i.c +1 -6
index cc1eb0818648..ce5c4fc8da6f 100644
@@ -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

Reviewed-by on v1 1/1
#2 lore raw
In reply to Thierry Reding
Quoted 9 lines · Thierry Reding

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.

Quoted 5 lines

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.

Fixes d3817a647059 ("pwm: sun4i: Remove redundant needs_delay")

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

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
#3 lore raw

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 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.

Quoted 5 lines

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.

Fixes d3817a647059 ("pwm: sun4i: Remove redundant needs_delay")

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

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |