blob: eec95768eaad572938105ee4c0d904271cbf5aad [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Will Deaconc09d6a02015-02-03 16:14:13 +00002#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>
Will Deaconc09d6a02015-02-03 16:14:13 +00008#include <asm/alternative.h>
Will Deaconc09d6a02015-02-03 16:14:13 +00009
Will Deacon084f9032015-02-12 04:17:37 +000010#ifdef __ASSEMBLER__
11
12.arch_extension lse
13
14.macro alt_lse, llsc, lse
Will Deaconc739dc82015-07-27 14:11:55 +010015 alternative_insn "\llsc", "\lse", ARM64_HAS_LSE_ATOMICS
Will Deacon084f9032015-02-12 04:17:37 +000016.endm
17
18#else /* __ASSEMBLER__ */
19
Will Deaconc09d6a02015-02-03 16:14:13 +000020__asm__(".arch_extension lse");
21
22/* Move the ll/sc atomics out-of-line */
Pratyush Anandb7eed6d2017-02-06 19:46:22 +053023#define __LL_SC_INLINE notrace
Will Deaconc09d6a02015-02-03 16:14:13 +000024#define __LL_SC_PREFIX(x) __ll_sc_##x
25#define __LL_SC_EXPORT(x) EXPORT_SYMBOL(__LL_SC_PREFIX(x))
26
27/* Macro for constructing calls to out-of-line ll/sc atomics */
28#define __LL_SC_CALL(op) "bl\t" __stringify(__LL_SC_PREFIX(op)) "\n"
Ard Biesheuvel5be8b702016-02-25 20:48:53 +010029#define __LL_SC_CLOBBERS "x16", "x17", "x30"
Will Deaconc09d6a02015-02-03 16:14:13 +000030
31/* In-line patching at runtime */
32#define ARM64_LSE_ATOMIC_INSN(llsc, lse) \
Will Deaconc739dc82015-07-27 14:11:55 +010033 ALTERNATIVE(llsc, lse, ARM64_HAS_LSE_ATOMICS)
Will Deaconc09d6a02015-02-03 16:14:13 +000034
Will Deacon084f9032015-02-12 04:17:37 +000035#endif /* __ASSEMBLER__ */
36#else /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */
37
38#ifdef __ASSEMBLER__
39
40.macro alt_lse, llsc, lse
41 \llsc
42.endm
43
44#else /* __ASSEMBLER__ */
Will Deaconc09d6a02015-02-03 16:14:13 +000045
46#define __LL_SC_INLINE static inline
47#define __LL_SC_PREFIX(x) x
48#define __LL_SC_EXPORT(x)
49
50#define ARM64_LSE_ATOMIC_INSN(llsc, lse) llsc
51
Will Deacon084f9032015-02-12 04:17:37 +000052#endif /* __ASSEMBLER__ */
Will Deaconc09d6a02015-02-03 16:14:13 +000053#endif /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */
54#endif /* __ASM_LSE_H */