Skip to content

Commit 37f75c6

Browse files
rafaeljwgregkh
authored andcommitted
PM: runtime: Drop pm_runtime_clean_up_links()
commit d6e3666 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 874dfb5 commit 37f75c6

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
@@ -1121,7 +1121,6 @@ static void __device_release_driver(struct device *dev, struct device *parent)
11211121
}
11221122

11231123
pm_runtime_get_sync(dev);
1124-
pm_runtime_clean_up_links(dev);
11251124

11261125
driver_sysfs_remove(dev);
11271126

drivers/base/power/runtime.c

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,42 +1615,6 @@ void pm_runtime_remove(struct device *dev)
16151615
pm_runtime_reinit(dev);
16161616
}
16171617

1618-
/**
1619-
* pm_runtime_clean_up_links - Prepare links to consumers for driver removal.
1620-
* @dev: Device whose driver is going to be removed.
1621-
*
1622-
* Check links from this device to any consumers and if any of them have active
1623-
* runtime PM references to the device, drop the usage counter of the device
1624-
* (as many times as needed).
1625-
*
1626-
* Links with the DL_FLAG_MANAGED flag unset are ignored.
1627-
*
1628-
* Since the device is guaranteed to be runtime-active at the point this is
1629-
* called, nothing else needs to be done here.
1630-
*
1631-
* Moreover, this is called after device_links_busy() has returned 'false', so
1632-
* the status of each link is guaranteed to be DL_STATE_SUPPLIER_UNBIND and
1633-
* therefore rpm_active can't be manipulated concurrently.
1634-
*/
1635-
void pm_runtime_clean_up_links(struct device *dev)
1636-
{
1637-
struct device_link *link;
1638-
int idx;
1639-
1640-
idx = device_links_read_lock();
1641-
1642-
list_for_each_entry_rcu(link, &dev->links.consumers, s_node,
1643-
device_links_read_lock_held()) {
1644-
if (!(link->flags & DL_FLAG_MANAGED))
1645-
continue;
1646-
1647-
while (refcount_dec_not_one(&link->rpm_active))
1648-
pm_runtime_put_noidle(dev);
1649-
}
1650-
1651-
device_links_read_unlock(idx);
1652-
}
1653-
16541618
/**
16551619
* pm_runtime_get_suppliers - Resume and reference-count supplier devices.
16561620
* @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);
@@ -173,7 +172,6 @@ static inline u64 pm_runtime_autosuspend_expiration(
173172
struct device *dev) { return 0; }
174173
static inline void pm_runtime_set_memalloc_noio(struct device *dev,
175174
bool enable){}
176-
static inline void pm_runtime_clean_up_links(struct device *dev) {}
177175
static inline void pm_runtime_get_suppliers(struct device *dev) {}
178176
static inline void pm_runtime_put_suppliers(struct device *dev) {}
179177
static inline void pm_runtime_new_link(struct device *dev) {}

0 commit comments

Comments
 (0)