lse.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #include <asm/cpufeature.h>
  7. #ifdef __ASSEMBLER__
  8. .arch_extension lse
  9. .macro alt_lse, llsc, lse
  10. alternative_insn "\llsc", "\lse", ARM64_HAS_LSE_ATOMICS
  11. .endm
  12. #else /* __ASSEMBLER__ */
  13. __asm__(".arch_extension lse");
  14. /* Move the ll/sc atomics out-of-line */
  15. #define __LL_SC_INLINE
  16. #define __LL_SC_PREFIX(x) __ll_sc_##x
  17. #define __LL_SC_EXPORT(x) EXPORT_SYMBOL(__LL_SC_PREFIX(x))
  18. /* Macro for constructing calls to out-of-line ll/sc atomics */
  19. #define __LL_SC_CALL(op) "bl\t" __stringify(__LL_SC_PREFIX(op)) "\n"
  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 */