2 * Generic barrier definitions, originally based on MN10300 definitions.
4 * It should be possible to use these on really simple architectures,
5 * but it serves more as a starting point for new ports.
7 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
8 * Written by David Howells (dhowells@redhat.com)
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public Licence
12 * as published by the Free Software Foundation; either version
13 * 2 of the Licence, or (at your option) any later version.
15 #ifndef __ASM_GENERIC_BARRIER_H
16 #define __ASM_GENERIC_BARRIER_H
20 #include <linux/compiler.h>
23 #define nop() asm volatile ("nop")
27 * Force strict CPU ordering. And yes, this is required on UP too when we're
30 * Fall back to compiler barriers if nothing better is provided.
34 #define mb() barrier()
46 #define dma_rmb() rmb()
50 #define dma_wmb() wmb()
53 #ifndef read_barrier_depends
54 #define read_barrier_depends() do { } while (0)
64 #define smp_rmb() rmb()
68 #define smp_wmb() wmb()
71 #ifndef smp_read_barrier_depends
72 #define smp_read_barrier_depends() read_barrier_depends()
75 #else /* !CONFIG_SMP */
78 #define smp_mb() barrier()
82 #define smp_rmb() barrier()
86 #define smp_wmb() barrier()
89 #ifndef smp_read_barrier_depends
90 #define smp_read_barrier_depends() do { } while (0)
93 #endif /* CONFIG_SMP */
96 #define smp_store_mb(var, value) do { WRITE_ONCE(var, value); smp_mb(); } while (0)
99 #ifndef smp_mb__before_atomic
100 #define smp_mb__before_atomic() smp_mb()
103 #ifndef smp_mb__after_atomic
104 #define smp_mb__after_atomic() smp_mb()
107 #define smp_store_release(p, v) \
109 compiletime_assert_atomic_type(*p); \
114 #define smp_load_acquire(p) \
116 typeof(*p) ___p1 = READ_ONCE(*p); \
117 compiletime_assert_atomic_type(*p); \
122 #endif /* !__ASSEMBLY__ */
123 #endif /* __ASM_GENERIC_BARRIER_H */