aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2015-07-22 13:25:52 -0400
committerWill Deacon <will.deacon@arm.com>2015-07-27 09:26:34 -0400
commit9511ca19dafbd503fb467d451fe331a6008f08cf (patch)
tree315f497d0d6f578a7e400c7834560164bd097097
parentfc9eb93cd4c5d819e9a68a7906d78ce37f42d8cd (diff)
arm64: rwlocks: don't fail trylock purely due to contention
STXR can fail for a number of reasons, so don't fail an rwlock trylock operation simply because the STXR reported failure. I'm not aware of any issues with the current code, but this makes it consistent with spin_trylock and also other architectures (e.g. arch/arm). Reported-by: Catalin Marinas <catalin.marinas@arm.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r--arch/arm64/include/asm/spinlock.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/arch/arm64/include/asm/spinlock.h b/arch/arm64/include/asm/spinlock.h
index cee128732435..0f08ba5cfb33 100644
--- a/arch/arm64/include/asm/spinlock.h
+++ b/arch/arm64/include/asm/spinlock.h
@@ -140,10 +140,11 @@ static inline int arch_write_trylock(arch_rwlock_t *rw)
140 unsigned int tmp; 140 unsigned int tmp;
141 141
142 asm volatile( 142 asm volatile(
143 " ldaxr %w0, %1\n" 143 "1: ldaxr %w0, %1\n"
144 " cbnz %w0, 1f\n" 144 " cbnz %w0, 2f\n"
145 " stxr %w0, %w2, %1\n" 145 " stxr %w0, %w2, %1\n"
146 "1:\n" 146 " cbnz %w0, 1b\n"
147 "2:\n"
147 : "=&r" (tmp), "+Q" (rw->lock) 148 : "=&r" (tmp), "+Q" (rw->lock)
148 : "r" (0x80000000) 149 : "r" (0x80000000)
149 : "memory"); 150 : "memory");
@@ -209,11 +210,12 @@ static inline int arch_read_trylock(arch_rwlock_t *rw)
209 unsigned int tmp, tmp2 = 1; 210 unsigned int tmp, tmp2 = 1;
210 211
211 asm volatile( 212 asm volatile(
212 " ldaxr %w0, %2\n" 213 "1: ldaxr %w0, %2\n"
213 " add %w0, %w0, #1\n" 214 " add %w0, %w0, #1\n"
214 " tbnz %w0, #31, 1f\n" 215 " tbnz %w0, #31, 2f\n"
215 " stxr %w1, %w0, %2\n" 216 " stxr %w1, %w0, %2\n"
216 "1:\n" 217 " cbnz %w1, 1b\n"
218 "2:\n"
217 : "=&r" (tmp), "+r" (tmp2), "+Q" (rw->lock) 219 : "=&r" (tmp), "+r" (tmp2), "+Q" (rw->lock)
218 : 220 :
219 : "memory"); 221 : "memory");