1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __ASM_LSE_H 3 #define __ASM_LSE_H 4 5 #if defined(CONFIG_AS_LSE) && defined(CONFIG_ARM64_LSE_ATOMICS) 6 7 #include <linux/stringify.h> 8 #include <asm/alternative.h> 9 10 #ifdef __ASSEMBLER__ 11 12 .arch_extension lse 13 14 .macro alt_lse, llsc, lse 15 alternative_insn "\llsc", "\lse", ARM64_HAS_LSE_ATOMICS 16 .endm 17 18 #else /* __ASSEMBLER__ */ 19 20 #ifdef CONFIG_LTO_CLANG 21 #define __LSE_PREAMBLE ".arch armv8-a+lse\n" 22 #else 23 __asm__(".arch_extension lse"); 24 #define __LSE_PREAMBLE 25 #endif 26 27 /* Move the ll/sc atomics out-of-line */ 28 #define __LL_SC_INLINE notrace 29 #define __LL_SC_PREFIX(x) __ll_sc_##x 30 #define __LL_SC_EXPORT(x) EXPORT_SYMBOL(__LL_SC_PREFIX(x)) 31 32 /* Macro for constructing calls to out-of-line ll/sc atomics */ 33 #define __LL_SC_CALL(op) "bl\t" __stringify(__LL_SC_PREFIX(op)) "\n" 34 #define __LL_SC_CLOBBERS "x16", "x17", "x30" 35 36 /* In-line patching at runtime */ 37 #define ARM64_LSE_ATOMIC_INSN(llsc, lse) \ 38 ALTERNATIVE(llsc, __LSE_PREAMBLE lse, ARM64_HAS_LSE_ATOMICS) 39 40 #endif /* __ASSEMBLER__ */ 41 #else /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */ 42 43 #ifdef __ASSEMBLER__ 44 45 .macro alt_lse, llsc, lse 46 \llsc 47 .endm 48 49 #else /* __ASSEMBLER__ */ 50 51 #define __LL_SC_INLINE static inline 52 #define __LL_SC_PREFIX(x) x 53 #define __LL_SC_EXPORT(x) 54 55 #define ARM64_LSE_ATOMIC_INSN(llsc, lse) llsc 56 57 #endif /* __ASSEMBLER__ */ 58 #endif /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */ 59 #endif /* __ASM_LSE_H */ 60