1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2b8b572e1SStephen Rothwell /* 3b8b572e1SStephen Rothwell * IRQ flags handling 4b8b572e1SStephen Rothwell */ 5b8b572e1SStephen Rothwell #ifndef _ASM_IRQFLAGS_H 6b8b572e1SStephen Rothwell #define _ASM_IRQFLAGS_H 7b8b572e1SStephen Rothwell 8b8b572e1SStephen Rothwell #ifndef __ASSEMBLY__ 9b8b572e1SStephen Rothwell /* 10df9ee292SDavid Howells * Get definitions for arch_local_save_flags(x), etc. 11b8b572e1SStephen Rothwell */ 12b8b572e1SStephen Rothwell #include <asm/hw_irq.h> 13b8b572e1SStephen Rothwell 14b8b572e1SStephen Rothwell #else 15b8b572e1SStephen Rothwell #ifdef CONFIG_TRACE_IRQFLAGS 163cb5f1a3SSteven Rostedt #ifdef CONFIG_IRQSOFF_TRACER 173cb5f1a3SSteven Rostedt /* 183cb5f1a3SSteven Rostedt * Since the ftrace irqsoff latency trace checks CALLER_ADDR1, 193cb5f1a3SSteven Rostedt * which is the stack frame here, we need to force a stack frame 203cb5f1a3SSteven Rostedt * in case we came from user space. 213cb5f1a3SSteven Rostedt */ 223cb5f1a3SSteven Rostedt #define TRACE_WITH_FRAME_BUFFER(func) \ 233cb5f1a3SSteven Rostedt mflr r0; \ 24d51959d7SAnton Blanchard stdu r1, -STACK_FRAME_OVERHEAD(r1); \ 253cb5f1a3SSteven Rostedt std r0, 16(r1); \ 26d51959d7SAnton Blanchard stdu r1, -STACK_FRAME_OVERHEAD(r1); \ 273cb5f1a3SSteven Rostedt bl func; \ 283cb5f1a3SSteven Rostedt ld r1, 0(r1); \ 293cb5f1a3SSteven Rostedt ld r1, 0(r1); 303cb5f1a3SSteven Rostedt #else 313cb5f1a3SSteven Rostedt #define TRACE_WITH_FRAME_BUFFER(func) \ 323cb5f1a3SSteven Rostedt bl func; 333cb5f1a3SSteven Rostedt #endif 343cb5f1a3SSteven Rostedt 35b8b572e1SStephen Rothwell /* 36144beb2fSMichael Ellerman * These are calls to C code, so the caller must be prepared for volatiles to 37144beb2fSMichael Ellerman * be clobbered. 38b8b572e1SStephen Rothwell */ 39b1576fecSAnton Blanchard #define TRACE_ENABLE_INTS TRACE_WITH_FRAME_BUFFER(trace_hardirqs_on) 40b1576fecSAnton Blanchard #define TRACE_DISABLE_INTS TRACE_WITH_FRAME_BUFFER(trace_hardirqs_off) 413cb5f1a3SSteven Rostedt 427230c564SBenjamin Herrenschmidt /* 43de021bb7STiejun Chen * This is used by assembly code to soft-disable interrupts first and 44de021bb7STiejun Chen * reconcile irq state. 45144beb2fSMichael Ellerman * 46144beb2fSMichael Ellerman * NB: This may call C code, so the caller must be prepared for volatiles to 47144beb2fSMichael Ellerman * be clobbered. 487230c564SBenjamin Herrenschmidt */ 49de021bb7STiejun Chen #define RECONCILE_IRQ_STATE(__rA, __rB) \ 507230c564SBenjamin Herrenschmidt lbz __rA,PACASOFTIRQEN(r13); \ 517230c564SBenjamin Herrenschmidt lbz __rB,PACAIRQHAPPENED(r13); \ 527230c564SBenjamin Herrenschmidt cmpwi cr0,__rA,0; \ 537230c564SBenjamin Herrenschmidt li __rA,0; \ 547230c564SBenjamin Herrenschmidt ori __rB,__rB,PACA_IRQ_HARD_DIS; \ 557230c564SBenjamin Herrenschmidt stb __rB,PACAIRQHAPPENED(r13); \ 567230c564SBenjamin Herrenschmidt beq 44f; \ 577230c564SBenjamin Herrenschmidt stb __rA,PACASOFTIRQEN(r13); \ 587230c564SBenjamin Herrenschmidt TRACE_DISABLE_INTS; \ 597230c564SBenjamin Herrenschmidt 44: 607230c564SBenjamin Herrenschmidt 61b8b572e1SStephen Rothwell #else 62b8b572e1SStephen Rothwell #define TRACE_ENABLE_INTS 63b8b572e1SStephen Rothwell #define TRACE_DISABLE_INTS 647230c564SBenjamin Herrenschmidt 65de021bb7STiejun Chen #define RECONCILE_IRQ_STATE(__rA, __rB) \ 667230c564SBenjamin Herrenschmidt lbz __rA,PACAIRQHAPPENED(r13); \ 677230c564SBenjamin Herrenschmidt li __rB,0; \ 687230c564SBenjamin Herrenschmidt ori __rA,__rA,PACA_IRQ_HARD_DIS; \ 697230c564SBenjamin Herrenschmidt stb __rB,PACASOFTIRQEN(r13); \ 707230c564SBenjamin Herrenschmidt stb __rA,PACAIRQHAPPENED(r13) 71b8b572e1SStephen Rothwell #endif 72b8b572e1SStephen Rothwell #endif 73b8b572e1SStephen Rothwell 74b8b572e1SStephen Rothwell #endif 75