staging: rtl8192u: remove redundant assignment to pointer crypt
[linux/fpc-iii.git] / arch / arm64 / include / asm / irqflags.h
blob7872f260c9ee3e14755e916230be06095a936dbf
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (C) 2012 ARM Ltd.
4 */
5 #ifndef __ASM_IRQFLAGS_H
6 #define __ASM_IRQFLAGS_H
8 #ifdef __KERNEL__
10 #include <asm/alternative.h>
11 #include <asm/ptrace.h>
12 #include <asm/sysreg.h>
15 * Aarch64 has flags for masking: Debug, Asynchronous (serror), Interrupts and
16 * FIQ exceptions, in the 'daif' register. We mask and unmask them in 'dai'
17 * order:
18 * Masking debug exceptions causes all other exceptions to be masked too/
19 * Masking SError masks irq, but not debug exceptions. Masking irqs has no
20 * side effects for other flags. Keeping to this order makes it easier for
21 * entry.S to know which exceptions should be unmasked.
23 * FIQ is never expected, but we mask it when we disable debug exceptions, and
24 * unmask it at all other times.
28 * CPU interrupt mask handling.
30 static inline void arch_local_irq_enable(void)
32 if (system_has_prio_mask_debugging()) {
33 u32 pmr = read_sysreg_s(SYS_ICC_PMR_EL1);
35 WARN_ON_ONCE(pmr != GIC_PRIO_IRQON && pmr != GIC_PRIO_IRQOFF);
38 asm volatile(ALTERNATIVE(
39 "msr daifclr, #2 // arch_local_irq_enable\n"
40 "nop",
41 __msr_s(SYS_ICC_PMR_EL1, "%0")
42 "dsb sy",
43 ARM64_HAS_IRQ_PRIO_MASKING)
45 : "r" ((unsigned long) GIC_PRIO_IRQON)
46 : "memory");
49 static inline void arch_local_irq_disable(void)
51 if (system_has_prio_mask_debugging()) {
52 u32 pmr = read_sysreg_s(SYS_ICC_PMR_EL1);
54 WARN_ON_ONCE(pmr != GIC_PRIO_IRQON && pmr != GIC_PRIO_IRQOFF);
57 asm volatile(ALTERNATIVE(
58 "msr daifset, #2 // arch_local_irq_disable",
59 __msr_s(SYS_ICC_PMR_EL1, "%0"),
60 ARM64_HAS_IRQ_PRIO_MASKING)
62 : "r" ((unsigned long) GIC_PRIO_IRQOFF)
63 : "memory");
67 * Save the current interrupt enable state.
69 static inline unsigned long arch_local_save_flags(void)
71 unsigned long flags;
73 asm volatile(ALTERNATIVE(
74 "mrs %0, daif",
75 __mrs_s("%0", SYS_ICC_PMR_EL1),
76 ARM64_HAS_IRQ_PRIO_MASKING)
77 : "=&r" (flags)
79 : "memory");
81 return flags;
84 static inline int arch_irqs_disabled_flags(unsigned long flags)
86 int res;
88 asm volatile(ALTERNATIVE(
89 "and %w0, %w1, #" __stringify(PSR_I_BIT),
90 "eor %w0, %w1, #" __stringify(GIC_PRIO_IRQON),
91 ARM64_HAS_IRQ_PRIO_MASKING)
92 : "=&r" (res)
93 : "r" ((int) flags)
94 : "memory");
96 return res;
99 static inline unsigned long arch_local_irq_save(void)
101 unsigned long flags;
103 flags = arch_local_save_flags();
106 * There are too many states with IRQs disabled, just keep the current
107 * state if interrupts are already disabled/masked.
109 if (!arch_irqs_disabled_flags(flags))
110 arch_local_irq_disable();
112 return flags;
116 * restore saved IRQ state
118 static inline void arch_local_irq_restore(unsigned long flags)
120 asm volatile(ALTERNATIVE(
121 "msr daif, %0\n"
122 "nop",
123 __msr_s(SYS_ICC_PMR_EL1, "%0")
124 "dsb sy",
125 ARM64_HAS_IRQ_PRIO_MASKING)
127 : "r" (flags)
128 : "memory");
131 #endif
132 #endif