.. | .. |
---|
7 | 7 | |
---|
8 | 8 | #include <asm/asm-const.h> |
---|
9 | 9 | |
---|
| 10 | +#ifndef __ASSEMBLY__ |
---|
| 11 | +#include <asm/ppc-opcode.h> |
---|
| 12 | +#endif |
---|
| 13 | + |
---|
10 | 14 | /* |
---|
11 | 15 | * Memory barrier. |
---|
12 | 16 | * The sync instruction guarantees that all memory accesses initiated |
---|
.. | .. |
---|
18 | 22 | * mb() prevents loads and stores being reordered across this point. |
---|
19 | 23 | * rmb() prevents loads being reordered across this point. |
---|
20 | 24 | * wmb() prevents stores being reordered across this point. |
---|
21 | | - * read_barrier_depends() prevents data-dependent loads being reordered |
---|
22 | | - * across this point (nop on PPC). |
---|
23 | 25 | * |
---|
24 | 26 | * *mb() variants without smp_ prefix must order all types of memory |
---|
25 | 27 | * operations with one another. sync is the only instruction sufficient |
---|
.. | .. |
---|
80 | 82 | ___p1; \ |
---|
81 | 83 | }) |
---|
82 | 84 | |
---|
| 85 | +#ifdef CONFIG_PPC64 |
---|
| 86 | +#define smp_cond_load_relaxed(ptr, cond_expr) ({ \ |
---|
| 87 | + typeof(ptr) __PTR = (ptr); \ |
---|
| 88 | + __unqual_scalar_typeof(*ptr) VAL; \ |
---|
| 89 | + VAL = READ_ONCE(*__PTR); \ |
---|
| 90 | + if (unlikely(!(cond_expr))) { \ |
---|
| 91 | + spin_begin(); \ |
---|
| 92 | + do { \ |
---|
| 93 | + VAL = READ_ONCE(*__PTR); \ |
---|
| 94 | + } while (!(cond_expr)); \ |
---|
| 95 | + spin_end(); \ |
---|
| 96 | + } \ |
---|
| 97 | + (typeof(*ptr))VAL; \ |
---|
| 98 | +}) |
---|
| 99 | +#endif |
---|
| 100 | + |
---|
83 | 101 | #ifdef CONFIG_PPC_BOOK3S_64 |
---|
84 | 102 | #define NOSPEC_BARRIER_SLOT nop |
---|
85 | 103 | #elif defined(CONFIG_PPC_FSL_BOOK3E) |
---|
.. | .. |
---|
101 | 119 | #define barrier_nospec() |
---|
102 | 120 | #endif /* CONFIG_PPC_BARRIER_NOSPEC */ |
---|
103 | 121 | |
---|
| 122 | +/* |
---|
| 123 | + * pmem_wmb() ensures that all stores for which the modification |
---|
| 124 | + * are written to persistent storage by preceding dcbfps/dcbstps |
---|
| 125 | + * instructions have updated persistent storage before any data |
---|
| 126 | + * access or data transfer caused by subsequent instructions is |
---|
| 127 | + * initiated. |
---|
| 128 | + */ |
---|
| 129 | +#define pmem_wmb() __asm__ __volatile__(PPC_PHWSYNC ::: "memory") |
---|
| 130 | + |
---|
104 | 131 | #include <asm-generic/barrier.h> |
---|
105 | 132 | |
---|
106 | 133 | #endif /* _ASM_POWERPC_BARRIER_H */ |
---|