irqflags.h 1.7 KB

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