barrier.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Memory barrier definitions. This is based on information published
  3. * in the Processor Abstraction Layer and the System Abstraction Layer
  4. * manual.
  5. *
  6. * Copyright (C) 1998-2003 Hewlett-Packard Co
  7. * David Mosberger-Tang <davidm@hpl.hp.com>
  8. * Copyright (C) 1999 Asit Mallick <asit.k.mallick@intel.com>
  9. * Copyright (C) 1999 Don Dugger <don.dugger@intel.com>
  10. */
  11. #ifndef _ASM_IA64_BARRIER_H
  12. #define _ASM_IA64_BARRIER_H
  13. #include <linux/compiler.h>
  14. /*
  15. * Macros to force memory ordering. In these descriptions, "previous"
  16. * and "subsequent" refer to program order; "visible" means that all
  17. * architecturally visible effects of a memory access have occurred
  18. * (at a minimum, this means the memory has been read or written).
  19. *
  20. * wmb(): Guarantees that all preceding stores to memory-
  21. * like regions are visible before any subsequent
  22. * stores and that all following stores will be
  23. * visible only after all previous stores.
  24. * rmb(): Like wmb(), but for reads.
  25. * mb(): wmb()/rmb() combo, i.e., all previous memory
  26. * accesses are visible before all subsequent
  27. * accesses and vice versa. This is also known as
  28. * a "fence."
  29. *
  30. * Note: "mb()" and its variants cannot be used as a fence to order
  31. * accesses to memory mapped I/O registers. For that, mf.a needs to
  32. * be used. However, we don't want to always use mf.a because (a)
  33. * it's (presumably) much slower than mf and (b) mf.a is supported for
  34. * sequential memory pages only.
  35. */
  36. #define mb() ia64_mf()
  37. #define rmb() mb()
  38. #define wmb() mb()
  39. #define dma_rmb() mb()
  40. #define dma_wmb() mb()
  41. #ifdef CONFIG_SMP
  42. # define smp_mb() mb()
  43. #else
  44. # define smp_mb() barrier()
  45. #endif
  46. #define smp_rmb() smp_mb()
  47. #define smp_wmb() smp_mb()
  48. #define read_barrier_depends() do { } while (0)
  49. #define smp_read_barrier_depends() do { } while (0)
  50. #define smp_mb__before_atomic() barrier()
  51. #define smp_mb__after_atomic() barrier()
  52. /*
  53. * IA64 GCC turns volatile stores into st.rel and volatile loads into ld.acq no
  54. * need for asm trickery!
  55. */
  56. #define smp_store_release(p, v) \
  57. do { \
  58. compiletime_assert_atomic_type(*p); \
  59. barrier(); \
  60. WRITE_ONCE(*p, v); \
  61. } while (0)
  62. #define smp_load_acquire(p) \
  63. ({ \
  64. typeof(*p) ___p1 = READ_ONCE(*p); \
  65. compiletime_assert_atomic_type(*p); \
  66. barrier(); \
  67. ___p1; \
  68. })
  69. #define smp_store_mb(var, value) do { WRITE_ONCE(var, value); mb(); } while (0)
  70. /*
  71. * The group barrier in front of the rsm & ssm are necessary to ensure
  72. * that none of the previous instructions in the same group are
  73. * affected by the rsm/ssm.
  74. */
  75. #endif /* _ASM_IA64_BARRIER_H */