linux-mips
[Top] [All Lists]

Re: [PATCH 1/3] do_fpe() cleanup

To: linux-mips@linux-mips.org
Subject: Re: [PATCH 1/3] do_fpe() cleanup
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Date: Thu, 08 Feb 2007 01:10:40 +0900 (JST)
Cc: ralf@linux-mips.org
In-reply-to: <20061125.000344.03977447.anemo@mba.ocn.ne.jp>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20061125.000344.03977447.anemo@mba.ocn.ne.jp>
Sender: linux-mips-bounce@linux-mips.org
On Sat, 25 Nov 2006 00:03:44 +0900 (JST), Atsushi Nemoto <anemo@mba.ocn.ne.jp> 
wrote:
> If we had already lost FPU before disabling preempt, we do not have to
> own it at all.  And we do not prevent preemption when managing saved
> FCR31 if we did not have FPU ownership.
> 
> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
> ---
>  traps.c |   22 ++++++++--------------
>  1 files changed, 8 insertions(+), 14 deletions(-)

Ping.  This patch is dependent from other fp_context patches and
should be safe and harmless.  Are there any problems?


diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 9fda1b8..b18aeb6 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -614,16 +614,6 @@ asmlinkage void do_fpe(struct pt_regs *r
        if (fcr31 & FPU_CSR_UNI_X) {
                int sig;
 
-               preempt_disable();
-
-#ifdef CONFIG_PREEMPT
-               if (!is_fpu_owner()) {
-                       /* We might lose fpu before disabling preempt... */
-                       own_fpu();
-                       BUG_ON(!used_math());
-                       restore_fp(current);
-               }
-#endif
                /*
                 * Unimplemented operation exception.  If we've got the full
                 * software emulator on-board, let's use it...
@@ -634,7 +624,11 @@ #endif
                 * register operands before invoking the emulator, which seems
                 * a bit extreme for what should be an infrequent event.
                 */
-               save_fp(current);
+               preempt_disable();
+
+               /* We might have lost fpu before disabling preempt... */
+               if (is_fpu_owner())
+                       save_fp(current);
                /* Ensure 'resume' not overwrite saved fp context again. */
                lose_fpu();
 
@@ -643,15 +637,15 @@ #endif
                /* Run the emulator */
                sig = fpu_emulator_cop1Handler (regs, &current->thread.fpu, 1);
 
-               preempt_disable();
-
-               own_fpu();      /* Using the FPU again.  */
                /*
                 * We can't allow the emulated instruction to leave any of
                 * the cause bit set in $fcr31.
                 */
                current->thread.fpu.fcr31 &= ~FPU_CSR_ALL_X;
 
+               preempt_disable();
+
+               own_fpu();      /* Using the FPU again.  */
                /* Restore the hardware register state */
                restore_fp(current);

<Prev in Thread] Current Thread [Next in Thread>
  • Re: [PATCH 1/3] do_fpe() cleanup, Atsushi Nemoto <=