Commit bccaadab authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Rafael J. Wysocki

PM / wakeup: Make events_lock a RAW_SPINLOCK

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: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent c1a957d1
...@@ -57,7 +57,7 @@ static void split_counters(unsigned int *cnt, unsigned int *inpr) ...@@ -57,7 +57,7 @@ static void split_counters(unsigned int *cnt, unsigned int *inpr)
/* A preserved old value of the events counter. */ /* A preserved old value of the events counter. */
static unsigned int saved_count; 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); static void pm_wakeup_timer_fn(struct timer_list *t);
...@@ -185,9 +185,9 @@ void wakeup_source_add(struct wakeup_source *ws) ...@@ -185,9 +185,9 @@ void wakeup_source_add(struct wakeup_source *ws)
ws->active = false; ws->active = false;
ws->last_time = ktime_get(); 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); 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); EXPORT_SYMBOL_GPL(wakeup_source_add);
...@@ -202,9 +202,9 @@ void wakeup_source_remove(struct wakeup_source *ws) ...@@ -202,9 +202,9 @@ void wakeup_source_remove(struct wakeup_source *ws)
if (WARN_ON(!ws)) if (WARN_ON(!ws))
return; return;
spin_lock_irqsave(&events_lock, flags); raw_spin_lock_irqsave(&events_lock, flags);
list_del_rcu(&ws->entry); list_del_rcu(&ws->entry);
spin_unlock_irqrestore(&events_lock, flags); raw_spin_unlock_irqrestore(&events_lock, flags);
synchronize_srcu(&wakeup_srcu); synchronize_srcu(&wakeup_srcu);
} }
EXPORT_SYMBOL_GPL(wakeup_source_remove); EXPORT_SYMBOL_GPL(wakeup_source_remove);
...@@ -843,7 +843,7 @@ bool pm_wakeup_pending(void) ...@@ -843,7 +843,7 @@ bool pm_wakeup_pending(void)
unsigned long flags; unsigned long flags;
bool ret = false; bool ret = false;
spin_lock_irqsave(&events_lock, flags); raw_spin_lock_irqsave(&events_lock, flags);
if (events_check_enabled) { if (events_check_enabled) {
unsigned int cnt, inpr; unsigned int cnt, inpr;
...@@ -851,7 +851,7 @@ bool pm_wakeup_pending(void) ...@@ -851,7 +851,7 @@ bool pm_wakeup_pending(void)
ret = (cnt != saved_count || inpr > 0); ret = (cnt != saved_count || inpr > 0);
events_check_enabled = !ret; events_check_enabled = !ret;
} }
spin_unlock_irqrestore(&events_lock, flags); raw_spin_unlock_irqrestore(&events_lock, flags);
if (ret) { if (ret) {
pr_info("PM: Wakeup pending, aborting suspend\n"); pr_info("PM: Wakeup pending, aborting suspend\n");
...@@ -940,13 +940,13 @@ bool pm_save_wakeup_count(unsigned int count) ...@@ -940,13 +940,13 @@ bool pm_save_wakeup_count(unsigned int count)
unsigned long flags; unsigned long flags;
events_check_enabled = false; events_check_enabled = false;
spin_lock_irqsave(&events_lock, flags); raw_spin_lock_irqsave(&events_lock, flags);
split_counters(&cnt, &inpr); split_counters(&cnt, &inpr);
if (cnt == count && inpr == 0) { if (cnt == count && inpr == 0) {
saved_count = count; saved_count = count;
events_check_enabled = true; events_check_enabled = true;
} }
spin_unlock_irqrestore(&events_lock, flags); raw_spin_unlock_irqrestore(&events_lock, flags);
return events_check_enabled; return events_check_enabled;
} }
......
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