]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
PM: sleep: wakeup: Use built-in RCU list checking
authorMadhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
Tue, 3 Mar 2020 19:42:09 +0000 (01:12 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 4 Mar 2020 10:05:59 +0000 (11:05 +0100)
Pass cond argument to list_for_each_entry_rcu() to fix the
following false positive lockdep warning and other uses of
list_for_each_entry_rcu() in wakeup.c.
(CONFIG_PROVE_RCU_LIST = y)

[  331.934648] =============================
[  331.934650] WARNING: suspicious RCU usage
[  331.934653] 5.6.0-rc1+ #5 Not tainted
[  331.934655] -----------------------------
[  331.934657] drivers/base/power/wakeup.c:408 RCU-list traversed in non-reader section!!

[  333.025156] =============================
[  333.025161] WARNING: suspicious RCU usage
[  333.025168] 5.6.0-rc1+ #5 Not tainted
[  333.025173] -----------------------------
[  333.025180] drivers/base/power/wakeup.c:424 RCU-list traversed in non-reader section!!

Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/power/wakeup.c

index 27f3e60608e590d90cbcfaf58f3ca35f0e6dae6e..7e33a8d829dc0ad03f15ac946ee690385a623784 100644 (file)
@@ -24,6 +24,9 @@ suspend_state_t pm_suspend_target_state;
 #define pm_suspend_target_state        (PM_SUSPEND_ON)
 #endif
 
+#define list_for_each_entry_rcu_locked(pos, head, member) \
+       list_for_each_entry_rcu(pos, head, member, \
+               srcu_read_lock_held(&wakeup_srcu))
 /*
  * If set, the suspend/hibernate code will abort transitions to a sleep state
  * if wakeup events are registered during or immediately before the transition.
@@ -405,7 +408,7 @@ void device_wakeup_arm_wake_irqs(void)
        int srcuidx;
 
        srcuidx = srcu_read_lock(&wakeup_srcu);
-       list_for_each_entry_rcu(ws, &wakeup_sources, entry)
+       list_for_each_entry_rcu_locked(ws, &wakeup_sources, entry)
                dev_pm_arm_wake_irq(ws->wakeirq);
        srcu_read_unlock(&wakeup_srcu, srcuidx);
 }
@@ -421,7 +424,7 @@ void device_wakeup_disarm_wake_irqs(void)
        int srcuidx;
 
        srcuidx = srcu_read_lock(&wakeup_srcu);
-       list_for_each_entry_rcu(ws, &wakeup_sources, entry)
+       list_for_each_entry_rcu_locked(ws, &wakeup_sources, entry)
                dev_pm_disarm_wake_irq(ws->wakeirq);
        srcu_read_unlock(&wakeup_srcu, srcuidx);
 }
@@ -874,7 +877,7 @@ void pm_print_active_wakeup_sources(void)
        struct wakeup_source *last_activity_ws = NULL;
 
        srcuidx = srcu_read_lock(&wakeup_srcu);
-       list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
+       list_for_each_entry_rcu_locked(ws, &wakeup_sources, entry) {
                if (ws->active) {
                        pm_pr_dbg("active wakeup source: %s\n", ws->name);
                        active = 1;
@@ -1025,7 +1028,7 @@ void pm_wakep_autosleep_enabled(bool set)
        int srcuidx;
 
        srcuidx = srcu_read_lock(&wakeup_srcu);
-       list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
+       list_for_each_entry_rcu_locked(ws, &wakeup_sources, entry) {
                spin_lock_irq(&ws->lock);
                if (ws->autosleep_enabled != set) {
                        ws->autosleep_enabled = set;
@@ -1104,7 +1107,7 @@ static void *wakeup_sources_stats_seq_start(struct seq_file *m,
        }
 
        *srcuidx = srcu_read_lock(&wakeup_srcu);
-       list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
+       list_for_each_entry_rcu_locked(ws, &wakeup_sources, entry) {
                if (n-- <= 0)
                        return ws;
        }