x86: Simplify __HAVE_ARCH_CMPXCHG tests
authorBorislav Petkov <bp@suse.de>
Fri, 11 Jul 2014 10:43:38 +0000 (12:43 +0200)
committerH. Peter Anvin <hpa@linux.intel.com>
Sat, 12 Jul 2014 00:28:51 +0000 (17:28 -0700)
Both the 32-bit and 64-bit cmpxchg.h header define __HAVE_ARCH_CMPXCHG
and there's ifdeffery which checks it. But since both bitness define it,
we can just as well move it up to the main cmpxchg header and simpify a
bit of code in doing that.

Signed-off-by: Borislav Petkov <bp@suse.de>
Link: http://lkml.kernel.org/r/20140711104338.GB17083@pd.tnic
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
arch/x86/include/asm/cmpxchg.h
arch/x86/include/asm/cmpxchg_32.h
arch/x86/include/asm/cmpxchg_64.h
arch/x86/include/asm/mc146818rtc.h
arch/x86/include/asm/mutex_32.h
arch/x86/kernel/acpi/boot.c

index d47786acb0169d0c2e87e830384ecac579cbc18c..99c105d78b7e123eec41d9bb5b2c308e5205d514 100644 (file)
@@ -4,6 +4,8 @@
 #include <linux/compiler.h>
 #include <asm/alternative.h> /* Provides LOCK_PREFIX */
 
+#define __HAVE_ARCH_CMPXCHG 1
+
 /*
  * Non-existant functions to indicate usage errors at link time
  * (or compile-time if the compiler implements __compiletime_error().
@@ -143,7 +145,6 @@ extern void __add_wrong_size(void)
 # include <asm/cmpxchg_64.h>
 #endif
 
-#ifdef __HAVE_ARCH_CMPXCHG
 #define cmpxchg(ptr, old, new)                                         \
        __cmpxchg(ptr, old, new, sizeof(*(ptr)))
 
@@ -152,7 +153,6 @@ extern void __add_wrong_size(void)
 
 #define cmpxchg_local(ptr, old, new)                                   \
        __cmpxchg_local(ptr, old, new, sizeof(*(ptr)))
-#endif
 
 /*
  * xadd() adds "inc" to "*ptr" and atomically returns the previous
index f8bf2eecab864f4d00bcd4cd2a47d4611e422787..f7e142926481b6fce09ce3f2d5ddc7f5869b86d8 100644 (file)
@@ -34,8 +34,6 @@ static inline void set_64bit(volatile u64 *ptr, u64 value)
                     : "memory");
 }
 
-#define __HAVE_ARCH_CMPXCHG 1
-
 #ifdef CONFIG_X86_CMPXCHG64
 #define cmpxchg64(ptr, o, n)                                           \
        ((__typeof__(*(ptr)))__cmpxchg64((ptr), (unsigned long long)(o), \
index 614be87f1a9b94ac5276436931fc844df2610c54..1af94697aae510fb8eee5699b96895622975f5ec 100644 (file)
@@ -6,8 +6,6 @@ static inline void set_64bit(volatile u64 *ptr, u64 val)
        *ptr = val;
 }
 
-#define __HAVE_ARCH_CMPXCHG 1
-
 #define cmpxchg64(ptr, o, n)                                           \
 ({                                                                     \
        BUILD_BUG_ON(sizeof(*(ptr)) != 8);                              \
index a55c7efcc4ed1c8b0e297fd52d1dbb729a1cab51..0f555cc3198419b3b60a9121702cfe09c11dd197 100644 (file)
@@ -13,7 +13,7 @@
 #define RTC_ALWAYS_BCD 1       /* RTC operates in binary mode */
 #endif
 
-#if defined(CONFIG_X86_32) && defined(__HAVE_ARCH_CMPXCHG)
+#if defined(CONFIG_X86_32)
 /*
  * This lock provides nmi access to the CMOS/RTC registers.  It has some
  * special properties.  It is owned by a CPU and stores the index register
index 0208c3c2cbc6733e3053681a5430428d5cacff5e..85e6cda45a0297e20204fe926757e46b647faa2b 100644 (file)
@@ -100,23 +100,11 @@ do {                                                              \
 static inline int __mutex_fastpath_trylock(atomic_t *count,
                                           int (*fail_fn)(atomic_t *))
 {
-       /*
-        * We have two variants here. The cmpxchg based one is the best one
-        * because it never induce a false contention state.  It is included
-        * here because architectures using the inc/dec algorithms over the
-        * xchg ones are much more likely to support cmpxchg natively.
-        *
-        * If not we fall back to the spinlock based variant - that is
-        * just as efficient (and simpler) as a 'destructive' probing of
-        * the mutex state would be.
-        */
-#ifdef __HAVE_ARCH_CMPXCHG
+       /* cmpxchg because it never induces a false contention state. */
        if (likely(atomic_cmpxchg(count, 1, 0) == 1))
                return 1;
+
        return 0;
-#else
-       return fail_fn(count);
-#endif
 }
 
 #endif /* _ASM_X86_MUTEX_32_H */
index 86281ffb96d6d08bf830d096a82a733d5bf7b812..a531f6564ed08e65d9e9e1ae4f86875caa846ef3 100644 (file)
@@ -74,10 +74,6 @@ int acpi_fix_pin2_polarity __initdata;
 static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
 #endif
 
-#ifndef __HAVE_ARCH_CMPXCHG
-#warning ACPI uses CMPXCHG, i486 and later hardware
-#endif
-
 /* --------------------------------------------------------------------------
                               Boot-time Configuration
    -------------------------------------------------------------------------- */