Commit bfcdf130 authored by Huacai Chen's avatar Huacai Chen Committed by Ralf Baechle

MIPS: Loongson: Fix COP2 usage for preemptible kernel

In preemptible kernel, only TIF_USEDFPU flag is reliable to distinguish
whether _init_fpu()/_restore_fp() is needed. Because the value of the
CP0_Status.CU1 isn't changed during preemption.

V2: Fix coding style.
Signed-off-by: default avatarHuacai Chen <chenhc@lemote.com>
Cc: John Crispin <john@phrozen.org>
Cc: Steven J. Hill <Steven.Hill@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: linux-mips@linux-mips.org
Cc: Fuxin Zhang <zhangfx@lemote.com>
Cc: Zhangjin Wu <wuzhangjin@gmail.com>
Patchwork: https://patchwork.linux-mips.org/patch/7515/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent bbbf6d87
...@@ -22,13 +22,13 @@ ...@@ -22,13 +22,13 @@
static int loongson_cu2_call(struct notifier_block *nfb, unsigned long action, static int loongson_cu2_call(struct notifier_block *nfb, unsigned long action,
void *data) void *data)
{ {
int fpu_enabled; int fpu_owned;
int fr = !test_thread_flag(TIF_32BIT_FPREGS); int fr = !test_thread_flag(TIF_32BIT_FPREGS);
switch (action) { switch (action) {
case CU2_EXCEPTION: case CU2_EXCEPTION:
preempt_disable(); preempt_disable();
fpu_enabled = read_c0_status() & ST0_CU1; fpu_owned = __is_fpu_owner();
if (!fr) if (!fr)
set_c0_status(ST0_CU1 | ST0_CU2); set_c0_status(ST0_CU1 | ST0_CU2);
else else
...@@ -39,8 +39,8 @@ static int loongson_cu2_call(struct notifier_block *nfb, unsigned long action, ...@@ -39,8 +39,8 @@ static int loongson_cu2_call(struct notifier_block *nfb, unsigned long action,
KSTK_STATUS(current) |= ST0_FR; KSTK_STATUS(current) |= ST0_FR;
else else
KSTK_STATUS(current) &= ~ST0_FR; KSTK_STATUS(current) &= ~ST0_FR;
/* If FPU is enabled, we needn't init or restore fp */ /* If FPU is owned, we needn't init or restore fp */
if(!fpu_enabled) { if (!fpu_owned) {
set_thread_flag(TIF_USEDFPU); set_thread_flag(TIF_USEDFPU);
if (!used_math()) { if (!used_math()) {
_init_fpu(); _init_fpu();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment