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 4/5] PM: sleep: Make async suspend handle suppliers like parents
Date: Fri, 14 Mar 2025 14:16:33 +0100 [thread overview]
Message-ID: <2651185.Lt9SDvczpP@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" suspend processing
upfront for devices that have consumers and start "async" suspend
processing for the supplies of a device after suspending 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 | 37 +++++++++++++++++++++++++++++++------
1 file changed, 31 insertions(+), 6 deletions(-)
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1249,10 +1249,15 @@
return false;
}
- return true;
+ /*
+ * 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 list_empty(&dev->links.consumers);
}
-static void dpm_async_suspend_parent(struct device *dev, async_func_t func)
+static bool dpm_async_suspend_parent(struct device *dev, async_func_t func)
{
guard(mutex)(&dpm_list_mtx);
@@ -1264,11 +1269,31 @@
* deleted before it.
*/
if (!device_pm_initialized(dev))
- return;
+ return false;
/* 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);
}
/**
@@ -1392,7 +1417,7 @@
if (error || async_error)
return error;
- dpm_async_suspend_parent(dev, async_suspend_noirq);
+ dpm_async_suspend_superior(dev, async_suspend_noirq);
return 0;
}
@@ -1588,7 +1613,7 @@
if (error || async_error)
return error;
- dpm_async_suspend_parent(dev, async_suspend_late);
+ dpm_async_suspend_superior(dev, async_suspend_late);
return 0;
}
@@ -1879,7 +1904,7 @@
if (error || async_error)
return error;
- dpm_async_suspend_parent(dev, async_suspend);
+ dpm_async_suspend_superior(dev, async_suspend);
return 0;
}
next prev parent reply other threads:[~2025-03-14 13:19 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 ` Rafael J. Wysocki [this message]
2025-03-14 13:17 ` [PATCH v3 5/5] PM: sleep: Make async resume handle consumers like children Rafael J. Wysocki
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=2651185.Lt9SDvczpP@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®