aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel/signal.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/kernel/signal.c')
-rw-r--r--arch/mips/kernel/signal.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
index b7e4614d41b5..e0178e117f68 100644
--- a/arch/mips/kernel/signal.c
+++ b/arch/mips/kernel/signal.c
@@ -102,10 +102,13 @@ static int protected_save_fp_context(struct sigcontext __user *sc)
102 int err; 102 int err;
103 while (1) { 103 while (1) {
104 lock_fpu_owner(); 104 lock_fpu_owner();
105 err = own_fpu_inatomic(1); 105 if (is_fpu_owner()) {
106 if (!err) 106 err = save_fp_context(sc);
107 err = save_fp_context(sc); /* this might fail */ 107 unlock_fpu_owner();
108 unlock_fpu_owner(); 108 } else {
109 unlock_fpu_owner();
110 err = copy_fp_to_sigcontext(sc);
111 }
109 if (likely(!err)) 112 if (likely(!err))
110 break; 113 break;
111 /* touch the sigcontext and try again */ 114 /* touch the sigcontext and try again */
@@ -123,10 +126,13 @@ static int protected_restore_fp_context(struct sigcontext __user *sc)
123 int err, tmp __maybe_unused; 126 int err, tmp __maybe_unused;
124 while (1) { 127 while (1) {
125 lock_fpu_owner(); 128 lock_fpu_owner();
126 err = own_fpu_inatomic(0); 129 if (is_fpu_owner()) {
127 if (!err) 130 err = restore_fp_context(sc);
128 err = restore_fp_context(sc); /* this might fail */ 131 unlock_fpu_owner();
129 unlock_fpu_owner(); 132 } else {
133 unlock_fpu_owner();
134 err = copy_fp_from_sigcontext(sc);
135 }
130 if (likely(!err)) 136 if (likely(!err))
131 break; 137 break;
132 /* touch the sigcontext and try again */ 138 /* touch the sigcontext and try again */