Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1232785

[RFC 6/7] arm: cpuidle: let genpd handle the cluster power transition with 'power-states'

From Marc Titinger <mtitinger@baylibre.com>
Newsgroups linux.kernel
Subject [RFC 6/7] arm: cpuidle: let genpd handle the cluster power transition with 'power-states'
Date 2015-09-25 15:10 +0200
Message-ID <qcAVc-2gw-23@gated-at.bofh.it> (permalink)
References <qcAVb-2gw-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Marc Titinger <mtitinger@baylibre.com>

Cpuidle now handles c-states and power-states differently. c-states do not decrement
 the reference count for the CPUs in the cluster, while power-states i.e.
cluster level states like 'CLUSTER_SLEEP_0' in the case of juno, will.

The 'D1' fake device also registers intermediate power-state,
for experimentation.

Signed-off-by: Marc Titinger <mtitinger@baylibre.com>
---
 arch/arm64/boot/dts/arm/juno.dts |  2 +-
 drivers/cpuidle/cpuidle-arm.c    | 50 ++++++++++++++++++++++++++++++++--------
 2 files changed, 42 insertions(+), 10 deletions(-)

diff --git a/arch/arm64/boot/dts/arm/juno.dts b/arch/arm64/boot/dts/arm/juno.dts
index cadc5de..0bb0dd7 100644
--- a/arch/arm64/boot/dts/arm/juno.dts
+++ b/arch/arm64/boot/dts/arm/juno.dts
@@ -47,7 +47,7 @@
 			};
 
 			CLUSTER_SLEEP_0: cluster-sleep-0 {
-				compatible = "arm,idle-state","arm,power-state";
+				compatible = "arm,power-state";
 				arm,psci-suspend-param = <0x1010000>;
 				local-timer-stop;
 				entry-latency-us = <800>;
diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c
index ca118ed..592bb1cb 100644
--- a/drivers/cpuidle/cpuidle-arm.c
+++ b/drivers/cpuidle/cpuidle-arm.c
@@ -39,7 +39,6 @@ static int arm_enter_idle_state(struct cpuidle_device *dev,
 				struct cpuidle_driver *drv, int idx)
 {
 	int ret;
-	struct device *cpu_dev = get_cpu_device(dev->cpu);
 
 	if (!idx) {
 		cpu_do_idle();
@@ -48,11 +47,6 @@ static int arm_enter_idle_state(struct cpuidle_device *dev,
 
 	ret = cpu_pm_enter();
 	if (!ret) {
-		/*
-		* Notify runtime PM as well of this cpu powering down
-		* TODO: Merge CPU_PM and runtime PM.
-		*/
-		pm_runtime_put_sync(cpu_dev);
 
 		/*
 		 * Pass idle state index to cpu_suspend which in turn will
@@ -61,6 +55,43 @@ static int arm_enter_idle_state(struct cpuidle_device *dev,
 		 */
 		arm_cpuidle_suspend(idx);
 
+		cpu_pm_exit();
+	}
+
+	return ret ? -1 : idx;
+}
+
+/*
+ * arm_enter_power_state - delegate state trasition to genpd
+ *
+ * dev: cpuidle device
+ * drv: cpuidle driver
+ * idx: state index
+ *
+ * Called from the CPUidle framework to delegate a state transition
+ * to the generic domain. This will be a cluster poweroff state
+ * the Domain will chose to actually turn off the cluster based on
+ * the status of other CPUs, and devices and subdomains in the Cluster
+ * domain.
+ */
+static int arm_enter_power_state(struct cpuidle_device *dev,
+				 struct cpuidle_driver *drv, int idx)
+{
+	int ret;
+	struct device *cpu_dev = get_cpu_device(dev->cpu);
+
+	BUG_ON(idx == 0);
+
+	ret = cpu_pm_enter();
+	if (!ret) {
+		/*
+		 * Notify runtime PM as well of this cpu powering down
+		 * TODO: Merge CPU_PM and runtime PM.
+		 */
+		pm_runtime_put_sync(cpu_dev);
+
+		arm_cpuidle_suspend(idx);
+
 		pm_runtime_get_sync(cpu_dev);
 		cpu_pm_exit();
 	}
@@ -89,9 +120,10 @@ static struct cpuidle_driver arm_idle_driver = {
 };
 
 static const struct of_device_id arm_idle_state_match[] __initconst = {
-	{ .compatible = "arm,idle-state",
-	  .data = arm_enter_idle_state },
-	{ },
+	{.compatible = "arm,idle-state",
+	 .data = arm_enter_idle_state},
+	{.compatible = "arm,power-state",
+	 .data = arm_enter_power_state},
 };
 
 /*
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC 0/7] Managing cluser-level c-states with generic power domains Marc Titinger <mtitinger@baylibre.com> - 2015-09-25 15:10 +0200
  [RFC 4/7] PM / Domains: introduce power-states consistent with c-states. Marc Titinger <mtitinger@baylibre.com> - 2015-09-25 15:10 +0200
  [RFC 3/7] PM / Domains: prepare for devices that might register a power state Marc Titinger <mtitinger@baylibre.com> - 2015-09-25 15:10 +0200
  [RFC 7/7] PM / Domains: add debugfs 'states' and 'timings' seq files Marc Titinger <mtitinger@baylibre.com> - 2015-09-25 15:10 +0200
  [RFC 1/7] arm64: pm/domains: try mutualize CPU domains init between arm/arm64 Marc Titinger <mtitinger@baylibre.com> - 2015-09-25 15:10 +0200
  [RFC 6/7] arm: cpuidle: let genpd handle the cluster power transition with 'power-states' Marc Titinger <mtitinger@baylibre.com> - 2015-09-25 15:10 +0200
  [RFC 2/7] arm64: Juno: declare generic power domains for both clusters. Marc Titinger <mtitinger@baylibre.com> - 2015-09-25 15:10 +0200
  [RFC 5/7] PM / Domains: succeed & warn when attaching non-irqsafe devices to an irq-safe domain. Marc Titinger <mtitinger@baylibre.com> - 2015-09-25 15:10 +0200

csiph-web