Ingo Molnar | de30a2b | 2006-07-03 00:24:42 -0700 | [diff] [blame] | 1 | /* |
Ingo Molnar | de30a2b | 2006-07-03 00:24:42 -0700 | [diff] [blame] | 2 | * IRQ flags handling |
Ingo Molnar | de30a2b | 2006-07-03 00:24:42 -0700 | [diff] [blame] | 3 | */ |
| 4 | #ifndef _ASM_IRQFLAGS_H |
| 5 | #define _ASM_IRQFLAGS_H |
| 6 | |
Benjamin Herrenschmidt | 945feb1 | 2008-04-17 14:35:01 +1000 | [diff] [blame] | 7 | #ifndef __ASSEMBLY__ |
Ingo Molnar | de30a2b | 2006-07-03 00:24:42 -0700 | [diff] [blame] | 8 | /* |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 9 | * Get definitions for arch_local_save_flags(x), etc. |
Ingo Molnar | de30a2b | 2006-07-03 00:24:42 -0700 | [diff] [blame] | 10 | */ |
Stephen Rothwell | b8b572e | 2008-08-01 15:20:30 +1000 | [diff] [blame] | 11 | #include <asm/hw_irq.h> |
Ingo Molnar | de30a2b | 2006-07-03 00:24:42 -0700 | [diff] [blame] | 12 | |
Ingo Molnar | de30a2b | 2006-07-03 00:24:42 -0700 | [diff] [blame] | 13 | #else |
Benjamin Herrenschmidt | 945feb1 | 2008-04-17 14:35:01 +1000 | [diff] [blame] | 14 | #ifdef CONFIG_TRACE_IRQFLAGS |
Steven Rostedt | 3cb5f1a | 2010-12-23 19:46:06 +0000 | [diff] [blame] | 15 | #ifdef CONFIG_IRQSOFF_TRACER |
| 16 | /* |
| 17 | * Since the ftrace irqsoff latency trace checks CALLER_ADDR1, |
| 18 | * which is the stack frame here, we need to force a stack frame |
| 19 | * in case we came from user space. |
| 20 | */ |
| 21 | #define TRACE_WITH_FRAME_BUFFER(func) \ |
| 22 | mflr r0; \ |
Anton Blanchard | d51959d | 2014-03-10 12:51:58 +1100 | [diff] [blame] | 23 | stdu r1, -STACK_FRAME_OVERHEAD(r1); \ |
Steven Rostedt | 3cb5f1a | 2010-12-23 19:46:06 +0000 | [diff] [blame] | 24 | std r0, 16(r1); \ |
Anton Blanchard | d51959d | 2014-03-10 12:51:58 +1100 | [diff] [blame] | 25 | stdu r1, -STACK_FRAME_OVERHEAD(r1); \ |
Steven Rostedt | 3cb5f1a | 2010-12-23 19:46:06 +0000 | [diff] [blame] | 26 | bl func; \ |
| 27 | ld r1, 0(r1); \ |
| 28 | ld r1, 0(r1); |
| 29 | #else |
| 30 | #define TRACE_WITH_FRAME_BUFFER(func) \ |
| 31 | bl func; |
| 32 | #endif |
| 33 | |
Benjamin Herrenschmidt | 945feb1 | 2008-04-17 14:35:01 +1000 | [diff] [blame] | 34 | /* |
Michael Ellerman | 144beb2 | 2014-07-15 21:15:36 +1000 | [diff] [blame] | 35 | * These are calls to C code, so the caller must be prepared for volatiles to |
| 36 | * be clobbered. |
Benjamin Herrenschmidt | 945feb1 | 2008-04-17 14:35:01 +1000 | [diff] [blame] | 37 | */ |
Anton Blanchard | b1576fe | 2014-02-04 16:04:35 +1100 | [diff] [blame] | 38 | #define TRACE_ENABLE_INTS TRACE_WITH_FRAME_BUFFER(trace_hardirqs_on) |
| 39 | #define TRACE_DISABLE_INTS TRACE_WITH_FRAME_BUFFER(trace_hardirqs_off) |
Steven Rostedt | 3cb5f1a | 2010-12-23 19:46:06 +0000 | [diff] [blame] | 40 | |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 41 | /* |
Tiejun Chen | de021bb | 2013-07-16 11:09:30 +0800 | [diff] [blame] | 42 | * This is used by assembly code to soft-disable interrupts first and |
| 43 | * reconcile irq state. |
Michael Ellerman | 144beb2 | 2014-07-15 21:15:36 +1000 | [diff] [blame] | 44 | * |
| 45 | * NB: This may call C code, so the caller must be prepared for volatiles to |
| 46 | * be clobbered. |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 47 | */ |
Tiejun Chen | de021bb | 2013-07-16 11:09:30 +0800 | [diff] [blame] | 48 | #define RECONCILE_IRQ_STATE(__rA, __rB) \ |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 49 | lbz __rA,PACASOFTIRQEN(r13); \ |
| 50 | lbz __rB,PACAIRQHAPPENED(r13); \ |
| 51 | cmpwi cr0,__rA,0; \ |
| 52 | li __rA,0; \ |
| 53 | ori __rB,__rB,PACA_IRQ_HARD_DIS; \ |
| 54 | stb __rB,PACAIRQHAPPENED(r13); \ |
| 55 | beq 44f; \ |
| 56 | stb __rA,PACASOFTIRQEN(r13); \ |
| 57 | TRACE_DISABLE_INTS; \ |
| 58 | 44: |
| 59 | |
Benjamin Herrenschmidt | 945feb1 | 2008-04-17 14:35:01 +1000 | [diff] [blame] | 60 | #else |
| 61 | #define TRACE_ENABLE_INTS |
| 62 | #define TRACE_DISABLE_INTS |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 63 | |
Tiejun Chen | de021bb | 2013-07-16 11:09:30 +0800 | [diff] [blame] | 64 | #define RECONCILE_IRQ_STATE(__rA, __rB) \ |
Benjamin Herrenschmidt | 7230c56 | 2012-03-06 18:27:59 +1100 | [diff] [blame] | 65 | lbz __rA,PACAIRQHAPPENED(r13); \ |
| 66 | li __rB,0; \ |
| 67 | ori __rA,__rA,PACA_IRQ_HARD_DIS; \ |
| 68 | stb __rB,PACASOFTIRQEN(r13); \ |
| 69 | stb __rA,PACAIRQHAPPENED(r13) |
Benjamin Herrenschmidt | 945feb1 | 2008-04-17 14:35:01 +1000 | [diff] [blame] | 70 | #endif |
Ingo Molnar | de30a2b | 2006-07-03 00:24:42 -0700 | [diff] [blame] | 71 | #endif |
| 72 | |
| 73 | #endif |