barrier.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 read_barrier_depends() do { } while(0)
  40. #ifdef CONFIG_SMP
  41. # define smp_mb() mb()
  42. # define smp_rmb() rmb()
  43. # define smp_wmb() wmb()
  44. # define smp_read_barrier_depends() read_barrier_depends()
  45. #else
  46. # define smp_mb() barrier()
  47. # define smp_rmb() barrier()
  48. # define smp_wmb() barrier()
  49. # define smp_read_barrier_depends() do { } while(0)
  50. #endif
  51. /*
  52. * XXX check on this ---I suspect what Linus really wants here is
  53. * acquire vs release semantics but we can't discuss this stuff with
  54. * Linus just yet. Grrr...
  55. */
  56. #define set_mb(var, value) do { (var) = (value); mb(); } while (0)
  57. /*
  58. * The group barrier in front of the rsm & ssm are necessary to ensure
  59. * that none of the previous instructions in the same group are
  60. * affected by the rsm/ssm.
  61. */
  62. #endif /* _ASM_IA64_BARRIER_H */