Skip to content

Commit b08ee5f

Browse files
suryasaimadhuH. Peter Anvin
authored andcommitted
x86: Simplify __HAVE_ARCH_CMPXCHG tests
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>
1 parent 8917157 commit b08ee5f

6 files changed

Lines changed: 5 additions & 25 deletions

File tree

‎arch/x86/include/asm/cmpxchg.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <linux/compiler.h>
55
#include <asm/alternative.h> /* Provides LOCK_PREFIX */
66

7+
#define __HAVE_ARCH_CMPXCHG 1
8+
79
/*
810
* Non-existant functions to indicate usage errors at link time
911
* (or compile-time if the compiler implements __compiletime_error().
@@ -143,7 +145,6 @@ extern void __add_wrong_size(void)
143145
# include <asm/cmpxchg_64.h>
144146
#endif
145147

146-
#ifdef __HAVE_ARCH_CMPXCHG
147148
#define cmpxchg(ptr, old, new) \
148149
__cmpxchg(ptr, old, new, sizeof(*(ptr)))
149150

@@ -152,7 +153,6 @@ extern void __add_wrong_size(void)
152153

153154
#define cmpxchg_local(ptr, old, new) \
154155
__cmpxchg_local(ptr, old, new, sizeof(*(ptr)))
155-
#endif
156156

157157
/*
158158
* xadd() adds "inc" to "*ptr" and atomically returns the previous

‎arch/x86/include/asm/cmpxchg_32.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ static inline void set_64bit(volatile u64 *ptr, u64 value)
3434
: "memory");
3535
}
3636

37-
#define __HAVE_ARCH_CMPXCHG 1
38-
3937
#ifdef CONFIG_X86_CMPXCHG64
4038
#define cmpxchg64(ptr, o, n) \
4139
((__typeof__(*(ptr)))__cmpxchg64((ptr), (unsigned long long)(o), \

‎arch/x86/include/asm/cmpxchg_64.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ static inline void set_64bit(volatile u64 *ptr, u64 val)
66
*ptr = val;
77
}
88

9-
#define __HAVE_ARCH_CMPXCHG 1
10-
119
#define cmpxchg64(ptr, o, n) \
1210
({ \
1311
BUILD_BUG_ON(sizeof(*(ptr)) != 8); \

‎arch/x86/include/asm/mc146818rtc.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#define RTC_ALWAYS_BCD 1 /* RTC operates in binary mode */
1414
#endif
1515

16-
#if defined(CONFIG_X86_32) && defined(__HAVE_ARCH_CMPXCHG)
16+
#if defined(CONFIG_X86_32)
1717
/*
1818
* This lock provides nmi access to the CMOS/RTC registers. It has some
1919
* special properties. It is owned by a CPU and stores the index register

‎arch/x86/include/asm/mutex_32.h‎

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,23 +100,11 @@ do { \
100100
static inline int __mutex_fastpath_trylock(atomic_t *count,
101101
int (*fail_fn)(atomic_t *))
102102
{
103-
/*
104-
* We have two variants here. The cmpxchg based one is the best one
105-
* because it never induce a false contention state. It is included
106-
* here because architectures using the inc/dec algorithms over the
107-
* xchg ones are much more likely to support cmpxchg natively.
108-
*
109-
* If not we fall back to the spinlock based variant - that is
110-
* just as efficient (and simpler) as a 'destructive' probing of
111-
* the mutex state would be.
112-
*/
113-
#ifdef __HAVE_ARCH_CMPXCHG
103+
/* cmpxchg because it never induces a false contention state. */
114104
if (likely(atomic_cmpxchg(count, 1, 0) == 1))
115105
return 1;
106+
116107
return 0;
117-
#else
118-
return fail_fn(count);
119-
#endif
120108
}
121109

122110
#endif /* _ASM_X86_MUTEX_32_H */

‎arch/x86/kernel/acpi/boot.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ int acpi_fix_pin2_polarity __initdata;
7474
static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
7575
#endif
7676

77-
#ifndef __HAVE_ARCH_CMPXCHG
78-
#warning ACPI uses CMPXCHG, i486 and later hardware
79-
#endif
80-
8177
/* --------------------------------------------------------------------------
8278
Boot-time Configuration
8379
-------------------------------------------------------------------------- */

0 commit comments

Comments
 (0)