PM / wakeup: Make events_lock a RAW_SPINLOCK
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Fri, 25 May 2018 09:46:46 +0000 (11:46 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sun, 27 May 2018 09:55:02 +0000 (11:55 +0200)
The `events_lock' is acquired during suspend while interrupts are
disabled even on RT. The lock is taken only for a very brief moment.
Make it a RAW lock which avoids "sleeping while atomic" warnings on RT.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/power/wakeup.c

index ea01621..2e76fbc 100644 (file)
@@ -57,7 +57,7 @@ static void split_counters(unsigned int *cnt, unsigned int *inpr)
 /* A preserved old value of the events counter. */
 static unsigned int saved_count;
 
-static DEFINE_SPINLOCK(events_lock);
+static DEFINE_RAW_SPINLOCK(events_lock);
 
 static void pm_wakeup_timer_fn(struct timer_list *t);
 
@@ -185,9 +185,9 @@ void wakeup_source_add(struct wakeup_source *ws)
        ws->active = false;
        ws->last_time = ktime_get();
 
-       spin_lock_irqsave(&events_lock, flags);
+       raw_spin_lock_irqsave(&events_lock, flags);
        list_add_rcu(&ws->entry, &wakeup_sources);
-       spin_unlock_irqrestore(&events_lock, flags);
+       raw_spin_unlock_irqrestore(&events_lock, flags);
 }
 EXPORT_SYMBOL_GPL(wakeup_source_add);
 
@@ -202,9 +202,9 @@ void wakeup_source_remove(struct wakeup_source *ws)
        if (WARN_ON(!ws))
                return;
 
-       spin_lock_irqsave(&events_lock, flags);
+       raw_spin_lock_irqsave(&events_lock, flags);
        list_del_rcu(&ws->entry);
-       spin_unlock_irqrestore(&events_lock, flags);
+       raw_spin_unlock_irqrestore(&events_lock, flags);
        synchronize_srcu(&wakeup_srcu);
 }
 EXPORT_SYMBOL_GPL(wakeup_source_remove);
@@ -843,7 +843,7 @@ bool pm_wakeup_pending(void)
        unsigned long flags;
        bool ret = false;
 
-       spin_lock_irqsave(&events_lock, flags);
+       raw_spin_lock_irqsave(&events_lock, flags);
        if (events_check_enabled) {
                unsigned int cnt, inpr;
 
@@ -851,7 +851,7 @@ bool pm_wakeup_pending(void)
                ret = (cnt != saved_count || inpr > 0);
                events_check_enabled = !ret;
        }
-       spin_unlock_irqrestore(&events_lock, flags);
+       raw_spin_unlock_irqrestore(&events_lock, flags);
 
        if (ret) {
                pr_info("PM: Wakeup pending, aborting suspend\n");
@@ -940,13 +940,13 @@ bool pm_save_wakeup_count(unsigned int count)
        unsigned long flags;
 
        events_check_enabled = false;
-       spin_lock_irqsave(&events_lock, flags);
+       raw_spin_lock_irqsave(&events_lock, flags);
        split_counters(&cnt, &inpr);
        if (cnt == count && inpr == 0) {
                saved_count = count;
                events_check_enabled = true;
        }
-       spin_unlock_irqrestore(&events_lock, flags);
+       raw_spin_unlock_irqrestore(&events_lock, flags);
        return events_check_enabled;
 }