From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Alan Stern <stern@rowland.harvard.edu>,
Ulf Hansson <ulf.hansson@linaro.org>,
Johan Hovold <johan@kernel.org>,
Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
Jon Hunter <jonathanh@nvidia.com>,
Saravana Kannan <saravanak@google.com>
Subject: [PATCH v3 5/5] PM: sleep: Make async resume handle consumers like children
Date: Fri, 14 Mar 2025 14:17:49 +0100 [thread overview]
Message-ID: <2229735.Mh6RI2rZIc@rjwysocki.net> (raw)
In-Reply-To: <10629535.nUPlyArG6x@rjwysocki.net>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Following previous changes, avoid starting "async" resume processing
upfront for devices that have suppliers and start "async" resume
processing for the consumers of a device after resuming the device
itself.
Suggested-by: Saravana Kannan <saravanak@google.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
New patch in v3.
---
drivers/base/power/main.c | 33 ++++++++++++++++++++++++---------
1 file changed, 24 insertions(+), 9 deletions(-)
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -635,17 +635,25 @@
return 0;
}
-static void dpm_async_resume_children(struct device *dev, async_func_t func)
+static void dpm_async_resume_subordinate(struct device *dev, async_func_t func)
{
+ struct device_link *link;
+ int idx;
+
/*
* Start processing "async" children of the device unless it's been
* started already for them.
- *
- * This could have been done for the device's "async" consumers too, but
- * they either need to wait for their parents or the processing has
- * already started for them after their parents were processed.
*/
device_for_each_child(dev, func, dpm_async_with_cleanup);
+
+ idx = device_links_read_lock();
+
+ /* Start processing the device's "async" consumers. */
+ list_for_each_entry_rcu(link, &dev->links.consumers, s_node)
+ if (READ_ONCE(link->status) != DL_STATE_DORMANT)
+ dpm_async_with_cleanup(link->consumer, func);
+
+ device_links_read_unlock(idx);
}
static void dpm_clear_async_state(struct device *dev)
@@ -656,7 +664,14 @@
static bool dpm_root_device(struct device *dev)
{
- return !dev->parent;
+ lockdep_assert_held(&dpm_list_mtx);
+
+ /*
+ * Since this function is required to run under dpm_list_mtx, the
+ * list_empty() below will only return true if the device's list of
+ * consumers is actually empty before calling it.
+ */
+ return !dev->parent && list_empty(&dev->links.suppliers);
}
static void async_resume_noirq(void *data, async_cookie_t cookie);
@@ -745,7 +760,7 @@
pm_dev_err(dev, state, async ? " async noirq" : " noirq", error);
}
- dpm_async_resume_children(dev, async_resume_noirq);
+ dpm_async_resume_subordinate(dev, async_resume_noirq);
}
static void async_resume_noirq(void *data, async_cookie_t cookie)
@@ -888,7 +903,7 @@
pm_dev_err(dev, state, async ? " async early" : " early", error);
}
- dpm_async_resume_children(dev, async_resume_early);
+ dpm_async_resume_subordinate(dev, async_resume_early);
}
static void async_resume_early(void *data, async_cookie_t cookie)
@@ -1063,7 +1078,7 @@
pm_dev_err(dev, state, async ? " async" : "", error);
}
- dpm_async_resume_children(dev, async_resume);
+ dpm_async_resume_subordinate(dev, async_resume);
}
static void async_resume(void *data, async_cookie_t cookie)
next prev parent reply other threads:[~2025-03-14 13:18 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-14 12:46 [PATCH v3 0/5] PM: sleep: Improvements of async suspend and resume of devices Rafael J. Wysocki
2025-03-14 12:50 ` [PATCH v3 1/5] PM: sleep: Resume children after resuming the parent Rafael J. Wysocki
2025-05-01 9:51 ` Jon Hunter
2025-05-02 20:33 ` Rafael J. Wysocki
2025-05-07 13:21 ` Jon Hunter
2025-05-07 13:39 ` Rafael J. Wysocki
2025-05-07 14:25 ` Rafael J. Wysocki
2025-05-07 14:39 ` Jon Hunter
2025-05-07 14:56 ` Rafael J. Wysocki
2025-05-07 15:39 ` Jon Hunter
2025-05-07 16:43 ` Rafael J. Wysocki
2025-05-08 13:38 ` Jon Hunter
2025-05-08 18:06 ` Rafael J. Wysocki
2025-05-10 11:39 ` Rafael J. Wysocki
2025-05-10 11:50 ` Jon Hunter
2025-07-11 13:08 ` Tudor Ambarus
2025-07-11 13:38 ` Rafael J. Wysocki
2025-07-11 13:54 ` Rafael J. Wysocki
2025-07-11 18:30 ` Saravana Kannan
2025-07-12 7:57 ` Rafael J. Wysocki
2025-07-12 7:54 ` Rafael J. Wysocki
2025-07-14 7:09 ` Tudor Ambarus
2025-07-14 7:29 ` Rafael J. Wysocki
2025-07-14 10:35 ` Tudor Ambarus
2025-07-14 12:14 ` Tudor Ambarus
2025-03-14 13:13 ` [PATCH v3 2/5] PM: sleep: Suspend async parents after suspending children Rafael J. Wysocki
2025-06-02 12:11 ` Chris Bainbridge
2025-06-02 14:29 ` Rafael J. Wysocki
2025-06-02 15:21 ` Mario Limonciello
2025-06-02 19:58 ` Rafael J. Wysocki
2025-06-03 9:38 ` Rafael J. Wysocki
2025-06-03 10:17 ` Chris Bainbridge
2025-06-03 10:29 ` Rafael J. Wysocki
2025-06-03 10:30 ` Rafael J. Wysocki
2025-06-03 11:37 ` Rafael J. Wysocki
2025-06-03 11:39 ` Rafael J. Wysocki
2025-06-03 12:14 ` Chris Bainbridge
2025-06-03 12:23 ` Rafael J. Wysocki
2025-06-03 12:26 ` Chris Bainbridge
2025-06-03 13:04 ` Rafael J. Wysocki
2025-06-03 13:36 ` Chris Bainbridge
2025-06-03 13:59 ` Rafael J. Wysocki
2025-03-14 13:14 ` [PATCH v3 3/5] PM: sleep: Make suspend of devices more asynchronous Rafael J. Wysocki
2025-03-14 13:16 ` [PATCH v3 4/5] PM: sleep: Make async suspend handle suppliers like parents Rafael J. Wysocki
2025-03-14 13:17 ` Rafael J. Wysocki [this message]
2025-03-14 21:06 ` [PATCH v3 0/5] PM: sleep: Improvements of async suspend and resume of devices Saravana Kannan
2025-03-15 14:57 ` Rafael J. Wysocki
2025-04-08 13:39 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2229735.Mh6RI2rZIc@rjwysocki.net \
--to=rjw@rjwysocki.net \
--cc=johan@kernel.org \
--cc=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=saravanak@google.com \
--cc=stern@rowland.harvard.edu \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®