From: sashiko-bot@kernel.org
To: "H. Nikolaus Schaller" <hns@goldelico.com>
Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
dri-devel@lists.freedesktop.org, linux-leds@vger.kernel.org,
linux-sound@vger.kernel.org, robh@kernel.org,
conor+dt@kernel.org, lee@kernel.org
Subject: Re: [PATCH v2 11/20] backlight: pwm: Support enable guard period
Date: Tue, 24 Nov 2026 07:36:45 +0000 [thread overview]
Message-ID: <sashiko-outbox-230649@kernel.org> (raw)
In-Reply-To: <54477b4e31e35af14677172088f94770ca5b9755.1795505160.git.hns@goldelico.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] backlight: pwm_bl: guard period runs before
pwm_backlight_power_on()
- [Medium] backlight: pwm_bl: guard pulse triggers before
compute_duty_cycle()
- [Medium] backlight: pwm_bl: unchecked post-guard
pwm_apply_might_sleep()
- [Low] backlight: pwm_bl: unused linux/minmax.h include added
--
commit e05803a769b6dbbf7722b07888a63c3cd2737641
Author: H. Nikolaus Schaller <hns@goldelico.com>
backlight: pwm: Support enable guard period
This commit adds support for a pwm-enable-guard-period-us device tree
property to apply a full duty cycle for a guard interval when enabling the
PWM from a disabled or zero-duty state.
Link: https://patchwork.kernel.org/project/linux-omap/patch/f897f695c0e1e128d7ebb41be8dfdce4d634f552.1783749722.git.hns@goldelico.com/#27124981
> diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
> index 3ad71ee3657af..1d0a463710926 100644
> --- a/drivers/video/backlight/pwm_bl.c
> +++ b/drivers/video/backlight/pwm_bl.c
> @@ -7,6 +7,7 @@
>
> #include <linux/delay.h>
> #include <linux/gpio/consumer.h>
> +#include <linux/minmax.h>
[Severity: Low]
This isn't a bug, but linux/minmax.h does not appear to be used by anything
in this change.
[ ... ]
> @@ -93,11 +98,39 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
> struct pwm_bl_data *pb = bl_get_data(bl);
> int brightness = backlight_get_brightness(bl);
> struct pwm_state state;
> + int ret;
>
> if (pb->notify)
> brightness = pb->notify(pb->dev, brightness);
>
> if (brightness > 0) {
> + pwm_get_state(pb->pwm, &state);
> +
> + /*
> + * Some LED drivers detect a one-wire control mode during
> + * a startup window (e.g. TI TPS61160/TPS61161, using
> + * the duration of low intervals on CTRL). Request full
> + * duty for the guard interval before normal dimming.
> + * The PWM provider may approximate full duty.
> + *
> + * Apply the guard if the previous PWM state was disabled
> + * or had zero duty cycle.
> + */
> + if (pb->enable_guard_period_us &&
> + (!state.enabled || !state.duty_cycle)) {
> + struct pwm_state guard = state;
> +
> + guard.duty_cycle = guard.period;
> + guard.enabled = true;
> + ret = pwm_apply_might_sleep(pb->pwm, &guard);
> + if (ret)
> + return ret;
> +
> + usleep_range(pb->enable_guard_period_us,
> + pb->enable_guard_period_us +
> + PWM_BL_GUARD_SLACK_US);
> + }
[Severity: Medium]
Does checking brightness > 0 before calling compute_duty_cycle() cause a
full-brightness flash when a non-zero brightness level maps to a duty cycle
of 0?
When pb->lth_brightness is 0 and a low non-zero brightness index maps to 0
in pb->levels[] (or truncates to 0 in compute_duty_cycle()), the guard block
drives the PWM at 100% duty cycle for pb->enable_guard_period_us before
programming state.duty_cycle = 0. Because state.duty_cycle remains 0,
subsequent updates at low brightness repeat the full-duty flash and delay.
In addition, if the target duty cycle is already equal to state.period,
the guard block sleeps and then applies the same full duty cycle a second
time.
> +
> pwm_get_state(pb->pwm, &state);
> state.duty_cycle = compute_duty_cycle(pb, brightness, &state);
> state.enabled = true;
[Severity: Medium]
Does running the guard interval before pwm_backlight_power_on(pb) leave the
LED driver unpowered or disabled while the guard pulse is on the line?
drivers/video/backlight/pwm_bl.c:pwm_backlight_update_status() {
...
pwm_get_state(pb->pwm, &state);
state.duty_cycle = compute_duty_cycle(pb, brightness, &state);
state.enabled = true;
pwm_apply_might_sleep(pb->pwm, &state);
pwm_backlight_power_on(pb);
...
}
When a board also uses power-supply or enable-gpios, the full-duty guard
waveform and its usleep_range() delay finish and the PWM is already switched
to the dimmed duty cycle before pwm_backlight_power_on() enables
pb->power_supply or asserts pb->enable_gpio. The LED driver IC powers up
only after normal PWM dimming has begun, bypassing the startup guard window.
[Severity: Medium]
What happens if the guard pwm_apply_might_sleep() succeeds, but the post-guard
pwm_apply_might_sleep() that sets the dimmed duty cycle fails?
Because the second call's return value is ignored, a transient failure on
that update leaves the PWM hardware running at 100% duty cycle from the
guard step while pwm_backlight_power_on() turns the backlight on and
pwm_backlight_update_status() returns 0.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795505160.git.hns@goldelico.com?part=11
next prev parent reply other threads:[~2026-11-24 7:36 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 7:25 [PATCH v2 00/20] ARM: omap3: pandora: Modernize audio and backlight to use Device Tree to finally remove pdata-quirks H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 01/20] dt-bindings: gpio: twl4030: Document REGEN GPIO H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 02/20] gpio: twl4030: Support " H. Nikolaus Schaller
2026-11-24 7:43 ` sashiko-bot
2026-11-24 7:25 ` [PATCH v2 03/20] ASoC: twl4030: Allow APLL rate selection through set_sysclk() H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 04/20] dt-bindings: sound: pcm1754: Describe PCM1773 H. Nikolaus Schaller
2026-11-24 12:05 ` Mark Brown
2026-11-24 14:33 ` [Letux-kernel] " H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 05/20] ASoC: codecs: pcm1754: Add PCM1773 support H. Nikolaus Schaller
2026-11-24 14:48 ` Mark Brown
2026-11-24 7:25 ` [PATCH v2 06/20] dt-bindings: sound: Document OpenPandora sound card H. Nikolaus Schaller
2026-11-24 7:40 ` sashiko-bot
2026-11-24 13:40 ` Rob Herring
2026-11-24 12:04 ` Mark Brown
2026-11-24 13:35 ` Rob Herring (Arm)
2026-11-24 14:42 ` H. Nikolaus Schaller
2026-11-24 14:45 ` Krzysztof Kozlowski
2026-11-24 14:50 ` H. Nikolaus Schaller
2026-11-24 21:43 ` Andreas Kemnade
2026-11-26 18:20 ` Andreas Kemnade
2026-11-26 18:35 ` H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 07/20] ASoC: ti: omap3pandora: Convert sound card to DT H. Nikolaus Schaller
2026-11-24 7:45 ` sashiko-bot
2026-11-24 14:48 ` Mark Brown
2026-11-24 14:55 ` H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 08/20] dt-bindings: mfd: twl4030: Document 64-cycle PWM H. Nikolaus Schaller
2026-11-24 14:40 ` Krzysztof Kozlowski
2026-11-24 14:49 ` H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 09/20] pwm: twl: Support 64-cycle PWM frame H. Nikolaus Schaller
2026-11-24 7:37 ` sashiko-bot
2026-11-24 7:25 ` [PATCH v2 10/20] dt-bindings: backlight: pwm: Document enable guard H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 11/20] backlight: pwm: Support enable guard period H. Nikolaus Schaller
2026-11-24 7:36 ` sashiko-bot [this message]
2026-11-24 7:25 ` [PATCH v2 12/20] drm/panel: td043mtea1: Attach DT backlight H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 13/20] ARM: dts: omap3pandora: Disable unused DMA channels H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 14/20] ARM: dts: omap3-pandora: Model LCD power enable dependencies H. Nikolaus Schaller
2026-11-24 7:45 ` sashiko-bot
2026-11-24 7:25 ` [PATCH v2 15/20] ARM: dts: omap3pandora: Enable audio interfaces H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 16/20] ARM: dts: omap3pandora: Describe PCM1773 H. Nikolaus Schaller
2026-11-24 7:40 ` sashiko-bot
2026-11-24 7:25 ` [PATCH v2 17/20] ARM: dts: omap3pandora: Describe sound card H. Nikolaus Schaller
2026-11-24 7:47 ` sashiko-bot
2026-11-24 7:25 ` [PATCH v2 18/20] ARM: dts: omap3pandora: Switch backlight to PWM H. Nikolaus Schaller
2026-11-24 7:46 ` sashiko-bot
2026-11-24 7:25 ` [PATCH v2 19/20] backlight: Remove legacy Pandora driver H. Nikolaus Schaller
2026-11-24 7:26 ` [PATCH v2 20/20] ARM: OMAP2+: Remove Pandora platform-data quirks H. Nikolaus Schaller
2026-11-24 21:16 ` Andreas Kemnade
2026-11-24 7:47 ` [PATCH v2 00/20] ARM: omap3: pandora: Modernize audio and backlight to use Device Tree to finally remove pdata-quirks sashiko-bot
2026-11-24 13:38 ` Mark Brown
2026-11-24 14:52 ` H. Nikolaus Schaller
2026-11-24 15:13 ` Rob Herring
2026-11-24 15:27 ` H. Nikolaus Schaller
2026-11-24 16:52 ` Mark Brown
2026-11-24 22:41 ` Andreas Kemnade
2026-11-25 6:42 ` [Letux-kernel] " H. Nikolaus Schaller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-230649@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=hns@goldelico.com \
--cc=lee@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.