]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
arm64: cmpwait: Clear event register before arming exclusive monitor
authorWill Deacon <will.deacon@arm.com>
Mon, 30 Apr 2018 12:56:32 +0000 (13:56 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Wed, 16 May 2018 11:21:19 +0000 (12:21 +0100)
When waiting for a cacheline to change state in cmpwait, we may immediately
wake-up the first time around the outer loop if the event register was
already set (for example, because of the event stream).

Avoid these spurious wakeups by explicitly clearing the event register
before loading the cacheline and setting the exclusive monitor.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/cmpxchg.h

index 4f5fd2a36e6ec9f72af72be125361ef9fc48cb76..3b0938281541912aae9fbe94ae97f799a0b342e4 100644 (file)
@@ -204,7 +204,9 @@ static inline void __cmpwait_case_##name(volatile void *ptr,                \
        unsigned long tmp;                                              \
                                                                        \
        asm volatile(                                                   \
-       "       ldxr" #sz "\t%" #w "[tmp], %[v]\n"              \
+       "       sevl\n"                                                 \
+       "       wfe\n"                                                  \
+       "       ldxr" #sz "\t%" #w "[tmp], %[v]\n"                      \
        "       eor     %" #w "[tmp], %" #w "[tmp], %" #w "[val]\n"     \
        "       cbnz    %" #w "[tmp], 1f\n"                             \
        "       wfe\n"                                                  \