Skip to content

Commit

Permalink
PM: runtime: Redefine pm_runtime_release_supplier()
Browse files Browse the repository at this point in the history
commit 0735819 upstream.

Instead of passing an extra bool argument to pm_runtime_release_supplier(),
make its callers take care of triggering a runtime-suspend of the
supplier device as needed.

No expected functional impact.

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: 5.1+ <stable@vger.kernel.org> # 5.1+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
rafaeljw authored and gregkh committed Jul 12, 2022
1 parent cecb806 commit d6931bf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
3 changes: 2 additions & 1 deletion drivers/base/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ static void device_link_release_fn(struct work_struct *work)
/* Ensure that all references to the link object have been dropped. */
device_link_synchronize_removal();

pm_runtime_release_supplier(link, true);
pm_runtime_release_supplier(link);
pm_request_idle(link->supplier);

put_device(link->consumer);
put_device(link->supplier);
Expand Down
20 changes: 9 additions & 11 deletions drivers/base/power/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,10 @@ static int rpm_get_suppliers(struct device *dev)
/**
* pm_runtime_release_supplier - Drop references to device link's supplier.
* @link: Target device link.
* @check_idle: Whether or not to check if the supplier device is idle.
*
* Drop all runtime PM references associated with @link to its supplier device
* and if @check_idle is set, check if that device is idle (and so it can be
* suspended).
* Drop all runtime PM references associated with @link to its supplier device.
*/
void pm_runtime_release_supplier(struct device_link *link, bool check_idle)
void pm_runtime_release_supplier(struct device_link *link)
{
struct device *supplier = link->supplier;

Expand All @@ -327,18 +324,18 @@ void pm_runtime_release_supplier(struct device_link *link, bool check_idle)
while (refcount_dec_not_one(&link->rpm_active) &&
atomic_read(&supplier->power.usage_count) > 0)
pm_runtime_put_noidle(supplier);

if (check_idle)
pm_request_idle(supplier);
}

static void __rpm_put_suppliers(struct device *dev, bool try_to_suspend)
{
struct device_link *link;

list_for_each_entry_rcu(link, &dev->links.suppliers, c_node,
device_links_read_lock_held())
pm_runtime_release_supplier(link, try_to_suspend);
device_links_read_lock_held()) {
pm_runtime_release_supplier(link);
if (try_to_suspend)
pm_request_idle(link->supplier);
}
}

static void rpm_put_suppliers(struct device *dev)
Expand Down Expand Up @@ -1776,7 +1773,8 @@ void pm_runtime_drop_link(struct device_link *link)
return;

pm_runtime_drop_link_count(link->consumer);
pm_runtime_release_supplier(link, true);
pm_runtime_release_supplier(link);
pm_request_idle(link->supplier);
}

static bool pm_runtime_need_not_resume(struct device *dev)
Expand Down
5 changes: 2 additions & 3 deletions include/linux/pm_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ 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_link *link);
extern void pm_runtime_release_supplier(struct device_link *link, bool check_idle);
extern void pm_runtime_release_supplier(struct device_link *link);

/**
* pm_runtime_get_if_in_use - Conditionally bump up runtime PM usage counter.
Expand Down Expand Up @@ -280,8 +280,7 @@ 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_link *link) {}
static inline void pm_runtime_release_supplier(struct device_link *link,
bool check_idle) {}
static inline void pm_runtime_release_supplier(struct device_link *link) {}

#endif /* !CONFIG_PM */

Expand Down

0 comments on commit d6931bf

Please sign in to comment.