entry.s only disables IRQs on hardware IRQ, move trace_hardirqs_off call
into do_interrupt. Check actual intlevel that will be restored on return
from exception handler to decide if trace_hardirqs_on should be called.
Annotate IRQ on/off points in the TIF_* handling loop on return from
exception handler.

Signed-off-by: Max Filippov <[email protected]>
---
 arch/xtensa/kernel/entry.S | 39 ++++++++++++++-------------------------
 arch/xtensa/kernel/traps.c |  5 ++++-
 2 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/arch/xtensa/kernel/entry.S b/arch/xtensa/kernel/entry.S
index b64075f..d060fc2 100644
--- a/arch/xtensa/kernel/entry.S
+++ b/arch/xtensa/kernel/entry.S
@@ -415,21 +415,6 @@ common_exception:
 
        save_xtregs_opt a1 a3 a4 a5 a6 a7 PT_XTREGS_OPT
        
-#ifdef CONFIG_TRACE_IRQFLAGS
-       l32i    a4, a1, PT_DEPC
-       /* Double exception means we came here with an exception
-        * while PS.EXCM was set, i.e. interrupts disabled.
-        */
-       bgeui   a4, VALID_DOUBLE_EXCEPTION_ADDRESS, 1f
-       bnei    a2, EXCCAUSE_LEVEL1_INTERRUPT, 1f
-       /* We came here with an interrupt means interrupts were enabled
-        * and we've just disabled them.
-        */
-       movi    a4, trace_hardirqs_off
-       callx4  a4
-1:
-#endif
-
        /* Go to second-level dispatcher. Set up parameters to pass to the
         * exception handler and call the exception handler.
         */
@@ -450,6 +435,10 @@ common_exception_return:
 
 1:
        rsil    a2, LOCKLEVEL
+#ifdef CONFIG_TRACE_IRQFLAGS
+       movi    a4, trace_hardirqs_off
+       callx4  a4
+#endif
 
        /* Jump if we are returning from kernel exceptions. */
 
@@ -474,6 +463,10 @@ common_exception_return:
 
        /* Call do_signal() */
 
+#ifdef CONFIG_TRACE_IRQFLAGS
+       movi    a4, trace_hardirqs_on
+       callx4  a4
+#endif
        rsil    a2, 0
        movi    a4, do_notify_resume    # int do_notify_resume(struct pt_regs*)
        mov     a6, a1
@@ -482,6 +475,10 @@ common_exception_return:
 
 3:     /* Reschedule */
 
+#ifdef CONFIG_TRACE_IRQFLAGS
+       movi    a4, trace_hardirqs_on
+       callx4  a4
+#endif
        rsil    a2, 0
        movi    a4, schedule    # void schedule (void)
        callx4  a4
@@ -510,16 +507,8 @@ common_exception_return:
 6:
 4:
 #ifdef CONFIG_TRACE_IRQFLAGS
-       l32i    a4, a1, PT_DEPC
-       /* Double exception means we came here with an exception
-        * while PS.EXCM was set, i.e. interrupts disabled.
-        */
-       bgeui   a4, VALID_DOUBLE_EXCEPTION_ADDRESS, 1f
-       l32i    a4, a1, PT_EXCCAUSE
-       bnei    a4, EXCCAUSE_LEVEL1_INTERRUPT, 1f
-       /* We came here with an interrupt means interrupts were enabled
-        * and we'll reenable them on return.
-        */
+       extui   a4, a3, PS_INTLEVEL_SHIFT, PS_INTLEVEL_WIDTH
+       bgei    a4, LOCKLEVEL, 1f
        movi    a4, trace_hardirqs_on
        callx4  a4
 1:
diff --git a/arch/xtensa/kernel/traps.c b/arch/xtensa/kernel/traps.c
index 9d2f45f..a1b5bd2 100644
--- a/arch/xtensa/kernel/traps.c
+++ b/arch/xtensa/kernel/traps.c
@@ -211,8 +211,11 @@ void do_interrupt(struct pt_regs *regs)
                XCHAL_INTLEVEL6_MASK,
                XCHAL_INTLEVEL7_MASK,
        };
-       struct pt_regs *old_regs = set_irq_regs(regs);
+       struct pt_regs *old_regs;
 
+       trace_hardirqs_off();
+
+       old_regs = set_irq_regs(regs);
        irq_enter();
 
        for (;;) {
-- 
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to