• Pavel Machek's avatar
    leds: avoid races with workqueue · 0db37915
    Pavel Machek authored
    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: 1afcadfc ("leds: core: Use set_brightness_work for the blocking op")
    Signed-off-by: default avatarPavel Machek <pavel@ucw.cz>
    Signed-off-by: default avatarJacek Anaszewski <jacek.anaszewski@gmail.com>
    0db37915
led-core.c 9.45 KB