Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
de30a2b3 | 2 | /* |
de30a2b3 | 3 | * IRQ flags handling |
de30a2b3 IM |
4 | */ |
5 | #ifndef _ASM_IRQFLAGS_H | |
6 | #define _ASM_IRQFLAGS_H | |
7 | ||
945feb17 | 8 | #ifndef __ASSEMBLY__ |
de30a2b3 | 9 | /* |
df9ee292 | 10 | * Get definitions for arch_local_save_flags(x), etc. |
de30a2b3 | 11 | */ |
b8b572e1 | 12 | #include <asm/hw_irq.h> |
de30a2b3 | 13 | |
945feb17 BH |
14 | #else |
15 | #ifdef CONFIG_TRACE_IRQFLAGS | |
3cb5f1a3 SR |
16 | #ifdef CONFIG_IRQSOFF_TRACER |
17 | /* | |
18 | * Since the ftrace irqsoff latency trace checks CALLER_ADDR1, | |
19 | * which is the stack frame here, we need to force a stack frame | |
20 | * in case we came from user space. | |
21 | */ | |
22 | #define TRACE_WITH_FRAME_BUFFER(func) \ | |
23 | mflr r0; \ | |
d51959d7 | 24 | stdu r1, -STACK_FRAME_OVERHEAD(r1); \ |
3cb5f1a3 | 25 | std r0, 16(r1); \ |
d51959d7 | 26 | stdu r1, -STACK_FRAME_OVERHEAD(r1); \ |
3cb5f1a3 SR |
27 | bl func; \ |
28 | ld r1, 0(r1); \ | |
29 | ld r1, 0(r1); | |
30 | #else | |
31 | #define TRACE_WITH_FRAME_BUFFER(func) \ | |
32 | bl func; | |
33 | #endif | |
34 | ||
de30a2b3 | 35 | /* |
144beb2f ME |
36 | * These are calls to C code, so the caller must be prepared for volatiles to |
37 | * be clobbered. | |
de30a2b3 | 38 | */ |
b1576fec AB |
39 | #define TRACE_ENABLE_INTS TRACE_WITH_FRAME_BUFFER(trace_hardirqs_on) |
40 | #define TRACE_DISABLE_INTS TRACE_WITH_FRAME_BUFFER(trace_hardirqs_off) | |
3cb5f1a3 | 41 | |
7230c564 | 42 | /* |
de021bb7 TC |
43 | * This is used by assembly code to soft-disable interrupts first and |
44 | * reconcile irq state. | |
144beb2f ME |
45 | * |
46 | * NB: This may call C code, so the caller must be prepared for volatiles to | |
47 | * be clobbered. | |
7230c564 | 48 | */ |
de021bb7 | 49 | #define RECONCILE_IRQ_STATE(__rA, __rB) \ |
4e26bc4a | 50 | lbz __rA,PACAIRQSOFTMASK(r13); \ |
7230c564 | 51 | lbz __rB,PACAIRQHAPPENED(r13); \ |
4e26bc4a MS |
52 | andi. __rA,__rA,IRQS_DISABLED; \ |
53 | li __rA,IRQS_DISABLED; \ | |
7230c564 BH |
54 | ori __rB,__rB,PACA_IRQ_HARD_DIS; \ |
55 | stb __rB,PACAIRQHAPPENED(r13); \ | |
01417c6c | 56 | bne 44f; \ |
4e26bc4a | 57 | stb __rA,PACAIRQSOFTMASK(r13); \ |
7230c564 BH |
58 | TRACE_DISABLE_INTS; \ |
59 | 44: | |
60 | ||
de30a2b3 | 61 | #else |
945feb17 BH |
62 | #define TRACE_ENABLE_INTS |
63 | #define TRACE_DISABLE_INTS | |
7230c564 | 64 | |
de021bb7 | 65 | #define RECONCILE_IRQ_STATE(__rA, __rB) \ |
7230c564 | 66 | lbz __rA,PACAIRQHAPPENED(r13); \ |
4e26bc4a | 67 | li __rB,IRQS_DISABLED; \ |
7230c564 | 68 | ori __rA,__rA,PACA_IRQ_HARD_DIS; \ |
4e26bc4a | 69 | stb __rB,PACAIRQSOFTMASK(r13); \ |
7230c564 | 70 | stb __rA,PACAIRQHAPPENED(r13) |
945feb17 | 71 | #endif |
de30a2b3 IM |
72 | #endif |
73 | ||
74 | #endif |