Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

driver/core: Convert to use built-in RCU list checking

This commit applies the consolidated hlist_for_each_entry_rcu() support
for lockdep conditions.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>

authored by

Joel Fernandes (Google) and committed by
Paul E. McKenney
c2fa1e1b 7fd69b0b

+23 -5
+1
drivers/base/base.h
··· 165 165 /* Device links support */ 166 166 extern int device_links_read_lock(void); 167 167 extern void device_links_read_unlock(int idx); 168 + extern int device_links_read_lock_held(void); 168 169 extern int device_links_check_suppliers(struct device *dev); 169 170 extern void device_links_driver_bound(struct device *dev); 170 171 extern void device_links_driver_cleanup(struct device *dev);
+12
drivers/base/core.c
··· 68 68 { 69 69 srcu_read_unlock(&device_links_srcu, idx); 70 70 } 71 + 72 + int device_links_read_lock_held(void) 73 + { 74 + return srcu_read_lock_held(&device_links_srcu); 75 + } 71 76 #else /* !CONFIG_SRCU */ 72 77 static DECLARE_RWSEM(device_links_lock); 73 78 ··· 96 91 { 97 92 up_read(&device_links_lock); 98 93 } 94 + 95 + #ifdef CONFIG_DEBUG_LOCK_ALLOC 96 + int device_links_read_lock_held(void) 97 + { 98 + return lockdep_is_held(&device_links_lock); 99 + } 100 + #endif 99 101 #endif /* !CONFIG_SRCU */ 100 102 101 103 /**
+10 -5
drivers/base/power/runtime.c
··· 287 287 { 288 288 struct device_link *link; 289 289 290 - list_for_each_entry_rcu(link, &dev->links.suppliers, c_node) { 290 + list_for_each_entry_rcu(link, &dev->links.suppliers, c_node, 291 + device_links_read_lock_held()) { 291 292 int retval; 292 293 293 294 if (!(link->flags & DL_FLAG_PM_RUNTIME) || ··· 310 309 { 311 310 struct device_link *link; 312 311 313 - list_for_each_entry_rcu(link, &dev->links.suppliers, c_node) { 312 + list_for_each_entry_rcu(link, &dev->links.suppliers, c_node, 313 + device_links_read_lock_held()) { 314 314 if (READ_ONCE(link->status) == DL_STATE_SUPPLIER_UNBIND) 315 315 continue; 316 316 ··· 1642 1640 1643 1641 idx = device_links_read_lock(); 1644 1642 1645 - list_for_each_entry_rcu(link, &dev->links.consumers, s_node) { 1643 + list_for_each_entry_rcu(link, &dev->links.consumers, s_node, 1644 + device_links_read_lock_held()) { 1646 1645 if (link->flags & DL_FLAG_STATELESS) 1647 1646 continue; 1648 1647 ··· 1665 1662 1666 1663 idx = device_links_read_lock(); 1667 1664 1668 - list_for_each_entry_rcu(link, &dev->links.suppliers, c_node) 1665 + list_for_each_entry_rcu(link, &dev->links.suppliers, c_node, 1666 + device_links_read_lock_held()) 1669 1667 if (link->flags & DL_FLAG_PM_RUNTIME) { 1670 1668 link->supplier_preactivated = true; 1671 1669 refcount_inc(&link->rpm_active); ··· 1687 1683 1688 1684 idx = device_links_read_lock(); 1689 1685 1690 - list_for_each_entry_rcu(link, &dev->links.suppliers, c_node) 1686 + list_for_each_entry_rcu(link, &dev->links.suppliers, c_node, 1687 + device_links_read_lock_held()) 1691 1688 if (link->supplier_preactivated) { 1692 1689 link->supplier_preactivated = false; 1693 1690 if (refcount_dec_not_one(&link->rpm_active))