Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / arch / loongarch / include / asm / irqflags.h
blob319a8c616f1f5b60097c30a24f9f24682b9282cc
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
4 */
5 #ifndef _ASM_IRQFLAGS_H
6 #define _ASM_IRQFLAGS_H
8 #ifndef __ASSEMBLY__
10 #include <linux/compiler.h>
11 #include <linux/stringify.h>
12 #include <asm/loongarch.h>
14 static inline void arch_local_irq_enable(void)
16 u32 flags = CSR_CRMD_IE;
17 __asm__ __volatile__(
18 "csrxchg %[val], %[mask], %[reg]\n\t"
19 : [val] "+r" (flags)
20 : [mask] "r" (CSR_CRMD_IE), [reg] "i" (LOONGARCH_CSR_CRMD)
21 : "memory");
24 static inline void arch_local_irq_disable(void)
26 u32 flags = 0;
27 __asm__ __volatile__(
28 "csrxchg %[val], %[mask], %[reg]\n\t"
29 : [val] "+r" (flags)
30 : [mask] "r" (CSR_CRMD_IE), [reg] "i" (LOONGARCH_CSR_CRMD)
31 : "memory");
34 static inline unsigned long arch_local_irq_save(void)
36 u32 flags = 0;
37 __asm__ __volatile__(
38 "csrxchg %[val], %[mask], %[reg]\n\t"
39 : [val] "+r" (flags)
40 : [mask] "r" (CSR_CRMD_IE), [reg] "i" (LOONGARCH_CSR_CRMD)
41 : "memory");
42 return flags;
45 static inline void arch_local_irq_restore(unsigned long flags)
47 __asm__ __volatile__(
48 "csrxchg %[val], %[mask], %[reg]\n\t"
49 : [val] "+r" (flags)
50 : [mask] "r" (CSR_CRMD_IE), [reg] "i" (LOONGARCH_CSR_CRMD)
51 : "memory");
54 static inline unsigned long arch_local_save_flags(void)
56 u32 flags;
57 __asm__ __volatile__(
58 "csrrd %[val], %[reg]\n\t"
59 : [val] "=r" (flags)
60 : [reg] "i" (LOONGARCH_CSR_CRMD)
61 : "memory");
62 return flags;
65 static inline int arch_irqs_disabled_flags(unsigned long flags)
67 return !(flags & CSR_CRMD_IE);
70 static inline int arch_irqs_disabled(void)
72 return arch_irqs_disabled_flags(arch_local_save_flags());
75 #endif /* #ifndef __ASSEMBLY__ */
77 #endif /* _ASM_IRQFLAGS_H */