lse.h 1.2 KB

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