aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/mips/kernel/branch.c10
-rw-r--r--include/asm-mips/fpu.h9
2 files changed, 14 insertions, 5 deletions
diff --git a/arch/mips/kernel/branch.c b/arch/mips/kernel/branch.c
index 01117e977a7f..56aea5f526a7 100644
--- a/arch/mips/kernel/branch.c
+++ b/arch/mips/kernel/branch.c
@@ -12,6 +12,7 @@
12#include <asm/branch.h> 12#include <asm/branch.h>
13#include <asm/cpu.h> 13#include <asm/cpu.h>
14#include <asm/cpu-features.h> 14#include <asm/cpu-features.h>
15#include <asm/fpu.h>
15#include <asm/inst.h> 16#include <asm/inst.h>
16#include <asm/ptrace.h> 17#include <asm/ptrace.h>
17#include <asm/uaccess.h> 18#include <asm/uaccess.h>
@@ -161,10 +162,13 @@ int __compute_return_epc(struct pt_regs *regs)
161 * And now the FPA/cp1 branch instructions. 162 * And now the FPA/cp1 branch instructions.
162 */ 163 */
163 case cop1_op: 164 case cop1_op:
164 if (!cpu_has_fpu) 165 preempt_disable();
165 fcr31 = current->thread.fpu.soft.fcr31; 166 if (is_fpu_owner())
166 else
167 asm volatile("cfc1\t%0,$31" : "=r" (fcr31)); 167 asm volatile("cfc1\t%0,$31" : "=r" (fcr31));
168 else
169 fcr31 = current->thread.fpu.hard.fcr31;
170 preempt_enable();
171
168 bit = (insn.i_format.rt >> 2); 172 bit = (insn.i_format.rt >> 2);
169 bit += (bit != 0); 173 bit += (bit != 0);
170 bit += 23; 174 bit += 23;
diff --git a/include/asm-mips/fpu.h b/include/asm-mips/fpu.h
index ea24e733b1bc..9c828b1f8218 100644
--- a/include/asm-mips/fpu.h
+++ b/include/asm-mips/fpu.h
@@ -80,9 +80,14 @@ do { \
80 80
81#define clear_fpu_owner() clear_thread_flag(TIF_USEDFPU) 81#define clear_fpu_owner() clear_thread_flag(TIF_USEDFPU)
82 82
83static inline int __is_fpu_owner(void)
84{
85 return test_thread_flag(TIF_USEDFPU);
86}
87
83static inline int is_fpu_owner(void) 88static inline int is_fpu_owner(void)
84{ 89{
85 return cpu_has_fpu && test_thread_flag(TIF_USEDFPU); 90 return cpu_has_fpu && __is_fpu_owner();
86} 91}
87 92
88static inline void own_fpu(void) 93static inline void own_fpu(void)
@@ -127,7 +132,7 @@ static inline void restore_fp(struct task_struct *tsk)
127static inline fpureg_t *get_fpu_regs(struct task_struct *tsk) 132static inline fpureg_t *get_fpu_regs(struct task_struct *tsk)
128{ 133{
129 if (cpu_has_fpu) { 134 if (cpu_has_fpu) {
130 if ((tsk == current) && is_fpu_owner()) 135 if ((tsk == current) && __is_fpu_owner())
131 _save_fp(current); 136 _save_fp(current);
132 return tsk->thread.fpu.hard.fpr; 137 return tsk->thread.fpu.hard.fpr;
133 } 138 }