From: Rafael J. Wysocki Date: Thu, 17 Jul 2025 17:55:25 +0000 (+0200) Subject: Merge back earlier material related to system sleep X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c1f7c22e69fae209eaad58de2627b8b5acb3cb3;p=thirdparty%2Flinux.git Merge back earlier material related to system sleep --- 7c1f7c22e69fae209eaad58de2627b8b5acb3cb3 diff --cc drivers/base/power/main.c index 7a50af416cac8,215c147eed040..5d9b3dc9011dc --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@@ -1278,24 -1301,28 +1301,44 @@@ static bool dpm_async_suspend_parent(st /* Start processing the device's parent if it is "async". */ if (dev->parent) dpm_async_with_cleanup(dev->parent, func); + + return true; + } + + static void dpm_async_suspend_superior(struct device *dev, async_func_t func) + { + struct device_link *link; + int idx; + + if (!dpm_async_suspend_parent(dev, func)) + return; + + idx = device_links_read_lock(); + + /* Start processing the device's "async" suppliers. */ + list_for_each_entry_rcu(link, &dev->links.suppliers, c_node) + if (READ_ONCE(link->status) != DL_STATE_DORMANT) + dpm_async_with_cleanup(link->supplier, func); + + device_links_read_unlock(idx); } +static void dpm_async_suspend_complete_all(struct list_head *device_list) +{ + struct device *dev; + + guard(mutex)(&async_wip_mtx); + + list_for_each_entry_reverse(dev, device_list, power.entry) { + /* + * In case the device is being waited for and async processing + * has not started for it yet, let the waiters make progress. + */ + if (!dev->power.work_in_progress) + complete_all(&dev->power.completion); + } +} + /** * resume_event - Return a "resume" message for given "suspend" sleep state. * @sleep_state: PM message representing a sleep state.