]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
Revert "PM / runtime: Fixup reference counting of device link suppliers at probe"
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 12 Jun 2018 08:24:13 +0000 (10:24 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 12 Jun 2018 08:24:13 +0000 (10:24 +0200)
Revert commit 1e8378619841 (PM / runtime: Fixup reference counting of
device link suppliers at probe), as it has introduced a regression
and the condition it was designed to address should be covered by the
existing code.

Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/dd.c
drivers/base/power/runtime.c
include/linux/pm_runtime.h

index a41c91bfac0e9ca4a08a5df81d74dba74ffd876c..10454fe5448259755e4b4e7df05231fe55ae6592 100644 (file)
@@ -580,7 +580,7 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
        pr_debug("bus: '%s': %s: matched device %s with driver %s\n",
                 drv->bus->name, __func__, dev_name(dev), drv->name);
 
-       pm_runtime_resume_suppliers(dev);
+       pm_runtime_get_suppliers(dev);
        if (dev->parent)
                pm_runtime_get_sync(dev->parent);
 
@@ -591,6 +591,7 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
        if (dev->parent)
                pm_runtime_put(dev->parent);
 
+       pm_runtime_put_suppliers(dev);
        return ret;
 }
 
index c6030f100c087fc5edb4ca216f35b4945692f69e..beb85c31f3fa3b9f997a4f21c72891f40e7535ed 100644 (file)
@@ -1563,16 +1563,37 @@ void pm_runtime_clean_up_links(struct device *dev)
 }
 
 /**
- * pm_runtime_resume_suppliers - Resume supplier devices.
+ * pm_runtime_get_suppliers - Resume and reference-count supplier devices.
  * @dev: Consumer device.
  */
-void pm_runtime_resume_suppliers(struct device *dev)
+void pm_runtime_get_suppliers(struct device *dev)
 {
+       struct device_link *link;
        int idx;
 
        idx = device_links_read_lock();
 
-       rpm_get_suppliers(dev);
+       list_for_each_entry_rcu(link, &dev->links.suppliers, c_node)
+               if (link->flags & DL_FLAG_PM_RUNTIME)
+                       pm_runtime_get_sync(link->supplier);
+
+       device_links_read_unlock(idx);
+}
+
+/**
+ * pm_runtime_put_suppliers - Drop references to supplier devices.
+ * @dev: Consumer device.
+ */
+void pm_runtime_put_suppliers(struct device *dev)
+{
+       struct device_link *link;
+       int idx;
+
+       idx = device_links_read_lock();
+
+       list_for_each_entry_rcu(link, &dev->links.suppliers, c_node)
+               if (link->flags & DL_FLAG_PM_RUNTIME)
+                       pm_runtime_put(link->supplier);
 
        device_links_read_unlock(idx);
 }
index db5dbbf7a48d4581da71e14fac6728eee72ba67d..f0fc4700b6ff53adfb8584162ae0bb3c522237a2 100644 (file)
@@ -56,7 +56,8 @@ 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_resume_suppliers(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);
 extern void pm_runtime_drop_link(struct device *dev);
 
@@ -172,7 +173,8 @@ static inline unsigned long pm_runtime_autosuspend_expiration(
 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_resume_suppliers(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) {}
 static inline void pm_runtime_drop_link(struct device *dev) {}