PM: runtime: Drop pm_runtime_clean_up_links()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 21 Oct 2020 19:13:10 +0000 (21:13 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 2 Nov 2020 17:14:07 +0000 (18:14 +0100)
After commit d12544fb2aa9 ("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: d12544fb2aa9 ("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>
drivers/base/dd.c
drivers/base/power/runtime.c
include/linux/pm_runtime.h

index b42229b74fd69688b1af2ea0de19008c8e169ba2..122b0372fdc95057f67e362316b45ddf3ea29d3f 100644 (file)
@@ -1133,7 +1133,6 @@ static void __device_release_driver(struct device *dev, struct device *parent)
                }
 
                pm_runtime_get_sync(dev);
-               pm_runtime_clean_up_links(dev);
 
                driver_sysfs_remove(dev);
 
index 6919f7fc226bb6a91e9c99040997e9c2281f7bb2..bfda153b1a41deed5a36ae53912fc7b0a4346980 100644 (file)
@@ -1642,42 +1642,6 @@ void pm_runtime_remove(struct device *dev)
        pm_runtime_reinit(dev);
 }
 
-/**
- * pm_runtime_clean_up_links - Prepare links to consumers for driver removal.
- * @dev: Device whose driver is going to be removed.
- *
- * Check links from this device to any consumers and if any of them have active
- * runtime PM references to the device, drop the usage counter of the device
- * (as many times as needed).
- *
- * Links with the DL_FLAG_MANAGED flag unset are ignored.
- *
- * Since the device is guaranteed to be runtime-active at the point this is
- * called, nothing else needs to be done here.
- *
- * Moreover, this is called after device_links_busy() has returned 'false', so
- * the status of each link is guaranteed to be DL_STATE_SUPPLIER_UNBIND and
- * therefore rpm_active can't be manipulated concurrently.
- */
-void pm_runtime_clean_up_links(struct device *dev)
-{
-       struct device_link *link;
-       int idx;
-
-       idx = device_links_read_lock();
-
-       list_for_each_entry_rcu(link, &dev->links.consumers, s_node,
-                               device_links_read_lock_held()) {
-               if (!(link->flags & DL_FLAG_MANAGED))
-                       continue;
-
-               while (refcount_dec_not_one(&link->rpm_active))
-                       pm_runtime_put_noidle(dev);
-       }
-
-       device_links_read_unlock(idx);
-}
-
 /**
  * pm_runtime_get_suppliers - Resume and reference-count supplier devices.
  * @dev: Consumer device.
index eadc1fdebce62f1aa02ddfe338cfa5ccdedc6323..4b708f4e8eed9df4d7f98ddcc8482f97dba63d2f 100644 (file)
@@ -54,7 +54,6 @@ extern u64 pm_runtime_autosuspend_expiration(struct device *dev);
 extern void pm_runtime_update_max_time_suspended(struct device *dev,
                                                 s64 delta_ns);
 extern void pm_runtime_set_memalloc_noio(struct device *dev, bool enable);
-extern void pm_runtime_clean_up_links(struct device *dev);
 extern void pm_runtime_get_suppliers(struct device *dev);
 extern void pm_runtime_put_suppliers(struct device *dev);
 extern void pm_runtime_new_link(struct device *dev);
@@ -276,7 +275,6 @@ static inline u64 pm_runtime_autosuspend_expiration(
                                struct device *dev) { return 0; }
 static inline void pm_runtime_set_memalloc_noio(struct device *dev,
                                                bool enable){}
-static inline void pm_runtime_clean_up_links(struct device *dev) {}
 static inline void pm_runtime_get_suppliers(struct device *dev) {}
 static inline void pm_runtime_put_suppliers(struct device *dev) {}
 static inline void pm_runtime_new_link(struct device *dev) {}