On Thu, 15 Jul 2021, Linus Walleij wrote:
Remove interrupt disablement during backlight setting. It is way to dangerous and makes platforms instable by having it miss vblank IRQs leading to the graphics derailing.
The code is using ndelay() which is not available on platforms such as ARM and will result in 32 * udelay(1) which is substantial.
Add some code to detect if an interrupt occurs during the tight loop and in that case just redo it from the top.
Fixes: 5317f37e48b9 ("backlight: Add Kinetic KTD253 backlight driver") Cc: Stephan Gerhold stephan@gerhold.net Reported-by: newbyte@disroot.org Reviewed-by: Daniel Thompson daniel.thompson@linaro.org Signed-off-by: Linus Walleij linus.walleij@linaro.org
ChangeLog v3->v4:
- Collect Daniel's Reviewed-by.
ChangeLog v2->v3:
- Read my own patch and realized a bug: when we get a timeout we bounce back to max period, but still count down the pwm with one leading to an off-by-one error. Fix it by extending some else clauses.
ChangeLog v1->v2:
- Alter the dimming code to check for how many ns the pulse is low, and if it gets to ~100 us then redo from start. This is to account for the advent that an IRQ arrives while setting backlight and hits the low pulse making it way too long.
drivers/video/backlight/ktd253-backlight.c | 75 ++++++++++++++++------ 1 file changed, 55 insertions(+), 20 deletions(-)
Applied, thanks.