mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Linux PM mailing list <linux-pm@lists.linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Kevin Hilman <khilman@ti.com>,
	Alan Stern <stern@rowland.harvard.edu>,
	MyungJoo Ham <myungjoo.ham@samsung.com>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	Paul Walmsley <paul@pwsan.com>, Greg KH <gregkh@suse.de>,
	Magnus Damm <magnus.damm@gmail.com>
Subject: [PATCH 6/6 v2] PM / Domains: Improve handling of wakeup devices during system suspend
Date: Sun, 10 Jul 2011 11:09:35 +0200	[thread overview]
Message-ID: <201107101109.36176.rjw@sisk.pl> (raw)
In-Reply-To: <201107101059.30322.rjw@sisk.pl>

From: Rafael J. Wysocki <rjw@sisk.pl>

Kevin points out that if there's a device that can wake up the system
from sleep states, but it doesn't generate wakeup signals by itself
(they are generated on its behalf by other parts of the system) and
it currently is not enabled to wake up the system (that is,
device_may_wakeup() returns "false" for it), we may need to change
its wakeup settings during system suspend (for example, the device
might have been configured to signal remote wakeup from the system's
working state, as needed by runtime PM).  Therefore the generic PM
domains code should invoke the system suspend callbacks provided by
the device's driver, which it doesn't do if the PM domain is powered
off during the system suspend's "prepare" stage.  This is a valid
point.  Moreover, this code also should make sure that system wakeup
devices that are enabled to wake up the system from sleep states and
have to remain active for this purpose are not suspended while the
system is in a sleep state.

To avoid the above issues, make the generic PM domains' .prepare()
routine, pm_genpd_prepare(), force runtime resume of devices whose
system wakeup settings may need to be changed during system suspend
or that should remain active while the system is in a sleep state to
be able to wake it up from that state.

Reported-by: Kevin Hilman <khilman@ti.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/base/power/domain.c |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

Index: linux-2.6/drivers/base/power/domain.c
===================================================================
--- linux-2.6.orig/drivers/base/power/domain.c
+++ linux-2.6/drivers/base/power/domain.c
@@ -482,6 +482,33 @@ static void pm_genpd_sync_poweroff(struc
 }
 
 /**
+ * resume_needed - Check whether to resume a device before system suspend.
+ * @dev: Device to check.
+ * @genpd: PM domain the device belongs to.
+ *
+ * There are two cases in which a device that can wake up the system from sleep
+ * states should be resumed by pm_genpd_prepare(): (1) if the device is enabled
+ * to wake up the system and it has to remain active for this purpose while the
+ * system is in the sleep state and (2) if the device is not enabled to wake up
+ * the system from sleep states and it generally doesn't generate wakeup signals
+ * by itself (those signals are generated on its behalf by other parts of the
+ * system).  In the latter case it may be necessary to reconfigure the device's
+ * wakeup settings during system suspend, because it may have been set up to
+ * signal remote wakeup from the system's working state as needed by runtime PM.
+ * Return 'true' in either of the above cases.
+ */
+static bool resume_needed(struct device *dev, struct generic_pm_domain *genpd)
+{
+	bool active_wakeup;
+
+	if (!device_can_wakeup(dev))
+		return false;
+
+	active_wakeup = genpd->active_wakeup && genpd->active_wakeup(dev);
+	return device_may_wakeup(dev) ? active_wakeup : !active_wakeup;
+}
+
+/**
  * pm_genpd_prepare - Start power transition of a device in a PM domain.
  * @dev: Device to start the transition of.
  *
@@ -515,6 +542,9 @@ static int pm_genpd_prepare(struct devic
 		return -EBUSY;
 	}
 
+	if (resume_needed(dev, genpd))
+		pm_runtime_resume(dev);
+
 	genpd_acquire_lock(genpd);
 
 	if (genpd->prepared_count++ == 0)


  parent reply	other threads:[~2011-07-10  9:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-06 20:48 [PATCH 0/5 v1] PM / Domains: Generic PM domains improvements Rafael J. Wysocki
2011-07-06 20:50 ` [PATCH 1/5 v1] PM / Domains: Set device state to "active" during system resume Rafael J. Wysocki
2011-07-06 20:51 ` [PATCH 2/5 v1] PM / Domains: Make failing pm_genpd_prepare() clean up properly Rafael J. Wysocki
2011-07-06 20:53 ` [PATCH 3/5 v1] PM / Domains: Rework locking Rafael J. Wysocki
2011-07-08 10:21   ` [Update][PATCH 3/5] " Rafael J. Wysocki
2011-07-06 21:00 ` [PATCH 4/5 v1] PM / Domains: Allow callbacks to execute arbitrary runtime PM helpers Rafael J. Wysocki
2011-07-07 19:59   ` [Update][PATCH 4/5] PM / Domains: Allow callbacks to execute all " Rafael J. Wysocki
2011-07-06 21:01 ` [PATCH 5/5 v1] PM / Domains: Do not restore all devices on power off error Rafael J. Wysocki
2011-07-07 20:01   ` [Update][PATCH 5/5] " Rafael J. Wysocki
2011-07-06 21:08 ` [PATCH 0/5 v1] PM / Domains: Generic PM domains improvements Greg KH
2011-07-06 21:12   ` Rafael J. Wysocki
2011-07-10  8:59 ` [PATCH 0/6 v2] " Rafael J. Wysocki
2011-07-10  9:05   ` [PATCH 1/6 v2] PM / Domains: Set device state to "active" during system resume Rafael J. Wysocki
2011-07-10  9:06   ` [PATCH 2/6 v2] PM / Domains: Make failing pm_genpd_prepare() clean up properly Rafael J. Wysocki
2011-07-10  9:07   ` [PATCH 3/6 v2] PM / Domains: Do not execute device callbacks under locks Rafael J. Wysocki
2011-07-10  9:08   ` [PATCH 4/6 v2] PM / Domains: Allow callbacks to execute all runtime PM helpers Rafael J. Wysocki
2011-07-10  9:08   ` [PATCH 5/6 v2] PM / Domains: Do not restore all devices on power off error Rafael J. Wysocki
2011-07-10  9:09   ` Rafael J. Wysocki [this message]
2011-07-10 12:29   ` [PATCH 7 v2] PM / Domains: Queue up power off work only if it is not pending 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=201107101109.36176.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=cw00.choi@samsung.com \
    --cc=gregkh@suse.de \
    --cc=khilman@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=magnus.damm@gmail.com \
    --cc=myungjoo.ham@samsung.com \
    --cc=paul@pwsan.com \
    --cc=stern@rowland.harvard.edu \
    /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®