Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: 8443/1: Adding support for atomic half word exchange

Since support for half-word atomic exchange was not there and Qspinlock
on ARM requires it, modified __xchg() to add support for that as well.
ARMv6 and lower does not support ldrex{b,h} so, added a guard code to
prevent build breaks.

Signed-off-by: Sarbojit Ganguly <ganguly.s@samsung.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Sarbojit Ganguly and committed by
Russell King
e8973a88 e1b8c05d

+12
+12
arch/arm/include/asm/cmpxchg.h
··· 39 39 40 40 switch (size) { 41 41 #if __LINUX_ARM_ARCH__ >= 6 42 + #ifndef CONFIG_CPU_V6 /* MIN ARCH >= V6K */ 42 43 case 1: 43 44 asm volatile("@ __xchg1\n" 44 45 "1: ldrexb %0, [%3]\n" ··· 50 49 : "r" (x), "r" (ptr) 51 50 : "memory", "cc"); 52 51 break; 52 + case 2: 53 + asm volatile("@ __xchg2\n" 54 + "1: ldrexh %0, [%3]\n" 55 + " strexh %1, %2, [%3]\n" 56 + " teq %1, #0\n" 57 + " bne 1b" 58 + : "=&r" (ret), "=&r" (tmp) 59 + : "r" (x), "r" (ptr) 60 + : "memory", "cc"); 61 + break; 62 + #endif 53 63 case 4: 54 64 asm volatile("@ __xchg4\n" 55 65 "1: ldrex %0, [%3]\n"