]> git.karo-electronics.de Git - karo-tx-linux.git/commit
sparc32: unbreak arch_write_unlock()
authorMikael Pettersson <mikpe@it.uu.se>
Mon, 15 Aug 2011 10:11:50 +0000 (10:11 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 7 Nov 2011 21:46:41 +0000 (13:46 -0800)
commitc8efe8c2805748f93add31d0463252c57f27a0ab
tree175a7321330cd8dc4b7a20278ea35ea56bedbf63
parent7923e0a24b17bb8ee4dc5f83cc42d82a2173e75a
sparc32: unbreak arch_write_unlock()

commit 3f6aa0b113846a8628baa649af422cfc6fb1d786 upstream.

The sparc32 version of arch_write_unlock() is just a plain assignment.
Unfortunately this allows the compiler to schedule side-effects in a
protected region to occur after the HW-level unlock, which is broken.
E.g., the following trivial test case gets miscompiled:

#include <linux/spinlock.h>
rwlock_t lock;
int counter;
void foo(void) { write_lock(&lock); ++counter; write_unlock(&lock); }

Fixed by adding a compiler memory barrier to arch_write_unlock().  The
sparc64 version combines the barrier and assignment into a single asm(),
and implements the operation as a static inline, so that's what I did too.

Compile-tested with sparc32_defconfig + CONFIG_SMP=y.

Signed-off-by: Mikael Pettersson <mikpe@it.uu.se>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/sparc/include/asm/spinlock_32.h