1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright IBM Corp. 1999, 2009
5 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
8 #ifndef __ASM_BARRIER_H
9 #define __ASM_BARRIER_H
12 * Force strict CPU ordering.
13 * And yes, this is required on UP too when we're talking
17 #ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
18 /* Fast-BCR without checkpoint synchronization */
19 #define __ASM_BARRIER "bcr 14,0\n"
21 #define __ASM_BARRIER "bcr 15,0\n"
24 #define mb() do { asm volatile(__ASM_BARRIER : : : "memory"); } while (0)
26 #define rmb() barrier()
27 #define wmb() barrier()
28 #define dma_rmb() mb()
29 #define dma_wmb() mb()
30 #define __smp_mb() mb()
31 #define __smp_rmb() rmb()
32 #define __smp_wmb() wmb()
34 #define __smp_store_release(p, v) \
36 compiletime_assert_atomic_type(*p); \
41 #define __smp_load_acquire(p) \
43 typeof(*p) ___p1 = READ_ONCE(*p); \
44 compiletime_assert_atomic_type(*p); \
49 #define __smp_mb__before_atomic() barrier()
50 #define __smp_mb__after_atomic() barrier()
53 * array_index_mask_nospec - generate a mask for array_idx() that is
54 * ~0UL when the bounds check succeeds and 0 otherwise
55 * @index: array element index
56 * @size: number of elements in array
58 #define array_index_mask_nospec array_index_mask_nospec
59 static inline unsigned long array_index_mask_nospec(unsigned long index
,
64 if (__builtin_constant_p(size
) && size
> 0) {
67 :"=d" (mask
) : "d" (size
-1), "d" (index
) :"cc");
72 :"=d" (mask
) : "d" (size
), "d" (index
) :"cc");
76 #include <asm-generic/barrier.h>
78 #endif /* __ASM_BARRIER_H */