blob: 8262325e2fc66ec3d42f83ae6621ea4ec7e19651 [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
Will Deacon8a624f12018-02-19 13:08:56 +00007#include <linux/compiler_types.h>
8#include <linux/export.h>
Will Deaconc09d6a02015-02-03 16:14:13 +00009#include <linux/stringify.h>
Will Deaconc09d6a02015-02-03 16:14:13 +000010#include <asm/alternative.h>
Will Deacon8a624f12018-02-19 13:08:56 +000011#include <asm/cpucaps.h>
Will Deaconc09d6a02015-02-03 16:14:13 +000012
Will Deacon084f9032015-02-12 04:17:37 +000013#ifdef __ASSEMBLER__
14
15.arch_extension lse
16
17.macro alt_lse, llsc, lse
Will Deaconc739dc82015-07-27 14:11:55 +010018 alternative_insn "\llsc", "\lse", ARM64_HAS_LSE_ATOMICS
Will Deacon084f9032015-02-12 04:17:37 +000019.endm
20
21#else /* __ASSEMBLER__ */
22
Will Deaconc09d6a02015-02-03 16:14:13 +000023__asm__(".arch_extension lse");
24
25/* Move the ll/sc atomics out-of-line */
Pratyush Anandb7eed6d2017-02-06 19:46:22 +053026#define __LL_SC_INLINE notrace
Will Deaconc09d6a02015-02-03 16:14:13 +000027#define __LL_SC_PREFIX(x) __ll_sc_##x
28#define __LL_SC_EXPORT(x) EXPORT_SYMBOL(__LL_SC_PREFIX(x))
29
30/* Macro for constructing calls to out-of-line ll/sc atomics */
31#define __LL_SC_CALL(op) "bl\t" __stringify(__LL_SC_PREFIX(op)) "\n"
Ard Biesheuvel5be8b702016-02-25 20:48:53 +010032#define __LL_SC_CLOBBERS "x16", "x17", "x30"
Will Deaconc09d6a02015-02-03 16:14:13 +000033
34/* In-line patching at runtime */
35#define ARM64_LSE_ATOMIC_INSN(llsc, lse) \
Will Deaconc739dc82015-07-27 14:11:55 +010036 ALTERNATIVE(llsc, lse, ARM64_HAS_LSE_ATOMICS)
Will Deaconc09d6a02015-02-03 16:14:13 +000037
Will Deacon084f9032015-02-12 04:17:37 +000038#endif /* __ASSEMBLER__ */
39#else /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */
40
41#ifdef __ASSEMBLER__
42
43.macro alt_lse, llsc, lse
44 \llsc
45.endm
46
47#else /* __ASSEMBLER__ */
Will Deaconc09d6a02015-02-03 16:14:13 +000048
49#define __LL_SC_INLINE static inline
50#define __LL_SC_PREFIX(x) x
51#define __LL_SC_EXPORT(x)
52
53#define ARM64_LSE_ATOMIC_INSN(llsc, lse) llsc
54
Will Deacon084f9032015-02-12 04:17:37 +000055#endif /* __ASSEMBLER__ */
Will Deaconc09d6a02015-02-03 16:14:13 +000056#endif /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */
57#endif /* __ASM_LSE_H */