arch/tile: adopt prepare_exit_to_usermode() model from x86
[cascardo/linux.git] / arch / tile / kernel / intvec_64.S
index 58964d2..a41c994 100644 (file)
@@ -878,20 +878,6 @@ STD_ENTRY(interrupt_return)
 .Lresume_userspace:
        FEEDBACK_REENTER(interrupt_return)
 
-       /*
-        * Use r33 to hold whether we have already loaded the callee-saves
-        * into ptregs.  We don't want to do it twice in this loop, since
-        * then we'd clobber whatever changes are made by ptrace, etc.
-        */
-       {
-        movei  r33, 0
-        move   r32, sp
-       }
-
-       /* Get base of stack in r32. */
-       EXTRACT_THREAD_INFO(r32)
-
-.Lretry_work_pending:
        /*
         * Disable interrupts so as to make sure we don't
         * miss an interrupt that sets any of the thread flags (like
@@ -902,33 +888,28 @@ STD_ENTRY(interrupt_return)
        IRQ_DISABLE(r20, r21)
        TRACE_IRQS_OFF  /* Note: clobbers registers r0-r29 */
 
-
-       /* Check to see if there is any work to do before returning to user. */
+       /*
+        * See if there are any work items (including single-shot items)
+        * to do.  If so, save the callee-save registers to pt_regs
+        * and then dispatch to C code.
+        */
+       move    r21, sp
+       EXTRACT_THREAD_INFO(r21)
        {
-        addi   r29, r32, THREAD_INFO_FLAGS_OFFSET
-        moveli r1, hw1_last(_TIF_ALLWORK_MASK)
+        addi   r22, r21, THREAD_INFO_FLAGS_OFFSET
+        moveli r20, hw1_last(_TIF_ALLWORK_MASK)
        }
        {
-        ld     r29, r29
-        shl16insli r1, r1, hw0(_TIF_ALLWORK_MASK)
+        ld     r22, r22
+        shl16insli r20, r20, hw0(_TIF_ALLWORK_MASK)
        }
-       and     r1, r29, r1
-       beqzt   r1, .Lrestore_all
-
-       /*
-        * Make sure we have all the registers saved for signal
-        * handling or notify-resume.  Call out to C code to figure out
-        * exactly what we need to do for each flag bit, then if
-        * necessary, reload the flags and recheck.
-        */
+       and     r1, r22, r20
        {
         PTREGS_PTR(r0, PTREGS_OFFSET_BASE)
-        bnez   r33, 1f
+        beqzt  r1, .Lrestore_all
        }
        push_extra_callee_saves r0
-       movei   r33, 1
-1:     jal     do_work_pending
-       bnez    r0, .Lretry_work_pending
+       jal     prepare_exit_to_usermode
 
        /*
         * In the NMI case we
@@ -1411,7 +1392,7 @@ STD_ENTRY(ret_from_kernel_thread)
        FEEDBACK_REENTER(ret_from_kernel_thread)
        {
         movei  r30, 0               /* not an NMI */
-        j      .Lresume_userspace   /* jump into middle of interrupt_return */
+        j      interrupt_return
        }
        STD_ENDPROC(ret_from_kernel_thread)