barrier.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
  3. #ifndef __ASM_CSKY_BARRIER_H
  4. #define __ASM_CSKY_BARRIER_H
  5. #ifndef __ASSEMBLY__
  6. #define nop() asm volatile ("nop\n":::"memory")
  7. /*
  8. * sync: completion barrier
  9. * sync.s: completion barrier and shareable to other cores
  10. * sync.i: completion barrier with flush cpu pipeline
  11. * sync.is: completion barrier with flush cpu pipeline and shareable to
  12. * other cores
  13. *
  14. * bar.brwarw: ordering barrier for all load/store instructions before it
  15. * bar.brwarws: ordering barrier for all load/store instructions before it
  16. * and shareable to other cores
  17. * bar.brar: ordering barrier for all load instructions before it
  18. * bar.brars: ordering barrier for all load instructions before it
  19. * and shareable to other cores
  20. * bar.bwaw: ordering barrier for all store instructions before it
  21. * bar.bwaws: ordering barrier for all store instructions before it
  22. * and shareable to other cores
  23. */
  24. #ifdef CONFIG_CPU_HAS_CACHEV2
  25. #define mb() asm volatile ("bar.brwarw\n":::"memory")
  26. #define rmb() asm volatile ("bar.brar\n":::"memory")
  27. #define wmb() asm volatile ("bar.bwaw\n":::"memory")
  28. #ifdef CONFIG_SMP
  29. #define __smp_mb() asm volatile ("bar.brwarws\n":::"memory")
  30. #define __smp_rmb() asm volatile ("bar.brars\n":::"memory")
  31. #define __smp_wmb() asm volatile ("bar.bwaws\n":::"memory")
  32. #endif /* CONFIG_SMP */
  33. #define sync_is() asm volatile ("sync.is\n":::"memory")
  34. #else /* !CONFIG_CPU_HAS_CACHEV2 */
  35. #define mb() asm volatile ("sync\n":::"memory")
  36. #endif
  37. #include <asm-generic/barrier.h>
  38. #endif /* __ASSEMBLY__ */
  39. #endif /* __ASM_CSKY_BARRIER_H */