Skip to content

Commit 2591e7b

Browse files
Madhuparna Bhowmikrafaeljw
authored andcommitted
PM: sleep: wakeup: Use built-in RCU list checking
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 <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 42beb82 commit 2591e7b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

drivers/base/power/wakeup.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ suspend_state_t pm_suspend_target_state;
2424
#define pm_suspend_target_state (PM_SUSPEND_ON)
2525
#endif
2626

27+
#define list_for_each_entry_rcu_locked(pos, head, member) \
28+
list_for_each_entry_rcu(pos, head, member, \
29+
srcu_read_lock_held(&wakeup_srcu))
2730
/*
2831
* If set, the suspend/hibernate code will abort transitions to a sleep state
2932
* if wakeup events are registered during or immediately before the transition.
@@ -405,7 +408,7 @@ void device_wakeup_arm_wake_irqs(void)
405408
int srcuidx;
406409

407410
srcuidx = srcu_read_lock(&wakeup_srcu);
408-
list_for_each_entry_rcu(ws, &wakeup_sources, entry)
411+
list_for_each_entry_rcu_locked(ws, &wakeup_sources, entry)
409412
dev_pm_arm_wake_irq(ws->wakeirq);
410413
srcu_read_unlock(&wakeup_srcu, srcuidx);
411414
}
@@ -421,7 +424,7 @@ void device_wakeup_disarm_wake_irqs(void)
421424
int srcuidx;
422425

423426
srcuidx = srcu_read_lock(&wakeup_srcu);
424-
list_for_each_entry_rcu(ws, &wakeup_sources, entry)
427+
list_for_each_entry_rcu_locked(ws, &wakeup_sources, entry)
425428
dev_pm_disarm_wake_irq(ws->wakeirq);
426429
srcu_read_unlock(&wakeup_srcu, srcuidx);
427430
}
@@ -874,7 +877,7 @@ void pm_print_active_wakeup_sources(void)
874877
struct wakeup_source *last_activity_ws = NULL;
875878

876879
srcuidx = srcu_read_lock(&wakeup_srcu);
877-
list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
880+
list_for_each_entry_rcu_locked(ws, &wakeup_sources, entry) {
878881
if (ws->active) {
879882
pm_pr_dbg("active wakeup source: %s\n", ws->name);
880883
active = 1;
@@ -1025,7 +1028,7 @@ void pm_wakep_autosleep_enabled(bool set)
10251028
int srcuidx;
10261029

10271030
srcuidx = srcu_read_lock(&wakeup_srcu);
1028-
list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
1031+
list_for_each_entry_rcu_locked(ws, &wakeup_sources, entry) {
10291032
spin_lock_irq(&ws->lock);
10301033
if (ws->autosleep_enabled != set) {
10311034
ws->autosleep_enabled = set;
@@ -1104,7 +1107,7 @@ static void *wakeup_sources_stats_seq_start(struct seq_file *m,
11041107
}
11051108

11061109
*srcuidx = srcu_read_lock(&wakeup_srcu);
1107-
list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
1110+
list_for_each_entry_rcu_locked(ws, &wakeup_sources, entry) {
11081111
if (n-- <= 0)
11091112
return ws;
11101113
}

0 commit comments

Comments
 (0)