diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2016-01-07 16:54:54 +0100 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2016-01-12 19:47:01 +0100 |
commit | 3226aad81aa670015a59e51458a0deb2d3bcb600 (patch) | |
tree | 0cc2ab0abf363ad3f851fdcb14c0f7c1386e89de /arch/sh/include/asm/cmpxchg-irq.h | |
parent | virtio_ring: update weak barriers to use virt_xxx (diff) | |
download | linux-3226aad81aa670015a59e51458a0deb2d3bcb600.tar.xz linux-3226aad81aa670015a59e51458a0deb2d3bcb600.zip |
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>
Diffstat (limited to 'arch/sh/include/asm/cmpxchg-irq.h')
-rw-r--r-- | arch/sh/include/asm/cmpxchg-irq.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/arch/sh/include/asm/cmpxchg-irq.h b/arch/sh/include/asm/cmpxchg-irq.h index bd11f630414a..f88877257171 100644 --- a/arch/sh/include/asm/cmpxchg-irq.h +++ b/arch/sh/include/asm/cmpxchg-irq.h @@ -14,6 +14,17 @@ static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val) return retval; } +static inline unsigned long xchg_u16(volatile u16 *m, unsigned long val) +{ + unsigned long flags, retval; + + local_irq_save(flags); + retval = *m; + *m = val; + local_irq_restore(flags); + return retval; +} + static inline unsigned long xchg_u8(volatile u8 *m, unsigned long val) { unsigned long flags, retval; |