Merge branch 'sh/driver-core'
[pandora-kernel.git] / arch / arm / vfp / vfpmodule.c
index a63c4be..315a540 100644 (file)
@@ -428,54 +428,60 @@ static void vfp_pm_init(void)
 static inline void vfp_pm_init(void) { }
 #endif /* CONFIG_PM */
 
-/*
- * Synchronise the hardware VFP state of a thread other than current with the
- * saved one. This function is used by the ptrace mechanism.
- */
-#ifdef CONFIG_SMP
-void vfp_sync_state(struct thread_info *thread)
+void vfp_sync_hwstate(struct thread_info *thread)
 {
+       unsigned int cpu = get_cpu();
+
        /*
-        * On SMP systems, the VFP state is automatically saved at every
-        * context switch. We mark the thread VFP state as belonging to a
-        * non-existent CPU so that the saved one will be reloaded when
-        * needed.
+        * If the thread we're interested in is the current owner of the
+        * hardware VFP state, then we need to save its state.
         */
-       thread->vfpstate.hard.cpu = NR_CPUS;
+       if (last_VFP_context[cpu] == &thread->vfpstate) {
+               u32 fpexc = fmrx(FPEXC);
+
+               /*
+                * Save the last VFP state on this CPU.
+                */
+               fmxr(FPEXC, fpexc | FPEXC_EN);
+               vfp_save_state(&thread->vfpstate, fpexc | FPEXC_EN);
+               fmxr(FPEXC, fpexc);
+       }
+
+       put_cpu();
 }
-#else
-void vfp_sync_state(struct thread_info *thread)
+
+void vfp_flush_hwstate(struct thread_info *thread)
 {
        unsigned int cpu = get_cpu();
-       u32 fpexc = fmrx(FPEXC);
 
        /*
-        * If VFP is enabled, the previous state was already saved and
-        * last_VFP_context updated.
+        * If the thread we're interested in is the current owner of the
+        * hardware VFP state, then we need to save its state.
         */
-       if (fpexc & FPEXC_EN)
-               goto out;
+       if (last_VFP_context[cpu] == &thread->vfpstate) {
+               u32 fpexc = fmrx(FPEXC);
 
-       if (!last_VFP_context[cpu])
-               goto out;
+               fmxr(FPEXC, fpexc & ~FPEXC_EN);
 
-       /*
-        * Save the last VFP state on this CPU.
-        */
-       fmxr(FPEXC, fpexc | FPEXC_EN);
-       vfp_save_state(last_VFP_context[cpu], fpexc);
-       fmxr(FPEXC, fpexc);
+               /*
+                * Set the context to NULL to force a reload the next time
+                * the thread uses the VFP.
+                */
+               last_VFP_context[cpu] = NULL;
+       }
 
+#ifdef CONFIG_SMP
        /*
-        * Set the context to NULL to force a reload the next time the thread
-        * uses the VFP.
+        * For SMP we still have to take care of the case where the thread
+        * migrates to another CPU and then back to the original CPU on which
+        * the last VFP user is still the same thread. Mark the thread VFP
+        * state as belonging to a non-existent CPU so that the saved one will
+        * be reloaded in the above case.
         */
-       last_VFP_context[cpu] = NULL;
-
-out:
+       thread->vfpstate.hard.cpu = NR_CPUS;
+#endif
        put_cpu();
 }
-#endif
 
 #include <linux/smp.h>
 
@@ -528,7 +534,7 @@ static int __init vfp_init(void)
                 */
                elf_hwcap |= HWCAP_VFP;
 #ifdef CONFIG_VFPv3
-               if (VFP_arch >= 3) {
+               if (VFP_arch >= 2) {
                        elf_hwcap |= HWCAP_VFPv3;
 
                        /*