Skip to content

Commit 42beb82

Browse files
Madhuparna Bhowmikrafaeljw
authored andcommitted
PM: sleep: core: Use built-in RCU list checking
This patch passes the cond argument to list_for_each_entry_rcu() to fix the following false-positive lockdep warnings: (with CONFIG_PROVE_RCU_LIST = y) [ 330.302784] ============================= [ 330.302789] WARNING: suspicious RCU usage [ 330.302796] 5.6.0-rc1+ #5 Not tainted [ 330.302801] ----------------------------- [ 330.302808] drivers/base/power/main.c:326 RCU-list traversed in non-reader section!! [ 330.303303] ============================= [ 330.303307] WARNING: suspicious RCU usage [ 330.303311] 5.6.0-rc1+ #5 Not tainted [ 330.303315] ----------------------------- [ 330.303319] drivers/base/power/main.c:1698 RCU-list traversed in non-reader section!! [ 331.934969] ============================= [ 331.934971] WARNING: suspicious RCU usage [ 331.934973] 5.6.0-rc1+ #5 Not tainted [ 331.934975] ----------------------------- [ 331.934977] drivers/base/power/main.c:1238 RCU-list traversed in non-reader section!! [ 332.467772] WARNING: suspicious RCU usage [ 332.467775] 5.6.0-rc1+ #5 Not tainted [ 332.467775] ----------------------------- [ 332.467778] drivers/base/power/main.c:269 RCU-list traversed in non-reader section!! Signed-off-by: Madhuparna Bhowmik <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 98d54f8 commit 42beb82

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/base/power/main.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040

4141
typedef int (*pm_callback_t)(struct device *);
4242

43+
#define list_for_each_entry_rcu_locked(pos, head, member) \
44+
list_for_each_entry_rcu(pos, head, member, \
45+
device_links_read_lock_held())
46+
4347
/*
4448
* The entries in the dpm_list list are in a depth first order, simply
4549
* because children are guaranteed to be discovered after parents, and
@@ -266,7 +270,7 @@ static void dpm_wait_for_suppliers(struct device *dev, bool async)
266270
* callbacks freeing the link objects for the links in the list we're
267271
* walking.
268272
*/
269-
list_for_each_entry_rcu(link, &dev->links.suppliers, c_node)
273+
list_for_each_entry_rcu_locked(link, &dev->links.suppliers, c_node)
270274
if (READ_ONCE(link->status) != DL_STATE_DORMANT)
271275
dpm_wait(link->supplier, async);
272276

@@ -323,7 +327,7 @@ static void dpm_wait_for_consumers(struct device *dev, bool async)
323327
* continue instead of trying to continue in parallel with its
324328
* unregistration).
325329
*/
326-
list_for_each_entry_rcu(link, &dev->links.consumers, s_node)
330+
list_for_each_entry_rcu_locked(link, &dev->links.consumers, s_node)
327331
if (READ_ONCE(link->status) != DL_STATE_DORMANT)
328332
dpm_wait(link->consumer, async);
329333

@@ -1235,7 +1239,7 @@ static void dpm_superior_set_must_resume(struct device *dev)
12351239

12361240
idx = device_links_read_lock();
12371241

1238-
list_for_each_entry_rcu(link, &dev->links.suppliers, c_node)
1242+
list_for_each_entry_rcu_locked(link, &dev->links.suppliers, c_node)
12391243
link->supplier->power.must_resume = true;
12401244

12411245
device_links_read_unlock(idx);
@@ -1695,7 +1699,7 @@ static void dpm_clear_superiors_direct_complete(struct device *dev)
16951699

16961700
idx = device_links_read_lock();
16971701

1698-
list_for_each_entry_rcu(link, &dev->links.suppliers, c_node) {
1702+
list_for_each_entry_rcu_locked(link, &dev->links.suppliers, c_node) {
16991703
spin_lock_irq(&link->supplier->power.lock);
17001704
link->supplier->power.direct_complete = false;
17011705
spin_unlock_irq(&link->supplier->power.lock);

0 commit comments

Comments
 (0)