linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: xiaoming wang <xiaoming.wang@intel.com>
To: rjw@rjwysocki.net, len.brown@intel.com, pavel@ucw.cz,
	gregkh@linuxfoundation.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: xiaoming wang <xiaoming.wang@intel.com>,
	Chuansheng Liu <chuansheng.liu@intel.com>
Subject: [PATCH 2/2] PM / sleep: Asynchronous threads for dpm_complete
Date: Mon, 25 Aug 2014 11:13:37 -0400	[thread overview]
Message-ID: <1408979617-14140-2-git-send-email-xiaoming.wang@intel.com> (raw)
In-Reply-To: <1408979617-14140-1-git-send-email-xiaoming.wang@intel.com>

In analogy with commits 5af84b82701a and 97df8c12995,
using asynchronous threads can improve the overall
resume time significantly.

This patch is for dpm_complete phase.

Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
Signed-off-by: xiaoming wang <xiaoming.wang@intel.com>
---
 drivers/base/power/main.c |   38 ++++++++++++++++++++++++++++++++++----
 1 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index f9fe1b3..00c4bf1 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -889,14 +889,15 @@ void dpm_resume(pm_message_t state)
  * @dev: Device to handle.
  * @state: PM transition of the system being carried out.
  */
-static void device_complete(struct device *dev, pm_message_t state)
+static void device_complete(struct device *dev, pm_message_t state, bool async)
 {
 	void (*callback)(struct device *) = NULL;
 	char *info = NULL;
 
 	if (dev->power.syscore)
-		return;
+		goto Complete;
 
+	dpm_wait(dev->parent, async);
 	device_lock(dev);
 
 	if (dev->pm_domain) {
@@ -928,6 +929,17 @@ static void device_complete(struct device *dev, pm_message_t state)
 	device_unlock(dev);
 
 	pm_runtime_put(dev);
+
+Complete:
+	complete_all(&dev->power.completion);
+}
+
+static void async_complete(void *data, async_cookie_t cookie)
+{
+	struct device *dev = (struct device *)data;
+
+	device_complete(dev, pm_transition, true);
+	put_device(dev);
 }
 
 /**
@@ -940,27 +952,45 @@ static void device_complete(struct device *dev, pm_message_t state)
 void dpm_complete(pm_message_t state)
 {
 	struct list_head list;
+	struct device *dev;
 
 	trace_suspend_resume(TPS("dpm_complete"), state.event, true);
 	might_sleep();
 
 	INIT_LIST_HEAD(&list);
 	mutex_lock(&dpm_list_mtx);
+	pm_transition = state;
+
+	/*
+	  * Advanced the async threads upfront,
+	  * in case the starting of async threads is
+	  * delayed by non-async resuming devices.
+	  */
+	list_for_each_entry(dev, &dpm_prepared_list, power.entry) {
+		reinit_completion(&dev->power.completion);
+		if (is_async(dev)) {
+			get_device(dev);
+			async_schedule(async_complete, dev);
+		}
+	}
+
 	while (!list_empty(&dpm_prepared_list)) {
-		struct device *dev = to_device(dpm_prepared_list.prev);
+		dev = to_device(dpm_prepared_list.prev);
 
 		get_device(dev);
 		dev->power.is_prepared = false;
 		list_move(&dev->power.entry, &list);
 		mutex_unlock(&dpm_list_mtx);
 
-		device_complete(dev, state);
+		if (!is_async(dev))
+			device_complete(dev, state, false);
 
 		mutex_lock(&dpm_list_mtx);
 		put_device(dev);
 	}
 	list_splice(&list, &dpm_list);
 	mutex_unlock(&dpm_list_mtx);
+	async_synchronize_full();
 	trace_suspend_resume(TPS("dpm_complete"), state.event, false);
 }
 
-- 
1.7.1

  reply	other threads:[~2014-08-25 15:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-25 15:13 [PATCH 1/2] PM / sleep: Asynchronous threads for dpm_prepare xiaoming wang
2014-08-25 15:13 ` xiaoming wang [this message]
2014-08-25 14:27   ` [PATCH 2/2] PM / sleep: Asynchronous threads for dpm_complete kodiak furr
  -- strict thread matches above, loose matches on Subject: below --
2014-08-19 20:29 [PATCH 1/2] PM / sleep: Asynchronous threads for dpm_prepare xiaoming wang
2014-08-19 20:29 ` [PATCH 2/2] PM / sleep: Asynchronous threads for dpm_complete xiaoming wang

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=1408979617-14140-2-git-send-email-xiaoming.wang@intel.com \
    --to=xiaoming.wang@intel.com \
    --cc=chuansheng.liu@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rjw@rjwysocki.net \
    /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;
as well as URLs for NNTP newsgroup(s).