lse.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_LSE_H
  3. #define __ASM_LSE_H
  4. #if defined(CONFIG_AS_LSE) && defined(CONFIG_ARM64_LSE_ATOMICS)
  5. #define __LSE_PREAMBLE ".arch_extension lse\n"
  6. #include <linux/compiler_types.h>
  7. #include <linux/export.h>
  8. #include <linux/stringify.h>
  9. #include <asm/alternative.h>
  10. #include <asm/cpucaps.h>
  11. #ifdef __ASSEMBLER__
  12. .arch_extension lse
  13. .macro alt_lse, llsc, lse
  14. alternative_insn "\llsc", "\lse", ARM64_HAS_LSE_ATOMICS
  15. .endm
  16. #else /* __ASSEMBLER__ */
  17. /* Move the ll/sc atomics out-of-line */
  18. #define __LL_SC_INLINE notrace
  19. #define __LL_SC_PREFIX(x) __ll_sc_##x
  20. #define __LL_SC_EXPORT(x) EXPORT_SYMBOL(__LL_SC_PREFIX(x))
  21. /* Macro for constructing calls to out-of-line ll/sc atomics */
  22. #define __LL_SC_CALL(op) "bl\t" __stringify(__LL_SC_PREFIX(op)) "\n"
  23. #define __LL_SC_CLOBBERS "x16", "x17", "x30"
  24. /* In-line patching at runtime */
  25. #define ARM64_LSE_ATOMIC_INSN(llsc, lse) \
  26. ALTERNATIVE(llsc, __LSE_PREAMBLE lse, ARM64_HAS_LSE_ATOMICS)
  27. #endif /* __ASSEMBLER__ */
  28. #else /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */
  29. #ifdef __ASSEMBLER__
  30. .macro alt_lse, llsc, lse
  31. \llsc
  32. .endm
  33. #else /* __ASSEMBLER__ */
  34. #define __LL_SC_INLINE static inline
  35. #define __LL_SC_PREFIX(x) x
  36. #define __LL_SC_EXPORT(x)
  37. #define ARM64_LSE_ATOMIC_INSN(llsc, lse) llsc
  38. #endif /* __ASSEMBLER__ */
  39. #endif /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */
  40. #endif /* __ASM_LSE_H */