From: lina.iyer@linaro.org (Lina Iyer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 07/16] kernel/cpu_pm: Add runtime PM support for CPUs
Date: Fri, 26 Aug 2016 14:17:49 -0600 [thread overview]
Message-ID: <1472242678-33700-8-git-send-email-lina.iyer@linaro.org> (raw)
In-Reply-To: <1472242678-33700-1-git-send-email-lina.iyer@linaro.org>
Notify runtime PM when the CPU is going to be powered off in the idle
state. This allows for runtime PM suspend/resume of the CPU as well as
its PM domain.
Cc: Kevin Hilman <khilman@kernel.org>
Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
Signed-off-by: Lina Iyer <lina.iyer@linaro.org>
---
kernel/cpu_pm.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/kernel/cpu_pm.c b/kernel/cpu_pm.c
index 009cc9a..657ce06 100644
--- a/kernel/cpu_pm.c
+++ b/kernel/cpu_pm.c
@@ -16,9 +16,11 @@
*/
#include <linux/kernel.h>
+#include <linux/cpu.h>
#include <linux/cpu_pm.h>
#include <linux/module.h>
#include <linux/notifier.h>
+#include <linux/pm_runtime.h>
#include <linux/spinlock.h>
#include <linux/syscore_ops.h>
@@ -99,6 +101,7 @@ int cpu_pm_enter(void)
{
int nr_calls;
int ret = 0;
+ struct device *dev = get_cpu_device(smp_processor_id());
read_lock(&cpu_pm_notifier_lock);
ret = cpu_pm_notify(CPU_PM_ENTER, -1, &nr_calls);
@@ -110,6 +113,10 @@ int cpu_pm_enter(void)
cpu_pm_notify(CPU_PM_ENTER_FAILED, nr_calls - 1, NULL);
read_unlock(&cpu_pm_notifier_lock);
+ /* Notify Runtime PM that we are suspending the CPU */
+ if (!ret && dev)
+ RCU_NONIDLE(pm_runtime_put_sync_suspend(dev));
+
return ret;
}
EXPORT_SYMBOL_GPL(cpu_pm_enter);
@@ -129,6 +136,11 @@ EXPORT_SYMBOL_GPL(cpu_pm_enter);
int cpu_pm_exit(void)
{
int ret;
+ struct device *dev = get_cpu_device(smp_processor_id());
+
+ /* Notify Runtime PM that we are resuming the CPU */
+ if (dev)
+ RCU_NONIDLE(pm_runtime_get_sync(dev));
read_lock(&cpu_pm_notifier_lock);
ret = cpu_pm_notify(CPU_PM_EXIT, -1, NULL);
@@ -200,6 +212,39 @@ int cpu_cluster_pm_exit(void)
}
EXPORT_SYMBOL_GPL(cpu_cluster_pm_exit);
+#ifdef CONFIG_HOTPLUG_CPU
+static int cpu_pm_cpu_hotplug(struct notifier_block *nb,
+ unsigned long action, void *data)
+{
+ struct device *dev = get_cpu_device(smp_processor_id());
+
+ if (!dev)
+ return NOTIFY_OK;
+
+ /* Execute CPU runtime PM on that CPU */
+ switch (action & ~CPU_TASKS_FROZEN) {
+ case CPU_DYING:
+ pm_runtime_put_sync_suspend(dev);
+ break;
+ case CPU_STARTING:
+ pm_runtime_get_sync(dev);
+ break;
+ default:
+ break;
+ }
+
+ return NOTIFY_OK;
+}
+
+static int __init cpu_pm_hotplug_init(void)
+{
+ /* Register for hotplug notifications for runtime PM */
+ hotcpu_notifier(cpu_pm_cpu_hotplug, 0);
+ return 0;
+}
+device_initcall(cpu_pm_hotplug_init);
+#endif
+
#ifdef CONFIG_PM
static int cpu_pm_suspend(void)
{
--
2.7.4
next prev parent reply other threads:[~2016-08-26 20:17 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-26 20:17 [PATCH v5 00/16] PM: SoC idle support using PM domains Lina Iyer
2016-08-26 20:17 ` [PATCH v5 01/16] PM / Domains: Allow domain power states to be read from DT Lina Iyer
2016-08-26 20:17 ` [PATCH v5 02/16] dt/bindings: Update binding for PM domain idle states Lina Iyer
2016-09-02 14:21 ` Sudeep Holla
2016-09-02 20:16 ` Lina Iyer
2016-09-12 15:19 ` Brendan Jackman
2016-09-12 16:16 ` Lina Iyer
2016-09-12 17:09 ` Sudeep Holla
2016-09-13 17:50 ` Brendan Jackman
2016-09-13 19:38 ` Lina Iyer
2016-09-14 10:14 ` Brendan Jackman
2016-09-14 11:37 ` Ulf Hansson
2016-09-14 14:55 ` Lina Iyer
2016-09-16 17:13 ` Kevin Hilman
2016-09-16 17:39 ` Sudeep Holla
2016-09-19 15:09 ` Brendan Jackman
2016-09-20 16:17 ` Lina Iyer
2016-09-21 9:48 ` Brendan Jackman
2016-08-26 20:17 ` [PATCH v5 03/16] PM / Domains: Abstract genpd locking Lina Iyer
2016-08-26 20:17 ` [PATCH v5 04/16] PM / Domains: Support IRQ safe PM domains Lina Iyer
2016-08-26 20:17 ` [PATCH v5 05/16] PM / doc: Update device documentation for devices in " Lina Iyer
2016-08-26 20:17 ` [PATCH v5 06/16] drivers: cpu: Setup CPU devices to do runtime PM Lina Iyer
2016-08-26 20:17 ` Lina Iyer [this message]
2016-08-26 20:17 ` [PATCH v5 08/16] PM / cpu_domains: Setup PM domains for CPUs/clusters Lina Iyer
2016-08-26 20:17 ` [PATCH v5 09/16] PM / cpu_domains: Initialize CPU PM domains from DT Lina Iyer
2016-08-26 23:28 ` kbuild test robot
2016-08-26 20:17 ` [PATCH v5 10/16] timer: Export next wake up of a CPU Lina Iyer
2016-08-26 21:29 ` kbuild test robot
2016-08-26 20:17 ` [PATCH v5 11/16] PM / cpu_domains: Add PM Domain governor for CPUs Lina Iyer
2016-08-26 23:10 ` kbuild test robot
2016-08-26 20:17 ` [PATCH v5 12/16] doc / cpu_domains: Describe CPU PM domains setup and governor Lina Iyer
2016-08-26 20:17 ` [PATCH v5 13/16] drivers: firmware: psci: Allow OS Initiated suspend mode Lina Iyer
2016-08-26 20:17 ` [PATCH v5 14/16] drivers: firmware: psci: Support cluster idle states for OS-Initiated Lina Iyer
2016-08-26 20:17 ` [PATCH v5 15/16] dt/bindings: Add PSCI OS-Initiated PM Domains bindings Lina Iyer
2016-08-26 20:17 ` [PATCH v5 16/16] ARM64: dts: Define CPU power domain for MSM8916 Lina Iyer
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=1472242678-33700-8-git-send-email-lina.iyer@linaro.org \
--to=lina.iyer@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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).