1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <asm/atomic_ll_sc.h>
7 #ifdef CONFIG_ARM64_LSE_ATOMICS
9 #define __LSE_PREAMBLE ".arch_extension lse\n"
11 #include <linux/compiler_types.h>
12 #include <linux/export.h>
13 #include <linux/stringify.h>
14 #include <asm/alternative.h>
15 #include <asm/alternative-macros.h>
16 #include <asm/atomic_lse.h>
17 #include <asm/cpucaps.h>
19 static __always_inline bool system_uses_lse_atomics(void)
21 return alternative_has_feature_likely(ARM64_HAS_LSE_ATOMICS);
24 #define __lse_ll_sc_body(op, ...) \
26 system_uses_lse_atomics() ? \
27 __lse_##op(__VA_ARGS__) : \
28 __ll_sc_##op(__VA_ARGS__); \
31 /* In-line patching at runtime */
32 #define ARM64_LSE_ATOMIC_INSN(llsc, lse) \
33 ALTERNATIVE(llsc, __LSE_PREAMBLE lse, ARM64_HAS_LSE_ATOMICS)
35 #else /* CONFIG_ARM64_LSE_ATOMICS */
37 static inline bool system_uses_lse_atomics(void) { return false; }
39 #define __lse_ll_sc_body(op, ...) __ll_sc_##op(__VA_ARGS__)
41 #define ARM64_LSE_ATOMIC_INSN(llsc, lse) llsc
43 #endif /* CONFIG_ARM64_LSE_ATOMICS */
44 #endif /* __ASM_LSE_H */