diff mbox

[PATCHv2,1/2] ARM: VFP: Fixed suspend and added context save support

Message ID 1259847353-22725-2-git-send-email-tero.kristo@nokia.com (mailing list archive)
State Awaiting Upstream, archived
Headers show

Commit Message

Tero Kristo Dec. 3, 2009, 1:35 p.m. UTC
None
diff mbox

Patch

diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
index 2d7423a..920a33b 100644
--- a/arch/arm/vfp/vfpmodule.c
+++ b/arch/arm/vfp/vfpmodule.c
@@ -329,22 +329,34 @@  static void vfp_enable(void *unused)
 #ifdef CONFIG_PM
 #include <linux/sysdev.h>
 
-static int vfp_pm_suspend(struct sys_device *dev, pm_message_t state)
+void vfp_pm_save_context(void)
 {
-	struct thread_info *ti = current_thread_info();
 	u32 fpexc = fmrx(FPEXC);
+	unsigned int cpu = get_cpu();
+
+	/* Save last_VFP_context if needed */
+	if (last_VFP_context[cpu]) {
+		/* Enable vfp to save context */
+		if (!(fpexc & FPEXC_EN)) {
+			vfp_enable(NULL);
+			fmxr(FPEXC, fpexc | FPEXC_EN);
+		}
 
-	/* if vfp is on, then save state for resumption */
-	if (fpexc & FPEXC_EN) {
 		printk(KERN_DEBUG "%s: saving vfp state\n", __func__);
-		vfp_save_state(&ti->vfpstate, fpexc);
+		vfp_save_state(last_VFP_context[cpu], fpexc);
 
 		/* disable, just in case */
-		fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN);
+		fmxr(FPEXC, fpexc & ~FPEXC_EN);
+
+		last_VFP_context[cpu] = NULL;
 	}
 
-	/* clear any information we had about last context state */
-	memset(last_VFP_context, 0, sizeof(last_VFP_context));
+	put_cpu();
+}
+
+static int vfp_pm_suspend(struct sys_device *dev, pm_message_t state)
+{
+	vfp_pm_save_context();
 
 	return 0;
 }