[PATCH v6] ARM: vfp: Always save VFP state in vfp_pm_suspend on UP

Colin Cross ccross at android.com
Mon Jul 16 14:17:20 EDT 2012


vfp_pm_suspend should save the VFP state in suspend after
any lazy context switch.  If it only saves when the VFP is enabled,
the state can get lost when, on a UP system:
  Thread 1 uses the VFP
  Context switch occurs to thread 2, VFP is disabled but the
     VFP context is not saved
  Thread 2 initiates suspend
  vfp_pm_suspend is called with the VFP disabled, and the unsaved
     VFP context of Thread 1 in the registers

Modify vfp_pm_suspend to save the VFP context whenever
vfp_current_hw_state is not NULL.

Includes a fix from Ido Yariv <ido at wizery.com>, who pointed out that on
SMP systems, the state pointer can be pointing to a freed task struct if
a task exited on another cpu, fixed by using #ifdef CONFIG_SMP in the
new if clause.

Cc: Russell King <linux at arm.linux.org.uk>
Cc: Barry Song <bs14 at csr.com>
Cc: Catalin Marinas <catalin.marinas at arm.com>
Cc: Ido Yariv <ido at wizery.com>
Cc: Daniel Drake <dsd at laptop.org>
Cc: Will Deacon <will.deacon at arm.com>
Signed-off-by: Colin Cross <ccross at android.com>
---
 arch/arm/vfp/vfpmodule.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
index 58696192..ce55f05 100644
--- a/arch/arm/vfp/vfpmodule.c
+++ b/arch/arm/vfp/vfpmodule.c
@@ -457,6 +457,12 @@ static int vfp_pm_suspend(void)
 
 		/* disable, just in case */
 		fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN);
+	} else if (vfp_current_hw_state[ti->cpu]) {
+#ifndef CONFIG_SMP
+		fmxr(FPEXC, fpexc | FPEXC_EN);
+		vfp_save_state(vfp_current_hw_state[ti->cpu], fpexc);
+		fmxr(FPEXC, fpexc);
+#endif
 	}
 
 	/* clear any information we had about last context state */
-- 
1.7.7.3




More information about the linux-arm-kernel mailing list