blob: fc756e22c84cd718278d4f0ba8ebc6a32ff4739e [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
Will Deaconc09d6a02015-02-03 16:14:13 +000019__asm__(".arch_extension lse");
20
21/* Move the ll/sc atomics out-of-line */
22#define __LL_SC_INLINE
23#define __LL_SC_PREFIX(x) __ll_sc_##x
24#define __LL_SC_EXPORT(x) EXPORT_SYMBOL(__LL_SC_PREFIX(x))
25
26/* Macro for constructing calls to out-of-line ll/sc atomics */
27#define __LL_SC_CALL(op) "bl\t" __stringify(__LL_SC_PREFIX(op)) "\n"
Ard Biesheuvel5be8b702016-02-25 20:48:53 +010028#define __LL_SC_CLOBBERS "x16", "x17", "x30"
Will Deaconc09d6a02015-02-03 16:14:13 +000029
30/* In-line patching at runtime */
31#define ARM64_LSE_ATOMIC_INSN(llsc, lse) \
Will Deaconc739dc82015-07-27 14:11:55 +010032 ALTERNATIVE(llsc, lse, ARM64_HAS_LSE_ATOMICS)
Will Deaconc09d6a02015-02-03 16:14:13 +000033
Will Deacon084f9032015-02-12 04:17:37 +000034#endif /* __ASSEMBLER__ */
35#else /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */
36
37#ifdef __ASSEMBLER__
38
39.macro alt_lse, llsc, lse
40 \llsc
41.endm
42
43#else /* __ASSEMBLER__ */
Will Deaconc09d6a02015-02-03 16:14:13 +000044
45#define __LL_SC_INLINE static inline
46#define __LL_SC_PREFIX(x) x
47#define __LL_SC_EXPORT(x)
48
49#define ARM64_LSE_ATOMIC_INSN(llsc, lse) llsc
50
Will Deacon084f9032015-02-12 04:17:37 +000051#endif /* __ASSEMBLER__ */
Will Deaconc09d6a02015-02-03 16:14:13 +000052#endif /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */
53#endif /* __ASM_LSE_H */