Skip to content

Commit

Permalink
powerpc: Add smp_mb()s to arch_spin_unlock_wait()
Browse files Browse the repository at this point in the history
commit 78e05b1 upstream.

Similar to the previous commit which described why we need to add a
barrier to arch_spin_is_locked(), we have a similar problem with
spin_unlock_wait().

We need a barrier on entry to ensure any spinlock we have previously
taken is visibly locked prior to the load of lock->slock.

It's also not clear if spin_unlock_wait() is intended to have ACQUIRE
semantics. For now be conservative and add a barrier on exit to give it
ACQUIRE semantics.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
  • Loading branch information
Michael Ellerman authored and Jiri Slaby committed Oct 31, 2014
1 parent 5aaee42 commit d9fc4e6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/powerpc/lib/locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,16 @@ void __rw_yield(arch_rwlock_t *rw)

void arch_spin_unlock_wait(arch_spinlock_t *lock)
{
smp_mb();

while (lock->slock) {
HMT_low();
if (SHARED_PROCESSOR)
__spin_yield(lock);
}
HMT_medium();

smp_mb();
}

EXPORT_SYMBOL(arch_spin_unlock_wait);

0 comments on commit d9fc4e6

Please sign in to comment.