MIPS: Simplify FP context initialization
MIPS has up until now had 3 different ways for a task's floating point context to be initialized: - If the task's first use of FP involves it gaining ownership of an FPU then _init_fpu() is used to initialize the FPU's registers such that they all contain ~0, and the FPU registers will be stored to struct thread_info later (eg. when context switching). - If the task first uses FP on a CPU without an associated FPU then fpu_emulator_init_fpu() initializes the task's floating point register state in struct thread_info such that all floating point register contain the bit pattern 0x7ff800007ff80000, different to the _init_fpu() behaviour. - If a task's floating point context is first accessed via ptrace then init_fp_ctx() initializes the floating point register state in struct thread_info to ~0, giving equivalent state to _init_fpu(). The _init_fpu() path has 2 separate implementations - one for r2k/r3k style systems & one for r4k style systems. The _init_fpu() path also requires that we be careful to clear & restore the value of the Config5.FRE bit on modern systems in order to avoid inadvertently triggering floating point exceptions. None of this code is in a performance critical hot path - it runs only the first time a task uses floating point. As such it doesn't seem to warrant the complications of maintaining the _init_fpu() path. Remove _init_fpu() & fpu_emulator_init_fpu(), instead using init_fp_ctx() consistently to initialize floating point register state in struct thread_info. Upon a task's first use of floating point this will typically mean that we initialize state in memory & then load it into FPU registers using _restore_fp() just as we would on a context switch. For other paths such as __compute_return_epc_for_insn() or mipsr2_decoder() this results in a significant simplification of the work to be done. Signed-off-by: Paul Burton <paul.burton@mips.com> Patchwork: https://patchwork.linux-mips.org/patch/21002/ Cc: linux-mips@linux-mips.org
This commit is contained in:
@@ -86,150 +86,6 @@ LEAF(_init_msa_upper)
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Load the FPU with signalling NANS. This bit pattern we're using has
|
||||
* the property that no matter whether considered as single or as double
|
||||
* precision represents signaling NANS.
|
||||
*
|
||||
* The value to initialize fcr31 to comes in $a0.
|
||||
*/
|
||||
|
||||
.set push
|
||||
SET_HARDFLOAT
|
||||
|
||||
LEAF(_init_fpu)
|
||||
mfc0 t0, CP0_STATUS
|
||||
li t1, ST0_CU1
|
||||
or t0, t1
|
||||
mtc0 t0, CP0_STATUS
|
||||
enable_fpu_hazard
|
||||
|
||||
ctc1 a0, fcr31
|
||||
|
||||
li t1, -1 # SNaN
|
||||
|
||||
#ifdef CONFIG_64BIT
|
||||
sll t0, t0, 5
|
||||
bgez t0, 1f # 16 / 32 register mode?
|
||||
|
||||
dmtc1 t1, $f1
|
||||
dmtc1 t1, $f3
|
||||
dmtc1 t1, $f5
|
||||
dmtc1 t1, $f7
|
||||
dmtc1 t1, $f9
|
||||
dmtc1 t1, $f11
|
||||
dmtc1 t1, $f13
|
||||
dmtc1 t1, $f15
|
||||
dmtc1 t1, $f17
|
||||
dmtc1 t1, $f19
|
||||
dmtc1 t1, $f21
|
||||
dmtc1 t1, $f23
|
||||
dmtc1 t1, $f25
|
||||
dmtc1 t1, $f27
|
||||
dmtc1 t1, $f29
|
||||
dmtc1 t1, $f31
|
||||
1:
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CPU_MIPS32
|
||||
mtc1 t1, $f0
|
||||
mtc1 t1, $f1
|
||||
mtc1 t1, $f2
|
||||
mtc1 t1, $f3
|
||||
mtc1 t1, $f4
|
||||
mtc1 t1, $f5
|
||||
mtc1 t1, $f6
|
||||
mtc1 t1, $f7
|
||||
mtc1 t1, $f8
|
||||
mtc1 t1, $f9
|
||||
mtc1 t1, $f10
|
||||
mtc1 t1, $f11
|
||||
mtc1 t1, $f12
|
||||
mtc1 t1, $f13
|
||||
mtc1 t1, $f14
|
||||
mtc1 t1, $f15
|
||||
mtc1 t1, $f16
|
||||
mtc1 t1, $f17
|
||||
mtc1 t1, $f18
|
||||
mtc1 t1, $f19
|
||||
mtc1 t1, $f20
|
||||
mtc1 t1, $f21
|
||||
mtc1 t1, $f22
|
||||
mtc1 t1, $f23
|
||||
mtc1 t1, $f24
|
||||
mtc1 t1, $f25
|
||||
mtc1 t1, $f26
|
||||
mtc1 t1, $f27
|
||||
mtc1 t1, $f28
|
||||
mtc1 t1, $f29
|
||||
mtc1 t1, $f30
|
||||
mtc1 t1, $f31
|
||||
|
||||
#if defined(CONFIG_CPU_MIPS32_R2) || defined(CONFIG_CPU_MIPS32_R6)
|
||||
.set push
|
||||
.set MIPS_ISA_LEVEL_RAW
|
||||
.set fp=64
|
||||
sll t0, t0, 5 # is Status.FR set?
|
||||
bgez t0, 1f # no: skip setting upper 32b
|
||||
|
||||
mthc1 t1, $f0
|
||||
mthc1 t1, $f1
|
||||
mthc1 t1, $f2
|
||||
mthc1 t1, $f3
|
||||
mthc1 t1, $f4
|
||||
mthc1 t1, $f5
|
||||
mthc1 t1, $f6
|
||||
mthc1 t1, $f7
|
||||
mthc1 t1, $f8
|
||||
mthc1 t1, $f9
|
||||
mthc1 t1, $f10
|
||||
mthc1 t1, $f11
|
||||
mthc1 t1, $f12
|
||||
mthc1 t1, $f13
|
||||
mthc1 t1, $f14
|
||||
mthc1 t1, $f15
|
||||
mthc1 t1, $f16
|
||||
mthc1 t1, $f17
|
||||
mthc1 t1, $f18
|
||||
mthc1 t1, $f19
|
||||
mthc1 t1, $f20
|
||||
mthc1 t1, $f21
|
||||
mthc1 t1, $f22
|
||||
mthc1 t1, $f23
|
||||
mthc1 t1, $f24
|
||||
mthc1 t1, $f25
|
||||
mthc1 t1, $f26
|
||||
mthc1 t1, $f27
|
||||
mthc1 t1, $f28
|
||||
mthc1 t1, $f29
|
||||
mthc1 t1, $f30
|
||||
mthc1 t1, $f31
|
||||
1: .set pop
|
||||
#endif /* CONFIG_CPU_MIPS32_R2 || CONFIG_CPU_MIPS32_R6 */
|
||||
#else
|
||||
.set MIPS_ISA_ARCH_LEVEL_RAW
|
||||
dmtc1 t1, $f0
|
||||
dmtc1 t1, $f2
|
||||
dmtc1 t1, $f4
|
||||
dmtc1 t1, $f6
|
||||
dmtc1 t1, $f8
|
||||
dmtc1 t1, $f10
|
||||
dmtc1 t1, $f12
|
||||
dmtc1 t1, $f14
|
||||
dmtc1 t1, $f16
|
||||
dmtc1 t1, $f18
|
||||
dmtc1 t1, $f20
|
||||
dmtc1 t1, $f22
|
||||
dmtc1 t1, $f24
|
||||
dmtc1 t1, $f26
|
||||
dmtc1 t1, $f28
|
||||
dmtc1 t1, $f30
|
||||
#endif
|
||||
jr ra
|
||||
END(_init_fpu)
|
||||
|
||||
.set pop /* SET_HARDFLOAT */
|
||||
|
||||
.set noreorder
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user