Will Deacon | c09d6a0 | 2015-02-03 16:14:13 +0000 | [diff] [blame] | 1 | #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 Deacon | c09d6a0 | 2015-02-03 16:14:13 +0000 | [diff] [blame] | 7 | #include <asm/alternative.h> |
Will Deacon | c09d6a0 | 2015-02-03 16:14:13 +0000 | [diff] [blame] | 8 | |
Will Deacon | 084f903 | 2015-02-12 04:17:37 +0000 | [diff] [blame] | 9 | #ifdef __ASSEMBLER__ |
| 10 | |
| 11 | .arch_extension lse |
| 12 | |
| 13 | .macro alt_lse, llsc, lse |
Will Deacon | c739dc8 | 2015-07-27 14:11:55 +0100 | [diff] [blame] | 14 | alternative_insn "\llsc", "\lse", ARM64_HAS_LSE_ATOMICS |
Will Deacon | 084f903 | 2015-02-12 04:17:37 +0000 | [diff] [blame] | 15 | .endm |
| 16 | |
| 17 | #else /* __ASSEMBLER__ */ |
| 18 | |
Sami Tolvanen | 1597fdf | 2019-02-06 12:51:14 -0800 | [diff] [blame] | 19 | #ifdef CONFIG_LTO_CLANG |
| 20 | #define __LSE_PREAMBLE ".arch armv8-a+lse\n" |
| 21 | #else |
Will Deacon | c09d6a0 | 2015-02-03 16:14:13 +0000 | [diff] [blame] | 22 | __asm__(".arch_extension lse"); |
Sami Tolvanen | 1597fdf | 2019-02-06 12:51:14 -0800 | [diff] [blame] | 23 | #define __LSE_PREAMBLE |
| 24 | #endif |
Will Deacon | c09d6a0 | 2015-02-03 16:14:13 +0000 | [diff] [blame] | 25 | |
| 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 Biesheuvel | 5be8b70 | 2016-02-25 20:48:53 +0100 | [diff] [blame] | 33 | #define __LL_SC_CLOBBERS "x16", "x17", "x30" |
Will Deacon | c09d6a0 | 2015-02-03 16:14:13 +0000 | [diff] [blame] | 34 | |
| 35 | /* In-line patching at runtime */ |
| 36 | #define ARM64_LSE_ATOMIC_INSN(llsc, lse) \ |
Sami Tolvanen | 1597fdf | 2019-02-06 12:51:14 -0800 | [diff] [blame] | 37 | ALTERNATIVE(llsc, __LSE_PREAMBLE lse, ARM64_HAS_LSE_ATOMICS) |
Will Deacon | c09d6a0 | 2015-02-03 16:14:13 +0000 | [diff] [blame] | 38 | |
Will Deacon | 084f903 | 2015-02-12 04:17:37 +0000 | [diff] [blame] | 39 | #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 Deacon | c09d6a0 | 2015-02-03 16:14:13 +0000 | [diff] [blame] | 49 | |
| 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 Deacon | 084f903 | 2015-02-12 04:17:37 +0000 | [diff] [blame] | 56 | #endif /* __ASSEMBLER__ */ |
Will Deacon | c09d6a0 | 2015-02-03 16:14:13 +0000 | [diff] [blame] | 57 | #endif /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */ |
| 58 | #endif /* __ASM_LSE_H */ |