Commit 8c0f693c authored by Pavel Machek's avatar Pavel Machek Committed by Jacek Anaszewski

leds: avoid flush_work in atomic context

It turns out that various triggers use led_blink_setup() from atomic
context, so we can't do a flush_work there. Flush is still needed for
slow LEDs, but we can move it to sysfs code where it is safe.

    WARNING: inconsistent lock state
    5.2.0-rc1 #1 Tainted: G        W
    --------------------------------
    inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage.
    swapper/1/0 [HC0[0]:SC1[1]:HE1:SE0] takes:
    000000006e30541b
    ((work_completion)(&led_cdev->set_brightness_work)){+.?.}, at:
    +__flush_work+0x3b/0x38a
    {SOFTIRQ-ON-W} state was registered at:
      lock_acquire+0x146/0x1a1
     __flush_work+0x5b/0x38a
     flush_work+0xb/0xd
     led_blink_setup+0x1e/0xd3
     led_blink_set+0x3f/0x44
     tpt_trig_timer+0xdb/0x106
     ieee80211_mod_tpt_led_trig+0xed/0x112

Fixes: 0db37915 ("leds: avoid races with workqueue")
Signed-off-by: default avatarPavel Machek <pavel@ucw.cz>
Tested-by: default avatarHugh Dickins <hughd@google.com>
Signed-off-by: default avatarJacek Anaszewski <jacek.anaszewski@gmail.com>
parent cd6c84d8
...@@ -164,11 +164,6 @@ static void led_blink_setup(struct led_classdev *led_cdev, ...@@ -164,11 +164,6 @@ static void led_blink_setup(struct led_classdev *led_cdev,
unsigned long *delay_on, unsigned long *delay_on,
unsigned long *delay_off) 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) && if (!test_bit(LED_BLINK_ONESHOT, &led_cdev->work_flags) &&
led_cdev->blink_set && led_cdev->blink_set &&
!led_cdev->blink_set(led_cdev, delay_on, delay_off)) !led_cdev->blink_set(led_cdev, delay_on, delay_off))
......
...@@ -113,6 +113,11 @@ static int timer_trig_activate(struct led_classdev *led_cdev) ...@@ -113,6 +113,11 @@ static int timer_trig_activate(struct led_classdev *led_cdev)
led_cdev->flags &= ~LED_INIT_DEFAULT_TRIGGER; led_cdev->flags &= ~LED_INIT_DEFAULT_TRIGGER;
} }
/*
* 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);
led_blink_set(led_cdev, &led_cdev->blink_delay_on, led_blink_set(led_cdev, &led_cdev->blink_delay_on,
&led_cdev->blink_delay_off); &led_cdev->blink_delay_off);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment