Re: [PATCH AUTOSEL 5.1 033/375] leds: avoid races with workqueue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

Could we hold this patch for now?

> From: Pavel Machek <pavel@xxxxxx>
> 
> [ Upstream commit 0db37915d912e8dc6588f25da76d3ed36718d92f ]
> 
> There are races between "main" thread and workqueue. They manifest
> themselves on Thinkpad X60:
> 
> This should result in LED blinking, but it turns it off instead:
> 
>     root@amd:/data/pavel# cd /sys/class/leds/tpacpi\:\:power
>     root@amd:/sys/class/leds/tpacpi::power# echo timer > trigger
>     root@amd:/sys/class/leds/tpacpi::power# echo timer > trigger
> 
> It should be possible to transition from blinking to solid on by echo
> 0 > brightness; echo 1 > brightness... but that does not work, either,
> if done too quickly.
> 
> Synchronization of the workqueue fixes both.
> 
> Fixes: 1afcadfcd184 ("leds: core: Use set_brightness_work for the blocking op")
> Signed-off-by: Pavel Machek <pavel@xxxxxx>
> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@xxxxxxxxx>
> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
> ---
>  drivers/leds/led-class.c | 1 +
>  drivers/leds/led-core.c  | 5 +++++
>  2 files changed, 6 insertions(+)

> index e3da7c03da1b5..e9ae7f87ab900 100644
> --- a/drivers/leds/led-core.c
> +++ b/drivers/leds/led-core.c
> @@ -164,6 +164,11 @@ static void led_blink_setup(struct led_classdev *led_cdev,
>  		     unsigned long *delay_on,
>  		     unsigned long *delay_off)
>  {
> +	/*
> +	 * If "set brightness to 0" is pending in workqueue, we don't
> +	 * want that to be reordered after blink_set()
> +	 */
> +	flush_work(&led_cdev->set_brightness_work);
>  	if (!test_bit(LED_BLINK_ONESHOT, &led_cdev->work_flags) &&
>  	    led_cdev->blink_set &&
>  	    !led_cdev->blink_set(led_cdev, delay_on, delay_off))

This part is likely buggy. It seems triggers are using this from
atomic context... ledtrig-disk for example.


									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux