sh: support 1 and 2 byte xchg
authorMichael S. Tsirkin <mst@redhat.com>
Thu, 7 Jan 2016 15:54:54 +0000 (17:54 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 12 Jan 2016 18:47:01 +0000 (20:47 +0200)
commit3226aad81aa670015a59e51458a0deb2d3bcb600
tree0cc2ab0abf363ad3f851fdcb14c0f7c1386e89de
parenta65961272e1ebdb60804bbe2bb440481fcbd1c76
sh: support 1 and 2 byte xchg

This completes the xchg implementation for sh architecture.  Note: The
llsc variant is tricky since this only supports 4 byte atomics, the
existing implementation of 1 byte xchg is wrong: we need to do a 4 byte
cmpxchg and retry if any bytes changed meanwhile.

Write this in C for clarity.

Suggested-by: Rich Felker <dalias@libc.org>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
arch/sh/include/asm/cmpxchg-grb.h
arch/sh/include/asm/cmpxchg-irq.h
arch/sh/include/asm/cmpxchg-llsc.h
arch/sh/include/asm/cmpxchg.h