]> git.karo-electronics.de Git - linux-beck.git/commitdiff
MIPS: preserve scalar FP CSR when switching vector context
authorPaul Burton <paul.burton@imgtec.com>
Fri, 11 Jul 2014 15:44:29 +0000 (16:44 +0100)
committerRalf Baechle <ralf@linux-mips.org>
Fri, 1 Aug 2014 22:06:43 +0000 (00:06 +0200)
Switching the vector context implicitly saves & restores the state of
the aliased scalar FP data registers, however the scalar FP control
& status register is distinct from the MSA control & status register.
In order to allow scalar FP to function correctly in programs using
MSA, the scalar CSR needs to be saved & restored along with the MSA
vector context.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/7301/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/kernel/r4k_switch.S
arch/mips/kernel/traps.c

index 81ca3f70fe29a701d37c5e0db0fc427520c44f51..1a1aef04312d370e9c9601365b3428a78ac53c17 100644 (file)
        /* Check whether we're saving scalar or vector context. */
        bgtz    a3, 1f
 
-       /* Save 128b MSA vector context. */
+       /* Save 128b MSA vector context + scalar FP control & status. */
+       cfc1    t1, fcr31
        msa_save_all    a0
+       sw      t1, THREAD_FCR31(a0)
        b       2f
 
 1:     /* Save 32b/64b scalar FP context. */
index 1a328b1e288b088d0e7117d4fc2907e57db78296..649c151fe1dbcb77cc6165da5a504ef828f5eac9 100644 (file)
@@ -1154,6 +1154,11 @@ static int enable_restore_fp_context(int msa)
 
        /* We need to restore the vector context. */
        restore_msa(current);
+
+       /* Restore the scalar FP control & status register */
+       if (!was_fpu_owner)
+               asm volatile("ctc1 %0, $31" : : "r"(current->thread.fpu.fcr31));
+
        return 0;
 }