[PATCH] fixup! locking,arm64: Introduce cmpwait()
From: Will Deacon
Date: Tue Apr 26 2016 - 12:31:53 EST
Signed-off-by: Will Deacon <will.deacon@xxxxxxx>
---
arch/arm64/include/asm/cmpxchg.h | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/arch/arm64/include/asm/cmpxchg.h b/arch/arm64/include/asm/cmpxchg.h
index cd7bff6ddedc..9b7113a3f0d7 100644
--- a/arch/arm64/include/asm/cmpxchg.h
+++ b/arch/arm64/include/asm/cmpxchg.h
@@ -225,18 +225,19 @@ __CMPXCHG_GEN(_mb)
})
#define __CMPWAIT_GEN(w, sz, name) \
-void __cmpwait_case_##name(volatile void *ptr, unsigned long val) \
+static inline void __cmpwait_case_##name(volatile void *ptr, \
+ unsigned long val) \
{ \
unsigned long tmp; \
\
asm volatile( \
" ldxr" #sz "\t%" #w "[tmp], %[v]\n" \
" eor %" #w "[tmp], %" #w "[tmp], %" #w "[val]\n" \
- " cbnz %" #w "[tmp], 1f\n" \
+ " cbz %" #w "[tmp], 1f\n" \
" wfe\n" \
"1:" \
- : [tmp] "=&r" (tmp), [val] "=&r" (val), \
- [v] "+Q" (*(unsigned long *)ptr)); \
+ : [tmp] "=&r" (tmp), [v] "+Q" (*(unsigned long *)ptr) \
+ : [val] "r" (val)); \
}
__CMPWAIT_GEN(w, b, 1);
@@ -244,11 +245,13 @@ __CMPWAIT_GEN(w, h, 2);
__CMPWAIT_GEN(w, , 4);
__CMPWAIT_GEN( , , 8);
+#undef __CMPWAIT_GEN
+
static inline void __cmpwait(volatile void *ptr, unsigned long val, int size)
{
switch (size) {
- case 1: return __cmpwait_case_1(ptr, val);
- case 2: return __cmpwait_case_2(ptr, val);
+ case 1: return __cmpwait_case_1(ptr, (u8)val);
+ case 2: return __cmpwait_case_2(ptr, (u16)val);
case 4: return __cmpwait_case_4(ptr, val);
case 8: return __cmpwait_case_8(ptr, val);
default: BUILD_BUG();
--
2.1.4