synch.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_POWERPC_SYNCH_H
  3. #define _ASM_POWERPC_SYNCH_H
  4. #ifdef __KERNEL__
  5. #include <linux/stringify.h>
  6. #include <asm/feature-fixups.h>
  7. #include <asm/asm-const.h>
  8. #ifndef __ASSEMBLY__
  9. extern unsigned int __start___lwsync_fixup, __stop___lwsync_fixup;
  10. extern void do_lwsync_fixups(unsigned long value, void *fixup_start,
  11. void *fixup_end);
  12. static inline void eieio(void)
  13. {
  14. __asm__ __volatile__ ("eieio" : : : "memory");
  15. }
  16. static inline void isync(void)
  17. {
  18. __asm__ __volatile__ ("isync" : : : "memory");
  19. }
  20. #endif /* __ASSEMBLY__ */
  21. #if defined(__powerpc64__)
  22. # define LWSYNC lwsync
  23. #elif defined(CONFIG_E500)
  24. # define LWSYNC \
  25. START_LWSYNC_SECTION(96); \
  26. sync; \
  27. MAKE_LWSYNC_SECTION_ENTRY(96, __lwsync_fixup);
  28. #else
  29. # define LWSYNC sync
  30. #endif
  31. #ifdef CONFIG_SMP
  32. #define __PPC_ACQUIRE_BARRIER \
  33. START_LWSYNC_SECTION(97); \
  34. isync; \
  35. MAKE_LWSYNC_SECTION_ENTRY(97, __lwsync_fixup);
  36. #define PPC_ACQUIRE_BARRIER "\n" stringify_in_c(__PPC_ACQUIRE_BARRIER)
  37. #define PPC_RELEASE_BARRIER stringify_in_c(LWSYNC) "\n"
  38. #define PPC_ATOMIC_ENTRY_BARRIER "\n" stringify_in_c(sync) "\n"
  39. #define PPC_ATOMIC_EXIT_BARRIER "\n" stringify_in_c(sync) "\n"
  40. #else
  41. #define PPC_ACQUIRE_BARRIER
  42. #define PPC_RELEASE_BARRIER
  43. #define PPC_ATOMIC_ENTRY_BARRIER
  44. #define PPC_ATOMIC_EXIT_BARRIER
  45. #endif
  46. #endif /* __KERNEL__ */
  47. #endif /* _ASM_POWERPC_SYNCH_H */