RISC-V: Add READ_ONCE in arch_spin_is_locked()
authorPalmer Dabbelt <palmer@sifive.com>
Tue, 28 Nov 2017 22:05:04 +0000 (14:05 -0800)
committerPalmer Dabbelt <palmer@sifive.com>
Tue, 28 Nov 2017 22:05:04 +0000 (14:05 -0800)
This was just incorrect in the original version.

Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
arch/riscv/include/asm/spinlock.h

index 04c71d938afdbf40f93d0d5d9d89229fa5f72c56..a6a005c4f2fb46f025cdfe6e5e628f96f42f4956 100644 (file)
@@ -24,7 +24,7 @@
 
 /* FIXME: Replace this with a ticket lock, like MIPS. */
 
-#define arch_spin_is_locked(x) ((x)->lock != 0)
+#define arch_spin_is_locked(x) (READ_ONCE((x)->lock) != 0)
 
 static inline void arch_spin_unlock(arch_spinlock_t *lock)
 {