hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/arch/powerpc/include/asm/barrier.h
....@@ -7,6 +7,10 @@
77
88 #include <asm/asm-const.h>
99
10
+#ifndef __ASSEMBLY__
11
+#include <asm/ppc-opcode.h>
12
+#endif
13
+
1014 /*
1115 * Memory barrier.
1216 * The sync instruction guarantees that all memory accesses initiated
....@@ -18,8 +22,6 @@
1822 * mb() prevents loads and stores being reordered across this point.
1923 * rmb() prevents loads being reordered across this point.
2024 * 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).
2325 *
2426 * *mb() variants without smp_ prefix must order all types of memory
2527 * operations with one another. sync is the only instruction sufficient
....@@ -80,6 +82,22 @@
8082 ___p1; \
8183 })
8284
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
+
83101 #ifdef CONFIG_PPC_BOOK3S_64
84102 #define NOSPEC_BARRIER_SLOT nop
85103 #elif defined(CONFIG_PPC_FSL_BOOK3E)
....@@ -101,6 +119,15 @@
101119 #define barrier_nospec()
102120 #endif /* CONFIG_PPC_BARRIER_NOSPEC */
103121
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
+
104131 #include <asm-generic/barrier.h>
105132
106133 #endif /* _ASM_POWERPC_BARRIER_H */