aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/mips/include/asm/fpu.h43
1 files changed, 27 insertions, 16 deletions
diff --git a/arch/mips/include/asm/fpu.h b/arch/mips/include/asm/fpu.h
index 994d21939676..5528f4e2af6a 100644
--- a/arch/mips/include/asm/fpu.h
+++ b/arch/mips/include/asm/fpu.h
@@ -74,8 +74,10 @@ static inline int __enable_fpu(enum fpu_mode mode)
74#endif 74#endif
75 /* fall through */ 75 /* fall through */
76 case FPU_32BIT: 76 case FPU_32BIT:
77 /* clear FRE */ 77 if (cpu_has_fre) {
78 write_c0_config5(read_c0_config5() & ~MIPS_CONF5_FRE); 78 /* clear FRE */
79 write_c0_config5(read_c0_config5() & ~MIPS_CONF5_FRE);
80 }
79fr_common: 81fr_common:
80 /* set CU1 & change FR appropriately */ 82 /* set CU1 & change FR appropriately */
81 fr = (int)mode & FPU_FR_MASK; 83 fr = (int)mode & FPU_FR_MASK;
@@ -182,25 +184,34 @@ static inline int init_fpu(void)
182 int ret = 0; 184 int ret = 0;
183 185
184 if (cpu_has_fpu) { 186 if (cpu_has_fpu) {
187 unsigned int config5;
188
185 ret = __own_fpu(); 189 ret = __own_fpu();
186 if (!ret) { 190 if (ret)
187 unsigned int config5 = read_c0_config5(); 191 return ret;
188
189 /*
190 * Ensure FRE is clear whilst running _init_fpu, since
191 * single precision FP instructions are used. If FRE
192 * was set then we'll just end up initialising all 32
193 * 64b registers.
194 */
195 write_c0_config5(config5 & ~MIPS_CONF5_FRE);
196 enable_fpu_hazard();
197 192
193 if (!cpu_has_fre) {
198 _init_fpu(); 194 _init_fpu();
199 195
200 /* Restore FRE */ 196 return 0;
201 write_c0_config5(config5);
202 enable_fpu_hazard();
203 } 197 }
198
199 config5 = read_c0_config5();
200
201 /*
202 * Ensure FRE is clear whilst running _init_fpu, since
203 * single precision FP instructions are used. If FRE
204 * was set then we'll just end up initialising all 32
205 * 64b registers.
206 */
207 write_c0_config5(config5 & ~MIPS_CONF5_FRE);
208 enable_fpu_hazard();
209
210 _init_fpu();
211
212 /* Restore FRE */
213 write_c0_config5(config5);
214 enable_fpu_hazard();
204 } else 215 } else
205 fpu_emulator_init_fpu(); 216 fpu_emulator_init_fpu();
206 217