|
26 | 26 | * The memory barriers are implicit with the load-acquire and store-release |
27 | 27 | * instructions. |
28 | 28 | */ |
29 | | -static inline void arch_spin_unlock_wait(arch_spinlock_t *lock) |
30 | | -{ |
31 | | - unsigned int tmp; |
32 | | - arch_spinlock_t lockval; |
33 | | - u32 owner; |
34 | | - |
35 | | - /* |
36 | | - * Ensure prior spin_lock operations to other locks have completed |
37 | | - * on this CPU before we test whether "lock" is locked. |
38 | | - */ |
39 | | - smp_mb(); |
40 | | - owner = READ_ONCE(lock->owner) << 16; |
41 | | - |
42 | | - asm volatile( |
43 | | -" sevl\n" |
44 | | -"1: wfe\n" |
45 | | -"2: ldaxr %w0, %2\n" |
46 | | - /* Is the lock free? */ |
47 | | -" eor %w1, %w0, %w0, ror #16\n" |
48 | | -" cbz %w1, 3f\n" |
49 | | - /* Lock taken -- has there been a subsequent unlock->lock transition? */ |
50 | | -" eor %w1, %w3, %w0, lsl #16\n" |
51 | | -" cbz %w1, 1b\n" |
52 | | - /* |
53 | | - * The owner has been updated, so there was an unlock->lock |
54 | | - * transition that we missed. That means we can rely on the |
55 | | - * store-release of the unlock operation paired with the |
56 | | - * load-acquire of the lock operation to publish any of our |
57 | | - * previous stores to the new lock owner and therefore don't |
58 | | - * need to bother with the writeback below. |
59 | | - */ |
60 | | -" b 4f\n" |
61 | | -"3:\n" |
62 | | - /* |
63 | | - * Serialise against any concurrent lockers by writing back the |
64 | | - * unlocked lock value |
65 | | - */ |
66 | | - ARM64_LSE_ATOMIC_INSN( |
67 | | - /* LL/SC */ |
68 | | -" stxr %w1, %w0, %2\n" |
69 | | - __nops(2), |
70 | | - /* LSE atomics */ |
71 | | -" mov %w1, %w0\n" |
72 | | -" cas %w0, %w0, %2\n" |
73 | | -" eor %w1, %w1, %w0\n") |
74 | | - /* Somebody else wrote to the lock, GOTO 10 and reload the value */ |
75 | | -" cbnz %w1, 2b\n" |
76 | | -"4:" |
77 | | - : "=&r" (lockval), "=&r" (tmp), "+Q" (*lock) |
78 | | - : "r" (owner) |
79 | | - : "memory"); |
80 | | -} |
81 | 29 |
|
82 | 30 | #define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock) |
83 | 31 |
|
@@ -176,7 +124,11 @@ static inline int arch_spin_value_unlocked(arch_spinlock_t lock) |
176 | 124 |
|
177 | 125 | static inline int arch_spin_is_locked(arch_spinlock_t *lock) |
178 | 126 | { |
179 | | - smp_mb(); /* See arch_spin_unlock_wait */ |
| 127 | + /* |
| 128 | + * Ensure prior spin_lock operations to other locks have completed |
| 129 | + * on this CPU before we test whether "lock" is locked. |
| 130 | + */ |
| 131 | + smp_mb(); /* ^^^ */ |
180 | 132 | return !arch_spin_value_unlocked(READ_ONCE(*lock)); |
181 | 133 | } |
182 | 134 |
|
|
0 commit comments