1 /* SPDX-License-Identifier: GPL-2.0 */
5 #if defined(CONFIG_AS_LSE) && defined(CONFIG_ARM64_LSE_ATOMICS)
7 #include <linux/compiler_types.h>
8 #include <linux/export.h>
9 #include <linux/stringify.h>
10 #include <asm/alternative.h>
11 #include <asm/cpucaps.h>
17 .macro alt_lse
, llsc
, lse
18 alternative_insn
"\llsc", "\lse", ARM64_HAS_LSE_ATOMICS
21 #else /* __ASSEMBLER__ */
23 __asm__(".arch_extension lse");
25 /* Move the ll/sc atomics out-of-line */
26 #define __LL_SC_INLINE notrace
27 #define __LL_SC_PREFIX(x) __ll_sc_##x
28 #define __LL_SC_EXPORT(x) EXPORT_SYMBOL(__LL_SC_PREFIX(x))
30 /* Macro for constructing calls to out-of-line ll/sc atomics */
31 #define __LL_SC_CALL(op) "bl\t" __stringify(__LL_SC_PREFIX(op)) "\n"
32 #define __LL_SC_CLOBBERS "x16", "x17", "x30"
34 /* In-line patching at runtime */
35 #define ARM64_LSE_ATOMIC_INSN(llsc, lse) \
36 ALTERNATIVE(llsc, lse, ARM64_HAS_LSE_ATOMICS)
38 #endif /* __ASSEMBLER__ */
39 #else /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */
43 .macro alt_lse
, llsc
, lse
47 #else /* __ASSEMBLER__ */
49 #define __LL_SC_INLINE static inline
50 #define __LL_SC_PREFIX(x) x
51 #define __LL_SC_EXPORT(x)
53 #define ARM64_LSE_ATOMIC_INSN(llsc, lse) llsc
55 #endif /* __ASSEMBLER__ */
56 #endif /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */
57 #endif /* __ASM_LSE_H */