diff mbox

[V5,2/9] drivers: cpu: Setup CPU devices to do runtime PM

Message ID 1488573695-106680-3-git-send-email-lina.iyer@linaro.org (mailing list archive)
State Not Applicable, archived
Delegated to: Andy Gross
Headers show

Commit Message

Lina Iyer March 3, 2017, 8:41 p.m. UTC
CPU devices just like any other device, can do runtime PM. However, CPU
devices may only do runtime only when IRQs are disabled. The devices
must be set as IRQ safe.

Cc: Kevin Hilman <khilman@kernel.org>
Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
Signed-off-by: Lina Iyer <lina.iyer@linaro.org>
---
 drivers/base/cpu.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Ulf Hansson March 13, 2017, 3:55 p.m. UTC | #1
On 3 March 2017 at 21:41, Lina Iyer <lina.iyer@linaro.org> wrote:
> CPU devices just like any other device, can do runtime PM. However, CPU
> devices may only do runtime only when IRQs are disabled. The devices
> must be set as IRQ safe.
>
> Cc: Kevin Hilman <khilman@kernel.org>
> Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
> Signed-off-by: Lina Iyer <lina.iyer@linaro.org>
> ---
>  drivers/base/cpu.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>
> diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
> index 2c3b359..77451ad 100644
> --- a/drivers/base/cpu.c
> +++ b/drivers/base/cpu.c
> @@ -18,6 +18,7 @@
>  #include <linux/cpufeature.h>
>  #include <linux/tick.h>
>  #include <linux/pm_qos.h>
> +#include <linux/pm_runtime.h>
>
>  #include "base.h"
>
> @@ -345,6 +346,19 @@ static int cpu_uevent(struct device *dev, struct kobj_uevent_env *env)
>  }
>  #endif
>
> +#ifdef CONFIG_PM
> +static void cpu_runtime_pm_init(struct device *dev)
> +{
> +       pm_runtime_irq_safe(dev);
> +       pm_runtime_enable(dev);
> +       if (cpu_online(dev->id))
> +               pm_runtime_set_active(dev);

You shouldn't change the runtime PM status of the device when runtime
PM is enabled. Instead do that before you call pm_runtime_enable().

> +}
> +#else
> +static void cpu_runtime_pm_init(struct device *dev)

There is no need for a stub function, as the runtime PM API already
provides stubs for when CONFIG_PM is unset.

> +{ }
> +#endif
> +
>  /*
>   * register_cpu - Setup a sysfs device for a CPU.
>   * @cpu - cpu->hotpluggable field set to 1 will generate a control file in
> @@ -379,6 +393,7 @@ int register_cpu(struct cpu *cpu, int num)
>         register_cpu_under_node(num, cpu_to_node(num));
>         dev_pm_qos_expose_latency_limit(&cpu->dev, 0);
>
> +       cpu_runtime_pm_init(&cpu->dev);
>         return 0;
>  }
>
> --
> 2.7.4
>

Kind regards
Uffe
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 2c3b359..77451ad 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -18,6 +18,7 @@ 
 #include <linux/cpufeature.h>
 #include <linux/tick.h>
 #include <linux/pm_qos.h>
+#include <linux/pm_runtime.h>
 
 #include "base.h"
 
@@ -345,6 +346,19 @@  static int cpu_uevent(struct device *dev, struct kobj_uevent_env *env)
 }
 #endif
 
+#ifdef CONFIG_PM
+static void cpu_runtime_pm_init(struct device *dev)
+{
+	pm_runtime_irq_safe(dev);
+	pm_runtime_enable(dev);
+	if (cpu_online(dev->id))
+		pm_runtime_set_active(dev);
+}
+#else
+static void cpu_runtime_pm_init(struct device *dev)
+{ }
+#endif
+
 /*
  * register_cpu - Setup a sysfs device for a CPU.
  * @cpu - cpu->hotpluggable field set to 1 will generate a control file in
@@ -379,6 +393,7 @@  int register_cpu(struct cpu *cpu, int num)
 	register_cpu_under_node(num, cpu_to_node(num));
 	dev_pm_qos_expose_latency_limit(&cpu->dev, 0);
 
+	cpu_runtime_pm_init(&cpu->dev);
 	return 0;
 }