blob: c5a0d2e8270d3cbc54db382f1939c34d01b2e7a8 [file] [log] [blame]
Will Deaconc09d6a02015-02-03 16:14:13 +00001#ifndef __ASM_LSE_H
2#define __ASM_LSE_H
3
4#if defined(CONFIG_AS_LSE) && defined(CONFIG_ARM64_LSE_ATOMICS)
5
6#include <linux/stringify.h>
Will Deaconc09d6a02015-02-03 16:14:13 +00007#include <asm/alternative.h>
Will Deaconc09d6a02015-02-03 16:14:13 +00008
Will Deacon084f9032015-02-12 04:17:37 +00009#ifdef __ASSEMBLER__
10
11.arch_extension lse
12
13.macro alt_lse, llsc, lse
Will Deaconc739dc82015-07-27 14:11:55 +010014 alternative_insn "\llsc", "\lse", ARM64_HAS_LSE_ATOMICS
Will Deacon084f9032015-02-12 04:17:37 +000015.endm
16
17#else /* __ASSEMBLER__ */
18
Sami Tolvanen1597fdf2019-02-06 12:51:14 -080019#ifdef CONFIG_LTO_CLANG
20#define __LSE_PREAMBLE ".arch armv8-a+lse\n"
21#else
Will Deaconc09d6a02015-02-03 16:14:13 +000022__asm__(".arch_extension lse");
Sami Tolvanen1597fdf2019-02-06 12:51:14 -080023#define __LSE_PREAMBLE
24#endif
Will Deaconc09d6a02015-02-03 16:14:13 +000025
26/* Move the ll/sc atomics out-of-line */
27#define __LL_SC_INLINE
28#define __LL_SC_PREFIX(x) __ll_sc_##x
29#define __LL_SC_EXPORT(x) EXPORT_SYMBOL(__LL_SC_PREFIX(x))
30
31/* Macro for constructing calls to out-of-line ll/sc atomics */
32#define __LL_SC_CALL(op) "bl\t" __stringify(__LL_SC_PREFIX(op)) "\n"
Ard Biesheuvel5be8b702016-02-25 20:48:53 +010033#define __LL_SC_CLOBBERS "x16", "x17", "x30"
Will Deaconc09d6a02015-02-03 16:14:13 +000034
35/* In-line patching at runtime */
36#define ARM64_LSE_ATOMIC_INSN(llsc, lse) \
Sami Tolvanen1597fdf2019-02-06 12:51:14 -080037 ALTERNATIVE(llsc, __LSE_PREAMBLE lse, ARM64_HAS_LSE_ATOMICS)
Will Deaconc09d6a02015-02-03 16:14:13 +000038
Will Deacon084f9032015-02-12 04:17:37 +000039#endif /* __ASSEMBLER__ */
40#else /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */
41
42#ifdef __ASSEMBLER__
43
44.macro alt_lse, llsc, lse
45 \llsc
46.endm
47
48#else /* __ASSEMBLER__ */
Will Deaconc09d6a02015-02-03 16:14:13 +000049
50#define __LL_SC_INLINE static inline
51#define __LL_SC_PREFIX(x) x
52#define __LL_SC_EXPORT(x)
53
54#define ARM64_LSE_ATOMIC_INSN(llsc, lse) llsc
55
Will Deacon084f9032015-02-12 04:17:37 +000056#endif /* __ASSEMBLER__ */
Will Deaconc09d6a02015-02-03 16:14:13 +000057#endif /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */
58#endif /* __ASM_LSE_H */