All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Linux PM list <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Linux-sh list <linux-sh@vger.kernel.org>,
	Magnus Damm <magnus.damm@gmail.com>,
	Paul Mundt <lethal@linux-sh.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH 1/15] PM / Domains: Introduce simplified power on routine for system resume
Date: Sun, 05 Aug 2012 23:39:16 +0000	[thread overview]
Message-ID: <201208060139.17136.rjw@sisk.pl> (raw)
In-Reply-To: <201208060138.03950.rjw@sisk.pl>


Introduce function pm_genpd_sync_poweron() for restoring domain power
during resume from system suspend and hibernation.  It can be much
simpler than pm_genpd_poweron(), because it doesn't have to care
about locking and it can skip many checks done by the latter.

Modify pm_genpd_resume_noirq() and pm_genpd_restore_noirq() to use
the new function.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/base/power/domain.c |   34 ++++++++++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 4 deletions(-)

Index: linux/drivers/base/power/domain.c
=================================--- linux.orig/drivers/base/power/domain.c
+++ linux/drivers/base/power/domain.c
@@ -777,6 +777,32 @@ static void pm_genpd_sync_poweroff(struc
 }
 
 /**
+ * pm_genpd_sync_poweron - Synchronously power on a PM domain and its masters.
+ * @genpd: PM domain to power on.
+ *
+ * This function is only called in "noirq" stage of system power transitions, so
+ * it need not acquire locks (all of the "noirq" callbacks are executed
+ * sequentially, so it is guaranteed that it will never run twice in parallel).
+ */
+static void pm_genpd_sync_poweron(struct generic_pm_domain *genpd)
+{
+	struct gpd_link *link;
+
+	if (genpd->status != GPD_STATE_POWER_OFF)
+		return;
+
+	list_for_each_entry(link, &genpd->slave_links, slave_node) {
+		pm_genpd_sync_poweron(link->master);
+		genpd_sd_counter_inc(link->master);
+	}
+
+	if (genpd->power_on)
+		genpd->power_on(genpd);
+
+	genpd->status = GPD_STATE_ACTIVE;
+}
+
+/**
  * resume_needed - Check whether to resume a device before system suspend.
  * @dev: Device to check.
  * @genpd: PM domain the device belongs to.
@@ -979,7 +1005,7 @@ static int pm_genpd_resume_noirq(struct
 	 * guaranteed that this function will never run twice in parallel for
 	 * the same PM domain, so it is not necessary to use locking here.
 	 */
-	pm_genpd_poweron(genpd);
+	pm_genpd_sync_poweron(genpd);
 	genpd->suspended_count--;
 
 	return genpd_start_dev(genpd, dev);
@@ -1186,8 +1212,8 @@ static int pm_genpd_restore_noirq(struct
 	if (genpd->suspended_count++ = 0) {
 		/*
 		 * The boot kernel might put the domain into arbitrary state,
-		 * so make it appear as powered off to pm_genpd_poweron(), so
-		 * that it tries to power it on in case it was really off.
+		 * so make it appear as powered off to pm_genpd_sync_poweron(),
+		 * so that it tries to power it on in case it was really off.
 		 */
 		genpd->status = GPD_STATE_POWER_OFF;
 		if (genpd->suspend_power_off) {
@@ -1205,7 +1231,7 @@ static int pm_genpd_restore_noirq(struct
 	if (genpd->suspend_power_off)
 		return 0;
 
-	pm_genpd_poweron(genpd);
+	pm_genpd_sync_poweron(genpd);
 
 	return dev_gpd_data(dev)->always_on ? 0 : genpd_start_dev(genpd, dev);
 }


WARNING: multiple messages have this Message-ID (diff)
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Linux PM list <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	"Linux-sh list" <linux-sh@vger.kernel.org>,
	Magnus Damm <magnus.damm@gmail.com>,
	Paul Mundt <lethal@linux-sh.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH 1/15] PM / Domains: Introduce simplified power on routine for system resume
Date: Mon, 6 Aug 2012 01:39:16 +0200	[thread overview]
Message-ID: <201208060139.17136.rjw@sisk.pl> (raw)
In-Reply-To: <201208060138.03950.rjw@sisk.pl>


Introduce function pm_genpd_sync_poweron() for restoring domain power
during resume from system suspend and hibernation.  It can be much
simpler than pm_genpd_poweron(), because it doesn't have to care
about locking and it can skip many checks done by the latter.

Modify pm_genpd_resume_noirq() and pm_genpd_restore_noirq() to use
the new function.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/base/power/domain.c |   34 ++++++++++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 4 deletions(-)

Index: linux/drivers/base/power/domain.c
===================================================================
--- linux.orig/drivers/base/power/domain.c
+++ linux/drivers/base/power/domain.c
@@ -777,6 +777,32 @@ static void pm_genpd_sync_poweroff(struc
 }
 
 /**
+ * pm_genpd_sync_poweron - Synchronously power on a PM domain and its masters.
+ * @genpd: PM domain to power on.
+ *
+ * This function is only called in "noirq" stage of system power transitions, so
+ * it need not acquire locks (all of the "noirq" callbacks are executed
+ * sequentially, so it is guaranteed that it will never run twice in parallel).
+ */
+static void pm_genpd_sync_poweron(struct generic_pm_domain *genpd)
+{
+	struct gpd_link *link;
+
+	if (genpd->status != GPD_STATE_POWER_OFF)
+		return;
+
+	list_for_each_entry(link, &genpd->slave_links, slave_node) {
+		pm_genpd_sync_poweron(link->master);
+		genpd_sd_counter_inc(link->master);
+	}
+
+	if (genpd->power_on)
+		genpd->power_on(genpd);
+
+	genpd->status = GPD_STATE_ACTIVE;
+}
+
+/**
  * resume_needed - Check whether to resume a device before system suspend.
  * @dev: Device to check.
  * @genpd: PM domain the device belongs to.
@@ -979,7 +1005,7 @@ static int pm_genpd_resume_noirq(struct
 	 * guaranteed that this function will never run twice in parallel for
 	 * the same PM domain, so it is not necessary to use locking here.
 	 */
-	pm_genpd_poweron(genpd);
+	pm_genpd_sync_poweron(genpd);
 	genpd->suspended_count--;
 
 	return genpd_start_dev(genpd, dev);
@@ -1186,8 +1212,8 @@ static int pm_genpd_restore_noirq(struct
 	if (genpd->suspended_count++ == 0) {
 		/*
 		 * The boot kernel might put the domain into arbitrary state,
-		 * so make it appear as powered off to pm_genpd_poweron(), so
-		 * that it tries to power it on in case it was really off.
+		 * so make it appear as powered off to pm_genpd_sync_poweron(),
+		 * so that it tries to power it on in case it was really off.
 		 */
 		genpd->status = GPD_STATE_POWER_OFF;
 		if (genpd->suspend_power_off) {
@@ -1205,7 +1231,7 @@ static int pm_genpd_restore_noirq(struct
 	if (genpd->suspend_power_off)
 		return 0;
 
-	pm_genpd_poweron(genpd);
+	pm_genpd_sync_poweron(genpd);
 
 	return dev_gpd_data(dev)->always_on ? 0 : genpd_start_dev(genpd, dev);
 }


  reply	other threads:[~2012-08-05 23:39 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-29 14:12 [RFC][PATCH 0/6] PM: Suspend/resume for clock sources/clock event devices in PM domains Rafael J. Wysocki
2012-07-29 14:12 ` Rafael J. Wysocki
2012-07-29 14:13 ` [RFC][PATCH 1/6] PM / Domains: Introduce simplified power on routine for system resume Rafael J. Wysocki
2012-07-29 14:13   ` Rafael J. Wysocki
2012-07-29 14:14 ` [RFC][PATCH 2/6] PM / Domains: Add power off/on function for system core suspend stage Rafael J. Wysocki
2012-07-29 14:14   ` Rafael J. Wysocki
2012-07-29 14:15 ` [RFC][PATCH 3/6] timekeeping: Add suspend and resume of clock event devices Rafael J. Wysocki
2012-07-29 14:15   ` Rafael J. Wysocki
2012-07-29 14:16 ` [RFC][PATCH 4/6] sh: TMU: Introduce clocksource/clock events suspend/resume routines Rafael J. Wysocki
2012-07-29 14:16   ` Rafael J. Wysocki
2012-07-29 14:16 ` [RFC][PATCH 5/6] sh: CMT: " Rafael J. Wysocki
2012-07-29 14:16   ` Rafael J. Wysocki
2012-07-29 14:17 ` [RFC][PATCH 6/6] sh: MTU2: Introduce clock " Rafael J. Wysocki
2012-07-29 14:17   ` Rafael J. Wysocki
2012-08-05 23:38 ` [PATCH 0/15] PM: Suspend/resume and runtime PM for clock sources/clock event devices in PM domains Rafael J. Wysocki
2012-08-05 23:38   ` Rafael J. Wysocki
2012-08-05 23:39   ` Rafael J. Wysocki [this message]
2012-08-05 23:39     ` [PATCH 1/15] PM / Domains: Introduce simplified power on routine for system resume Rafael J. Wysocki
2012-08-05 23:39   ` [PATCH 2/15] PM / Domains: Add power off/on function for system core suspend stage Rafael J. Wysocki
2012-08-05 23:39     ` Rafael J. Wysocki
2012-08-05 23:40   ` [PATCH 3/15] timekeeping: Add suspend and resume of clock event devices Rafael J. Wysocki
2012-08-05 23:40     ` Rafael J. Wysocki
2012-08-05 23:41   ` [PATCH 4/15] sh: TMU: Introduce clocksource/clock events suspend/resume routines Rafael J. Wysocki
2012-08-05 23:41     ` Rafael J. Wysocki
2012-08-05 23:43   ` [PATCH 5/15] sh: CMT: " Rafael J. Wysocki
2012-08-05 23:43     ` Rafael J. Wysocki
2012-08-05 23:43   ` [PATCH 6/15] sh: MTU2: Introduce clock " Rafael J. Wysocki
2012-08-05 23:43     ` Rafael J. Wysocki
2012-08-05 23:44   ` [PATCH 7/15] PM: Reorganize device PM initialization Rafael J. Wysocki
2012-08-05 23:44     ` Rafael J. Wysocki
2012-08-05 23:45   ` [PATCH 8/15] PM / Runtime: Allow helpers to be called by early platform drivers Rafael J. Wysocki
2012-08-05 23:45     ` Rafael J. Wysocki
2012-08-05 23:45   ` [PATCH 9/15] PM / Domains: Rename the always_on device flag to syscore Rafael J. Wysocki
2012-08-05 23:45     ` Rafael J. Wysocki
2012-08-05 23:46   ` [PATCH 10/15] PM / Domains: Move syscore flag from subsys data to struct device Rafael J. Wysocki
2012-08-05 23:46     ` Rafael J. Wysocki
2012-08-05 23:47   ` [PATCH 11/15] PM / Domains: Do not measure start time for "irq safe" devices Rafael J. Wysocki
2012-08-05 23:47     ` Rafael J. Wysocki
2012-08-05 23:48   ` [PATCH 12/15] sh: TMU: Basic runtime PM support Rafael J. Wysocki
2012-08-05 23:48     ` Rafael J. Wysocki
2012-08-05 23:48   ` [PATCH 13/15] sh: CMT: " Rafael J. Wysocki
2012-08-05 23:48     ` Rafael J. Wysocki
2012-08-05 23:49   ` [PATCH 14/15] sh: MTU2: " Rafael J. Wysocki
2012-08-05 23:49     ` Rafael J. Wysocki
2012-08-11  9:39     ` Geert Uytterhoeven
2012-08-11  9:39       ` Geert Uytterhoeven
2012-08-11 22:29       ` Rafael J. Wysocki
2012-08-11 22:29         ` Rafael J. Wysocki
2012-08-05 23:53   ` [PATCH 15/15] PM: Do not use the syscore flag for runtime PM Rafael J. Wysocki
2012-08-05 23:53     ` 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=201208060139.17136.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.