Skip to content

Commit d6e3666

Browse files
committed
PM: runtime: Drop pm_runtime_clean_up_links()
After commit d12544f ("PM: runtime: Remove link state checks in rpm_get/put_supplier()") nothing prevents the consumer device's runtime PM from acquiring additional references to the supplier device after pm_runtime_clean_up_links() has run (or even while it is running), so calling this function from __device_release_driver() may be pointless (or even harmful). Moreover, it ignores stateless device links, so the runtime PM handling of managed and stateless device links is inconsistent because of it, so better get rid of it entirely. Fixes: d12544f ("PM: runtime: Remove link state checks in rpm_get/put_supplier()") Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Cc: 5.1+ <stable@vger.kernel.org> # 5.1+ Tested-by: Xiang Chen <chenxiang66@hisilicon.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e0e398e commit d6e3666

3 files changed

Lines changed: 0 additions & 39 deletions

File tree

drivers/base/dd.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,6 @@ static void __device_release_driver(struct device *dev, struct device *parent)
11331133
}
11341134

11351135
pm_runtime_get_sync(dev);
1136-
pm_runtime_clean_up_links(dev);
11371136

11381137
driver_sysfs_remove(dev);
11391138

drivers/base/power/runtime.c

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,42 +1642,6 @@ void pm_runtime_remove(struct device *dev)
16421642
pm_runtime_reinit(dev);
16431643
}
16441644

1645-
/**
1646-
* pm_runtime_clean_up_links - Prepare links to consumers for driver removal.
1647-
* @dev: Device whose driver is going to be removed.
1648-
*
1649-
* Check links from this device to any consumers and if any of them have active
1650-
* runtime PM references to the device, drop the usage counter of the device
1651-
* (as many times as needed).
1652-
*
1653-
* Links with the DL_FLAG_MANAGED flag unset are ignored.
1654-
*
1655-
* Since the device is guaranteed to be runtime-active at the point this is
1656-
* called, nothing else needs to be done here.
1657-
*
1658-
* Moreover, this is called after device_links_busy() has returned 'false', so
1659-
* the status of each link is guaranteed to be DL_STATE_SUPPLIER_UNBIND and
1660-
* therefore rpm_active can't be manipulated concurrently.
1661-
*/
1662-
void pm_runtime_clean_up_links(struct device *dev)
1663-
{
1664-
struct device_link *link;
1665-
int idx;
1666-
1667-
idx = device_links_read_lock();
1668-
1669-
list_for_each_entry_rcu(link, &dev->links.consumers, s_node,
1670-
device_links_read_lock_held()) {
1671-
if (!(link->flags & DL_FLAG_MANAGED))
1672-
continue;
1673-
1674-
while (refcount_dec_not_one(&link->rpm_active))
1675-
pm_runtime_put_noidle(dev);
1676-
}
1677-
1678-
device_links_read_unlock(idx);
1679-
}
1680-
16811645
/**
16821646
* pm_runtime_get_suppliers - Resume and reference-count supplier devices.
16831647
* @dev: Consumer device.

include/linux/pm_runtime.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ extern u64 pm_runtime_autosuspend_expiration(struct device *dev);
5454
extern void pm_runtime_update_max_time_suspended(struct device *dev,
5555
s64 delta_ns);
5656
extern void pm_runtime_set_memalloc_noio(struct device *dev, bool enable);
57-
extern void pm_runtime_clean_up_links(struct device *dev);
5857
extern void pm_runtime_get_suppliers(struct device *dev);
5958
extern void pm_runtime_put_suppliers(struct device *dev);
6059
extern void pm_runtime_new_link(struct device *dev);
@@ -276,7 +275,6 @@ static inline u64 pm_runtime_autosuspend_expiration(
276275
struct device *dev) { return 0; }
277276
static inline void pm_runtime_set_memalloc_noio(struct device *dev,
278277
bool enable){}
279-
static inline void pm_runtime_clean_up_links(struct device *dev) {}
280278
static inline void pm_runtime_get_suppliers(struct device *dev) {}
281279
static inline void pm_runtime_put_suppliers(struct device *dev) {}
282280
static inline void pm_runtime_new_link(struct device *dev) {}

0 commit comments

Comments
 (0)