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

ARM: v6k: select cmpxchg code sequences according to V6 variants

If CONFIG_CPU_V6 is enabled, we must avoid the byte/halfword/doubleword
exclusive operations, which aren't implemented before V6K. Use the
generic versions (or omit them) instead.

If CONFIG_CPU_V6 is not set, but CONFIG_CPU_32v6K is enabled, we have
the K extnesions, so use these new instructions.

Acked-by: Tony Lindgren <tony@atomide.com>
Tested-by: Sourav Poddar <sourav.poddar@ti.com>
Tested-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

+9 -8
+9 -8
arch/arm/include/asm/system.h
··· 347 347 #include <asm-generic/cmpxchg-local.h> 348 348 349 349 #if __LINUX_ARM_ARCH__ < 6 350 + /* min ARCH < ARMv6 */ 350 351 351 352 #ifdef CONFIG_SMP 352 353 #error "SMP is not supported on this platform" ··· 366 365 #include <asm-generic/cmpxchg.h> 367 366 #endif 368 367 369 - #else /* __LINUX_ARM_ARCH__ >= 6 */ 368 + #else /* min ARCH >= ARMv6 */ 370 369 371 370 extern void __bad_cmpxchg(volatile void *ptr, int size); 372 371 ··· 380 379 unsigned long oldval, res; 381 380 382 381 switch (size) { 383 - #ifdef CONFIG_CPU_32v6K 382 + #ifndef CONFIG_CPU_V6 /* min ARCH >= ARMv6K */ 384 383 case 1: 385 384 do { 386 385 asm volatile("@ __cmpxchg1\n" ··· 405 404 : "memory", "cc"); 406 405 } while (res); 407 406 break; 408 - #endif /* CONFIG_CPU_32v6K */ 407 + #endif 409 408 case 4: 410 409 do { 411 410 asm volatile("@ __cmpxchg4\n" ··· 451 450 unsigned long ret; 452 451 453 452 switch (size) { 454 - #ifndef CONFIG_CPU_32v6K 453 + #ifdef CONFIG_CPU_V6 /* min ARCH == ARMv6 */ 455 454 case 1: 456 455 case 2: 457 456 ret = __cmpxchg_local_generic(ptr, old, new, size); 458 457 break; 459 - #endif /* !CONFIG_CPU_32v6K */ 458 + #endif 460 459 default: 461 460 ret = __cmpxchg(ptr, old, new, size); 462 461 } ··· 470 469 (unsigned long)(n), \ 471 470 sizeof(*(ptr)))) 472 471 473 - #ifdef CONFIG_CPU_32v6K 472 + #ifndef CONFIG_CPU_V6 /* min ARCH >= ARMv6K */ 474 473 475 474 /* 476 475 * Note : ARMv7-M (currently unsupported by Linux) does not support ··· 525 524 (unsigned long long)(o), \ 526 525 (unsigned long long)(n))) 527 526 528 - #else /* !CONFIG_CPU_32v6K */ 527 + #else /* min ARCH = ARMv6 */ 529 528 530 529 #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n)) 531 530 532 - #endif /* CONFIG_CPU_32v6K */ 531 + #endif 533 532 534 533 #endif /* __LINUX_ARM_ARCH__ >= 6 */ 535 534