arm64: barrier: Implement smp_cond_load_relaxed
authorWill Deacon <will.deacon@arm.com>
Wed, 31 Jan 2018 15:55:24 +0000 (15:55 +0000)
committerWill Deacon <will.deacon@arm.com>
Thu, 5 Jul 2018 09:05:05 +0000 (10:05 +0100)
We can provide an implementation of smp_cond_load_relaxed using READ_ONCE
and __cmpwait_relaxed.

Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/include/asm/barrier.h

index f11518af96a93abf8c003cd197c5a8f24c88d994..822a9192c55118ddc624687d3917f086cad1637f 100644 (file)
@@ -128,6 +128,19 @@ do {                                                                       \
        __u.__val;                                                      \
 })
 
+#define smp_cond_load_relaxed(ptr, cond_expr)                          \
+({                                                                     \
+       typeof(ptr) __PTR = (ptr);                                      \
+       typeof(*ptr) VAL;                                               \
+       for (;;) {                                                      \
+               VAL = READ_ONCE(*__PTR);                                \
+               if (cond_expr)                                          \
+                       break;                                          \
+               __cmpwait_relaxed(__PTR, VAL);                          \
+       }                                                               \
+       VAL;                                                            \
+})
+
 #define smp_cond_load_acquire(ptr, cond_expr)                          \
 ({                                                                     \
        typeof(ptr) __PTR = (ptr);                                      \