Skip to contentSkip to conversation

MIPS: Loongson: Fix COP2 usage for preemptible kernel

PATCH New Huacai Chen 1 participant 1 message Aug 11, 2014 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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.

---
 arch/mips/loongson/loongson-3/cop2-ex.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
arch/mips/loongson/loongson-3/cop2-ex.c +4 -4
index 9182e8d..c1e9503 100644
@@ -22,13 +22,13 @@
 static int loongson_cu2_call(struct notifier_block *nfb, unsigned long action,
 	void *data)
 {
-	int fpu_enabled;
+	int fpu_owned;
 	int fr = !test_thread_flag(TIF_32BIT_FPREGS);
 
 	switch (action) {
 	case CU2_EXCEPTION:
 		preempt_disable();
-		fpu_enabled = read_c0_status() & ST0_CU1;
+		fpu_owned = __is_fpu_owner();
 		if (!fr)
 			set_c0_status(ST0_CU1 | ST0_CU2);
 		else
@@ -39,8 +39,8 @@ static int loongson_cu2_call(struct notifier_block *nfb, unsigned long action,
 			KSTK_STATUS(current) |= ST0_FR;
 		else
 			KSTK_STATUS(current) &= ~ST0_FR;
-		/* If FPU is enabled, we needn't init or restore fp */
-		if(!fpu_enabled) {
+		/* If FPU is owned, we needn't init or restore fp */
+		if (!fpu_owned) {
 			set_thread_flag(TIF_USEDFPU);
 			if (!used_math()) {
 				_init_fpu();
Signature · 1 line
1.7.7.3