From patchwork Mon Jun 13 00:43:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Cross X-Patchwork-Id: 873672 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5D0ia2k004249 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 13 Jun 2011 00:44:57 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QVvGL-0004L4-7D; Mon, 13 Jun 2011 00:44:17 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QVvGK-0000bM-Q9; Mon, 13 Jun 2011 00:44:16 +0000 Received: from smtp-out.google.com ([216.239.44.51]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QVvGH-0000ai-6D for linux-arm-kernel@lists.infradead.org; Mon, 13 Jun 2011 00:44:14 +0000 Received: from hpaq11.eem.corp.google.com (hpaq11.eem.corp.google.com [172.25.149.11]) by smtp-out.google.com with ESMTP id p5D0i2Hl021303; Sun, 12 Jun 2011 17:44:02 -0700 Received: from walnut.mtv.corp.google.com (walnut.mtv.corp.google.com [172.18.102.62]) by hpaq11.eem.corp.google.com with ESMTP id p5D0hsYM029042; Sun, 12 Jun 2011 17:43:54 -0700 Received: by walnut.mtv.corp.google.com (Postfix, from userid 99897) id 2B446257965; Sun, 12 Jun 2011 17:43:54 -0700 (PDT) From: 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 Message-Id: <1307925825-28566-4-git-send-email-ccross@android.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1307925825-28566-1-git-send-email-ccross@android.com> References: <1307925825-28566-1-git-send-email-ccross@android.com> X-System-Of-Record: true X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110612_204413_546911_D686F1F0 X-CRM114-Status: GOOD ( 15.26 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [216.239.44.51 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: Catalin Marinas , Santosh Shilimkar , Russell King , linux-kernel@vger.kernel.org, Colin Cross X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 13 Jun 2011 00:44:57 +0000 (UTC) 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 --- 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 #include #include +#include #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(); /*