diff options
author | Huacai Chen <chenhc@lemote.com> | 2014-08-11 05:10:38 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2014-08-19 12:04:24 -0400 |
commit | bfcdf1306361951b104c6858d07f6778b53e4368 (patch) | |
tree | 9752e9f37fe001dd624b082a651e8a0bf0c2e25d /arch/mips | |
parent | bbbf6d8768f5cac3523c408917083a111b1f3ffe (diff) |
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: Huacai 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: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips')
-rw-r--r-- | arch/mips/loongson/loongson-3/cop2-ex.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/arch/mips/loongson/loongson-3/cop2-ex.c b/arch/mips/loongson/loongson-3/cop2-ex.c index 9182e8d2967c..b03e37d2071a 100644 --- a/arch/mips/loongson/loongson-3/cop2-ex.c +++ b/arch/mips/loongson/loongson-3/cop2-ex.c | |||
@@ -22,13 +22,13 @@ | |||
22 | static int loongson_cu2_call(struct notifier_block *nfb, unsigned long action, | 22 | static int loongson_cu2_call(struct notifier_block *nfb, unsigned long action, |
23 | void *data) | 23 | void *data) |
24 | { | 24 | { |
25 | int fpu_enabled; | 25 | int fpu_owned; |
26 | int fr = !test_thread_flag(TIF_32BIT_FPREGS); | 26 | int fr = !test_thread_flag(TIF_32BIT_FPREGS); |
27 | 27 | ||
28 | switch (action) { | 28 | switch (action) { |
29 | case CU2_EXCEPTION: | 29 | case CU2_EXCEPTION: |
30 | preempt_disable(); | 30 | preempt_disable(); |
31 | fpu_enabled = read_c0_status() & ST0_CU1; | 31 | fpu_owned = __is_fpu_owner(); |
32 | if (!fr) | 32 | if (!fr) |
33 | set_c0_status(ST0_CU1 | ST0_CU2); | 33 | set_c0_status(ST0_CU1 | ST0_CU2); |
34 | else | 34 | else |
@@ -39,8 +39,8 @@ static int loongson_cu2_call(struct notifier_block *nfb, unsigned long action, | |||
39 | KSTK_STATUS(current) |= ST0_FR; | 39 | KSTK_STATUS(current) |= ST0_FR; |
40 | else | 40 | else |
41 | KSTK_STATUS(current) &= ~ST0_FR; | 41 | KSTK_STATUS(current) &= ~ST0_FR; |
42 | /* If FPU is enabled, we needn't init or restore fp */ | 42 | /* If FPU is owned, we needn't init or restore fp */ |
43 | if(!fpu_enabled) { | 43 | if (!fpu_owned) { |
44 | set_thread_flag(TIF_USEDFPU); | 44 | set_thread_flag(TIF_USEDFPU); |
45 | if (!used_math()) { | 45 | if (!used_math()) { |
46 | _init_fpu(); | 46 | _init_fpu(); |