barrier.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copied from the kernel sources to tools/:
  4. *
  5. * Memory barrier definitions. This is based on information published
  6. * in the Processor Abstraction Layer and the System Abstraction Layer
  7. * manual.
  8. *
  9. * Copyright (C) 1998-2003 Hewlett-Packard Co
  10. * David Mosberger-Tang <davidm@hpl.hp.com>
  11. * Copyright (C) 1999 Asit Mallick <asit.k.mallick@intel.com>
  12. * Copyright (C) 1999 Don Dugger <don.dugger@intel.com>
  13. */
  14. #ifndef _TOOLS_LINUX_ASM_IA64_BARRIER_H
  15. #define _TOOLS_LINUX_ASM_IA64_BARRIER_H
  16. #include <linux/compiler.h>
  17. /*
  18. * Macros to force memory ordering. In these descriptions, "previous"
  19. * and "subsequent" refer to program order; "visible" means that all
  20. * architecturally visible effects of a memory access have occurred
  21. * (at a minimum, this means the memory has been read or written).
  22. *
  23. * wmb(): Guarantees that all preceding stores to memory-
  24. * like regions are visible before any subsequent
  25. * stores and that all following stores will be
  26. * visible only after all previous stores.
  27. * rmb(): Like wmb(), but for reads.
  28. * mb(): wmb()/rmb() combo, i.e., all previous memory
  29. * accesses are visible before all subsequent
  30. * accesses and vice versa. This is also known as
  31. * a "fence."
  32. *
  33. * Note: "mb()" and its variants cannot be used as a fence to order
  34. * accesses to memory mapped I/O registers. For that, mf.a needs to
  35. * be used. However, we don't want to always use mf.a because (a)
  36. * it's (presumably) much slower than mf and (b) mf.a is supported for
  37. * sequential memory pages only.
  38. */
  39. /* XXX From arch/ia64/include/uapi/asm/gcc_intrin.h */
  40. #define ia64_mf() asm volatile ("mf" ::: "memory")
  41. #define mb() ia64_mf()
  42. #define rmb() mb()
  43. #define wmb() mb()
  44. #endif /* _TOOLS_LINUX_ASM_IA64_BARRIER_H */