From: ccross@android.com (Colin Cross)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] ARM: vfp: Use cpu pm notifiers to save vfp state
Date: Sun, 12 Jun 2011 17:43:45 -0700 [thread overview]
Message-ID: <1307925825-28566-4-git-send-email-ccross@android.com> (raw)
In-Reply-To: <1307925825-28566-1-git-send-email-ccross@android.com>
When the cpu is powered down in a low power mode, the vfp
registers may be reset.
This patch uses CPU_PM_ENTER and CPU_PM_EXIT notifiers to save
and restore the cpu's vfp registers.
Signed-off-by: Colin Cross <ccross@android.com>
---
arch/arm/vfp/vfpmodule.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
index f25e7ec..6f08dbe 100644
--- a/arch/arm/vfp/vfpmodule.c
+++ b/arch/arm/vfp/vfpmodule.c
@@ -21,6 +21,7 @@
#include <asm/cputype.h>
#include <asm/thread_notify.h>
#include <asm/vfp.h>
+#include <asm/cpu_pm.h>
#include "vfpinstr.h"
#include "vfp.h"
@@ -169,6 +170,44 @@ static struct notifier_block vfp_notifier_block = {
.notifier_call = vfp_notifier,
};
+#ifdef CONFIG_CPU_PM
+static int vfp_cpu_pm_notifier(struct notifier_block *self, unsigned long cmd,
+ void *v)
+{
+ u32 fpexc = fmrx(FPEXC);
+ unsigned int cpu = smp_processor_id();
+
+ switch (cmd) {
+ case CPU_PM_ENTER:
+ if (last_VFP_context[cpu]) {
+ fmxr(FPEXC, fpexc | FPEXC_EN);
+ vfp_save_state(last_VFP_context[cpu], fpexc);
+ /* force a reload when coming back from idle */
+ last_VFP_context[cpu] = NULL;
+ fmxr(FPEXC, fpexc & ~FPEXC_EN);
+ }
+ break;
+ case CPU_PM_ENTER_FAILED:
+ case CPU_PM_EXIT:
+ /* make sure VFP is disabled when leaving idle */
+ fmxr(FPEXC, fpexc & ~FPEXC_EN);
+ break;
+ }
+ return NOTIFY_OK;
+}
+
+static struct notifier_block vfp_cpu_pm_notifier_block = {
+ .notifier_call = vfp_cpu_pm_notifier,
+};
+
+static void vfp_cpu_pm_init(void)
+{
+ cpu_pm_register_notifier(&vfp_cpu_pm_notifier_block);
+}
+#else
+static inline void vfp_cpu_pm_init(void) { }
+#endif
+
/*
* Raise a SIGFPE for the current process.
* sicode describes the signal being raised.
@@ -563,6 +602,7 @@ static int __init vfp_init(void)
vfp_vector = vfp_support_entry;
thread_register_notifier(&vfp_notifier_block);
+ vfp_cpu_pm_init();
vfp_pm_init();
/*
--
1.7.4.1
WARNING: multiple messages have this Message-ID (diff)
From: Colin Cross <ccross@android.com>
To: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org,
Russell King <linux@arm.linux.org.uk>,
Catalin Marinas <catalin.marinas@arm.com>,
Santosh Shilimkar <santosh.shilimkar@ti.com>,
Colin Cross <ccross@android.com>
Subject: [PATCH 3/3] ARM: vfp: Use cpu pm notifiers to save vfp state
Date: Sun, 12 Jun 2011 17:43:45 -0700 [thread overview]
Message-ID: <1307925825-28566-4-git-send-email-ccross@android.com> (raw)
In-Reply-To: <1307925825-28566-1-git-send-email-ccross@android.com>
When the cpu is powered down in a low power mode, the vfp
registers may be reset.
This patch uses CPU_PM_ENTER and CPU_PM_EXIT notifiers to save
and restore the cpu's vfp registers.
Signed-off-by: Colin Cross <ccross@android.com>
---
arch/arm/vfp/vfpmodule.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
index f25e7ec..6f08dbe 100644
--- a/arch/arm/vfp/vfpmodule.c
+++ b/arch/arm/vfp/vfpmodule.c
@@ -21,6 +21,7 @@
#include <asm/cputype.h>
#include <asm/thread_notify.h>
#include <asm/vfp.h>
+#include <asm/cpu_pm.h>
#include "vfpinstr.h"
#include "vfp.h"
@@ -169,6 +170,44 @@ static struct notifier_block vfp_notifier_block = {
.notifier_call = vfp_notifier,
};
+#ifdef CONFIG_CPU_PM
+static int vfp_cpu_pm_notifier(struct notifier_block *self, unsigned long cmd,
+ void *v)
+{
+ u32 fpexc = fmrx(FPEXC);
+ unsigned int cpu = smp_processor_id();
+
+ switch (cmd) {
+ case CPU_PM_ENTER:
+ if (last_VFP_context[cpu]) {
+ fmxr(FPEXC, fpexc | FPEXC_EN);
+ vfp_save_state(last_VFP_context[cpu], fpexc);
+ /* force a reload when coming back from idle */
+ last_VFP_context[cpu] = NULL;
+ fmxr(FPEXC, fpexc & ~FPEXC_EN);
+ }
+ break;
+ case CPU_PM_ENTER_FAILED:
+ case CPU_PM_EXIT:
+ /* make sure VFP is disabled when leaving idle */
+ fmxr(FPEXC, fpexc & ~FPEXC_EN);
+ break;
+ }
+ return NOTIFY_OK;
+}
+
+static struct notifier_block vfp_cpu_pm_notifier_block = {
+ .notifier_call = vfp_cpu_pm_notifier,
+};
+
+static void vfp_cpu_pm_init(void)
+{
+ cpu_pm_register_notifier(&vfp_cpu_pm_notifier_block);
+}
+#else
+static inline void vfp_cpu_pm_init(void) { }
+#endif
+
/*
* Raise a SIGFPE for the current process.
* sicode describes the signal being raised.
@@ -563,6 +602,7 @@ static int __init vfp_init(void)
vfp_vector = vfp_support_entry;
thread_register_notifier(&vfp_notifier_block);
+ vfp_cpu_pm_init();
vfp_pm_init();
/*
--
1.7.4.1
next prev parent reply other threads:[~2011-06-13 0:43 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-13 0:43 [PATCH 0/3] CPU PM notifiers Colin Cross
2011-06-13 0:43 ` Colin Cross
2011-06-13 0:43 ` [PATCH 1/3] ARM: Add cpu power management notifiers Colin Cross
2011-06-13 0:43 ` Colin Cross
2011-06-13 1:57 ` Rob Herring
2011-06-13 1:57 ` Rob Herring
2011-06-13 22:17 ` Kevin Hilman
2011-06-13 22:17 ` Kevin Hilman
2011-06-14 6:15 ` Colin Cross
2011-06-14 6:15 ` Colin Cross
2011-06-16 0:12 ` Kevin Hilman
2011-06-16 0:12 ` Kevin Hilman
2011-06-13 0:43 ` [PATCH 2/3] ARM: gic: Use cpu pm notifiers to save gic state Colin Cross
2011-06-13 0:43 ` Colin Cross
2011-06-13 10:41 ` Lorenzo Pieralisi
2011-06-13 10:41 ` Lorenzo Pieralisi
2011-06-13 0:43 ` Colin Cross [this message]
2011-06-13 0:43 ` [PATCH 3/3] ARM: vfp: Use cpu pm notifiers to save vfp state Colin Cross
2011-06-13 18:37 ` [PATCH 0/3] CPU PM notifiers Rafael J. Wysocki
2011-06-13 18:37 ` Rafael J. Wysocki
2011-06-13 18:55 ` Colin Cross
2011-06-13 18:55 ` Colin Cross
2011-06-13 18:55 ` Colin Cross
2011-06-14 21:00 ` Rafael J. Wysocki
2011-06-14 21:00 ` Rafael J. Wysocki
2011-06-14 21:00 ` Rafael J. Wysocki
2011-06-14 21:19 ` Colin Cross
2011-06-14 21:19 ` Colin Cross
2011-06-14 21:19 ` Colin Cross
2011-06-14 21:34 ` Rafael J. Wysocki
2011-06-14 21:34 ` Rafael J. Wysocki
2011-06-14 21:40 ` Colin Cross
2011-06-14 21:40 ` Colin Cross
2011-06-14 21:40 ` Colin Cross
2011-06-14 22:12 ` Rafael J. Wysocki
2011-06-14 22:12 ` Rafael J. Wysocki
2011-06-14 22:12 ` Rafael J. Wysocki
2011-06-15 6:54 ` Santosh Shilimkar
2011-06-15 6:54 ` Santosh Shilimkar
2011-06-15 6:54 ` Santosh Shilimkar
2011-06-15 23:13 ` Rafael J. Wysocki
2011-06-15 23:13 ` Rafael J. Wysocki
2011-06-15 23:13 ` Rafael J. Wysocki
2011-06-14 21:34 ` Rafael J. Wysocki
2011-06-13 18:37 ` 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=1307925825-28566-4-git-send-email-ccross@android.com \
--to=ccross@android.com \
--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 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.