|author||Catalin Marinas <firstname.lastname@example.org>||2013-05-31 16:30:58 +0100|
|committer||Mark Brown <email@example.com>||2014-05-14 12:16:14 +0100|
arm64: spinlock: retry trylock operation if strex fails on free lock
commit 4ecf7ccb1973fd826456b6ab1e6dfafe9023c753 upstream. An exclusive store instruction may fail for reasons other than lock contention (e.g. a cache eviction during the critical section) so, in line with other architectures using similar exclusive instructions (alpha, mips, powerpc), retry the trylock operation if the lock appears to be free but the strex reported failure. Signed-off-by: Catalin Marinas <firstname.lastname@example.org> Reported-by: Tony Thompson <email@example.com> Acked-by: Will Deacon <firstname.lastname@example.org> Cc: Mark Brown <email@example.com> Signed-off-by: Greg Kroah-Hartman <firstname.lastname@example.org> (cherry picked from commit 42b5bb47a62b7b2d8cd0b9af58f914c5e83ef76e) Signed-off-by: Mark Brown <email@example.com>
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/arm64/include/asm/spinlock.h b/arch/arm64/include/asm/spinlock.h
index 7065e920149d..0defa0728a9b 100644
@@ -59,9 +59,10 @@ static inline int arch_spin_trylock(arch_spinlock_t *lock)
unsigned int tmp;
- " ldaxr %w0, %1\n"
+ "2: ldaxr %w0, %1\n"
" cbnz %w0, 1f\n"
" stxr %w0, %w2, %1\n"
+ " cbnz %w0, 2b\n"
: "=&r" (tmp), "+Q" (lock->lock)
: "r" (1)