ARM: dma-api: fix max_pfn off-by-one error in __dma_supported()
[linux/fpc-iii.git] / arch / arm64 / include / asm / lse.h
blobd429f7701c3670101b62540f79c65ec711cba4d1
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_LSE_H
3 #define __ASM_LSE_H
5 #include <asm/atomic_ll_sc.h>
7 #ifdef CONFIG_ARM64_LSE_ATOMICS
9 #define __LSE_PREAMBLE ".arch armv8-a+lse\n"
11 #include <linux/compiler_types.h>
12 #include <linux/export.h>
13 #include <linux/jump_label.h>
14 #include <linux/stringify.h>
15 #include <asm/alternative.h>
16 #include <asm/atomic_lse.h>
17 #include <asm/cpucaps.h>
19 extern struct static_key_false cpu_hwcap_keys[ARM64_NCAPS];
20 extern struct static_key_false arm64_const_caps_ready;
22 static inline bool system_uses_lse_atomics(void)
24 return (static_branch_likely(&arm64_const_caps_ready)) &&
25 static_branch_likely(&cpu_hwcap_keys[ARM64_HAS_LSE_ATOMICS]);
28 #define __lse_ll_sc_body(op, ...) \
29 ({ \
30 system_uses_lse_atomics() ? \
31 __lse_##op(__VA_ARGS__) : \
32 __ll_sc_##op(__VA_ARGS__); \
35 /* In-line patching at runtime */
36 #define ARM64_LSE_ATOMIC_INSN(llsc, lse) \
37 ALTERNATIVE(llsc, __LSE_PREAMBLE lse, ARM64_HAS_LSE_ATOMICS)
39 #else /* CONFIG_ARM64_LSE_ATOMICS */
41 static inline bool system_uses_lse_atomics(void) { return false; }
43 #define __lse_ll_sc_body(op, ...) __ll_sc_##op(__VA_ARGS__)
45 #define ARM64_LSE_ATOMIC_INSN(llsc, lse) llsc
47 #endif /* CONFIG_ARM64_LSE_ATOMICS */
48 #endif /* __ASM_LSE_H */