]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - arch/powerpc/include/asm/hw_irq.h
1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
5 #ifndef _ASM_POWERPC_HW_IRQ_H
6 #define _ASM_POWERPC_HW_IRQ_H
10 #include <linux/errno.h>
11 #include <linux/compiler.h>
12 #include <asm/ptrace.h>
13 #include <asm/processor.h>
18 * PACA flags in paca->irq_happened.
20 * This bits are set when interrupts occur while soft-disabled
21 * and allow a proper replay. Additionally, PACA_IRQ_HARD_DIS
22 * is set whenever we manually hard disable.
24 #define PACA_IRQ_HARD_DIS 0x01
25 #define PACA_IRQ_DBELL 0x02
26 #define PACA_IRQ_EE 0x04
27 #define PACA_IRQ_DEC 0x08 /* Or FIT */
28 #define PACA_IRQ_EE_EDGE 0x10 /* BookE only */
29 #define PACA_IRQ_HMI 0x20
32 * flags for paca->irq_soft_mask
34 #define IRQS_ENABLED 0
35 #define IRQS_DISABLED 1 /* local_irq_disable() interrupts */
36 #define IRQS_PMI_DISABLED 2
37 #define IRQS_ALL_DISABLED (IRQS_DISABLED | IRQS_PMI_DISABLED)
39 #endif /* CONFIG_PPC64 */
43 extern void replay_system_reset(void);
44 extern void __replay_interrupt(unsigned int vector
);
46 extern void timer_interrupt(struct pt_regs
*);
47 extern void performance_monitor_exception(struct pt_regs
*regs
);
48 extern void WatchdogException(struct pt_regs
*regs
);
49 extern void unknown_exception(struct pt_regs
*regs
);
54 static inline unsigned long arch_local_save_flags(void)
61 : "i" (offsetof(struct paca_struct
, soft_enabled
)));
66 static inline unsigned long arch_local_irq_disable(void)
68 unsigned long flags
, zero
;
71 "li %1,0; lbz %0,%2(13); stb %1,%2(13)"
72 : "=r" (flags
), "=&r" (zero
)
73 : "i" (offsetof(struct paca_struct
, soft_enabled
))
79 extern void arch_local_irq_restore(unsigned long);
81 static inline void arch_local_irq_enable(void)
83 arch_local_irq_restore(1);
86 static inline unsigned long arch_local_irq_save(void)
88 return arch_local_irq_disable();
91 static inline bool arch_irqs_disabled_flags(unsigned long flags
)
96 static inline bool arch_irqs_disabled(void)
98 return arch_irqs_disabled_flags(arch_local_save_flags());
101 #ifdef CONFIG_PPC_BOOK3E
102 #define __hard_irq_enable() asm volatile("wrteei 1" : : : "memory")
103 #define __hard_irq_disable() asm volatile("wrteei 0" : : : "memory")
105 #define __hard_irq_enable() __mtmsrd(local_paca->kernel_msr | MSR_EE, 1)
106 #define __hard_irq_disable() __mtmsrd(local_paca->kernel_msr, 1)
109 #define hard_irq_disable() do { \
111 __hard_irq_disable(); \
112 _was_enabled = local_paca->soft_enabled; \
113 local_paca->soft_enabled = 0; \
114 local_paca->irq_happened |= PACA_IRQ_HARD_DIS; \
116 trace_hardirqs_off(); \
119 static inline bool lazy_irq_pending(void)
121 return !!(get_paca()->irq_happened
& ~PACA_IRQ_HARD_DIS
);
125 * This is called by asynchronous interrupts to conditionally
126 * re-enable hard interrupts when soft-disabled after having
127 * cleared the source of the interrupt
129 static inline void may_hard_irq_enable(void)
131 get_paca()->irq_happened
&= ~PACA_IRQ_HARD_DIS
;
132 if (!(get_paca()->irq_happened
& PACA_IRQ_EE
))
136 static inline bool arch_irq_disabled_regs(struct pt_regs
*regs
)
141 extern bool prep_irq_for_idle(void);
142 extern bool prep_irq_for_idle_irqsoff(void);
143 extern void irq_set_pending_from_srr1(unsigned long srr1
);
145 #define fini_irq_for_idle_irqsoff() trace_hardirqs_off();
147 extern void force_external_irq_replay(void);
149 #else /* CONFIG_PPC64 */
151 #define SET_MSR_EE(x) mtmsr(x)
153 static inline unsigned long arch_local_save_flags(void)
158 static inline void arch_local_irq_restore(unsigned long flags
)
160 #if defined(CONFIG_BOOKE)
161 asm volatile("wrtee %0" : : "r" (flags
) : "memory");
167 static inline unsigned long arch_local_irq_save(void)
169 unsigned long flags
= arch_local_save_flags();
171 asm volatile("wrteei 0" : : : "memory");
172 #elif defined(CONFIG_PPC_8xx)
175 SET_MSR_EE(flags
& ~MSR_EE
);
180 static inline void arch_local_irq_disable(void)
183 asm volatile("wrteei 0" : : : "memory");
184 #elif defined(CONFIG_PPC_8xx)
187 arch_local_irq_save();
191 static inline void arch_local_irq_enable(void)
194 asm volatile("wrteei 1" : : : "memory");
195 #elif defined(CONFIG_PPC_8xx)
198 unsigned long msr
= mfmsr();
199 SET_MSR_EE(msr
| MSR_EE
);
203 static inline bool arch_irqs_disabled_flags(unsigned long flags
)
205 return (flags
& MSR_EE
) == 0;
208 static inline bool arch_irqs_disabled(void)
210 return arch_irqs_disabled_flags(arch_local_save_flags());
213 #define hard_irq_disable() arch_local_irq_disable()
215 static inline bool arch_irq_disabled_regs(struct pt_regs
*regs
)
217 return !(regs
->msr
& MSR_EE
);
220 static inline void may_hard_irq_enable(void) { }
222 #endif /* CONFIG_PPC64 */
224 #define ARCH_IRQ_INIT_FLAGS IRQ_NOREQUEST
227 * interrupt-retrigger: should we handle this via lost interrupts and IPIs
228 * or should we not care like we do now ? --BenH.
232 #endif /* __ASSEMBLY__ */
233 #endif /* __KERNEL__ */
234 #endif /* _ASM_POWERPC_HW_IRQ_H */