Linux LED subsystem development
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: Craig McQueen <craig@mcqueen.au>
Cc: linux-leds <linux-leds@vger.kernel.org>
Subject: Re: [PATCH] leds: core: Fix race condition for software blink
Date: Thu, 14 May 2026 17:40:31 +0100	[thread overview]
Message-ID: <20260514164031.GQ305027@google.com> (raw)
In-Reply-To: <19e0507bcfe.b2da6346184484.1331248575877259177@mcqueen.au>

On Fri, 08 May 2026, Craig McQueen wrote:

> Lee Jones wrote
>  > On Thu, 23 Apr 2026, Craig McQueen wrote: 
>  >  
>  > > led_set_brightness() function: Change handling of software blink to 
>  > > avoid race conditions when stopping blink and setting brightness. 
>  > > 
>  > > Triggers may call led_set_brightness(LED_OFF), 
>  > > led_set_brightness(LED_FULL) in quick succession to disable blinking and 
>  > > turn the LED on. If the delayed work task has not yet disabled blinking 
>  > > by the time the second call occurs, then the brightness also needs to be 
>  > > changed in the delayed work task. 
>  > > 
>  > > Signed-off-by: Craig McQueen <craig@mcqueen.au> 
>  > > --- 
>  > >  drivers/leds/led-core.c | 33 ++++++++++++++++++++------------- 
>  > >  1 file changed, 20 insertions(+), 13 deletions(-) 
>  >  
>  > I think this needs more eyes on it and to be thoroughly tested by others. 
> 
> The problem I have seen is when a Linux driver controls a trigger to change it from flashing to steady-on. I've seen it specifically with LED core's software blinking.
> 
> /* First stop the blinking */
> led_trigger_event(&udev->led_trigger, LED_OFF);
> /* Next turn the LED steady-on */
> led_trigger_event(&udev->led_trigger, LED_FULL);
> 
> Without this patch, the LED usually ends up in the off state, rather than on.
> 
> I have tested this patch on a Rockchip RK3328 based system (ARM 64).

I'm sure that this patch does work for you.  Just as the last iteration
of this function has been working fine for everyone else for the last 10
years.  However, since this is core change, I shall be exercising
caution.

If anyone would be kind enough to test it, or provide some extra eyes,
I'd be appreciative.

-- 
Lee Jones

      reply	other threads:[~2026-05-14 16:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-23 11:36 [PATCH] leds: core: Fix race condition for software blink Craig McQueen
2026-05-07 11:59 ` Lee Jones
2026-05-08  0:40   ` Craig McQueen
2026-05-14 16:40     ` Lee Jones [this message]

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=20260514164031.GQ305027@google.com \
    --to=lee@kernel.org \
    --cc=craig@mcqueen.au \
    --cc=linux-leds@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox