diff options
author | Borislav Petkov <bp@suse.de> | 2014-07-11 06:43:38 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2014-07-11 20:28:51 -0400 |
commit | b08ee5f7e4135d64b8edd769367f8964a725122e (patch) | |
tree | c23c93542548c4ef5da24ed60d3c5dc038b3b607 | |
parent | 891715793f0451e5114d200be932ac14ce8521a3 (diff) |
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>
-rw-r--r-- | arch/x86/include/asm/cmpxchg.h | 4 | ||||
-rw-r--r-- | arch/x86/include/asm/cmpxchg_32.h | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/cmpxchg_64.h | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/mc146818rtc.h | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/mutex_32.h | 16 | ||||
-rw-r--r-- | arch/x86/kernel/acpi/boot.c | 4 |
6 files changed, 5 insertions, 25 deletions
diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h index d47786acb016..99c105d78b7e 100644 --- a/arch/x86/include/asm/cmpxchg.h +++ b/arch/x86/include/asm/cmpxchg.h | |||
@@ -4,6 +4,8 @@ | |||
4 | #include <linux/compiler.h> | 4 | #include <linux/compiler.h> |
5 | #include <asm/alternative.h> /* Provides LOCK_PREFIX */ | 5 | #include <asm/alternative.h> /* Provides LOCK_PREFIX */ |
6 | 6 | ||
7 | #define __HAVE_ARCH_CMPXCHG 1 | ||
8 | |||
7 | /* | 9 | /* |
8 | * Non-existant functions to indicate usage errors at link time | 10 | * Non-existant functions to indicate usage errors at link time |
9 | * (or compile-time if the compiler implements __compiletime_error(). | 11 | * (or compile-time if the compiler implements __compiletime_error(). |
@@ -143,7 +145,6 @@ extern void __add_wrong_size(void) | |||
143 | # include <asm/cmpxchg_64.h> | 145 | # include <asm/cmpxchg_64.h> |
144 | #endif | 146 | #endif |
145 | 147 | ||
146 | #ifdef __HAVE_ARCH_CMPXCHG | ||
147 | #define cmpxchg(ptr, old, new) \ | 148 | #define cmpxchg(ptr, old, new) \ |
148 | __cmpxchg(ptr, old, new, sizeof(*(ptr))) | 149 | __cmpxchg(ptr, old, new, sizeof(*(ptr))) |
149 | 150 | ||
@@ -152,7 +153,6 @@ extern void __add_wrong_size(void) | |||
152 | 153 | ||
153 | #define cmpxchg_local(ptr, old, new) \ | 154 | #define cmpxchg_local(ptr, old, new) \ |
154 | __cmpxchg_local(ptr, old, new, sizeof(*(ptr))) | 155 | __cmpxchg_local(ptr, old, new, sizeof(*(ptr))) |
155 | #endif | ||
156 | 156 | ||
157 | /* | 157 | /* |
158 | * xadd() adds "inc" to "*ptr" and atomically returns the previous | 158 | * xadd() adds "inc" to "*ptr" and atomically returns the previous |
diff --git a/arch/x86/include/asm/cmpxchg_32.h b/arch/x86/include/asm/cmpxchg_32.h index f8bf2eecab86..f7e142926481 100644 --- a/arch/x86/include/asm/cmpxchg_32.h +++ b/arch/x86/include/asm/cmpxchg_32.h | |||
@@ -34,8 +34,6 @@ static inline void set_64bit(volatile u64 *ptr, u64 value) | |||
34 | : "memory"); | 34 | : "memory"); |
35 | } | 35 | } |
36 | 36 | ||
37 | #define __HAVE_ARCH_CMPXCHG 1 | ||
38 | |||
39 | #ifdef CONFIG_X86_CMPXCHG64 | 37 | #ifdef CONFIG_X86_CMPXCHG64 |
40 | #define cmpxchg64(ptr, o, n) \ | 38 | #define cmpxchg64(ptr, o, n) \ |
41 | ((__typeof__(*(ptr)))__cmpxchg64((ptr), (unsigned long long)(o), \ | 39 | ((__typeof__(*(ptr)))__cmpxchg64((ptr), (unsigned long long)(o), \ |
diff --git a/arch/x86/include/asm/cmpxchg_64.h b/arch/x86/include/asm/cmpxchg_64.h index 614be87f1a9b..1af94697aae5 100644 --- a/arch/x86/include/asm/cmpxchg_64.h +++ b/arch/x86/include/asm/cmpxchg_64.h | |||
@@ -6,8 +6,6 @@ static inline void set_64bit(volatile u64 *ptr, u64 val) | |||
6 | *ptr = val; | 6 | *ptr = val; |
7 | } | 7 | } |
8 | 8 | ||
9 | #define __HAVE_ARCH_CMPXCHG 1 | ||
10 | |||
11 | #define cmpxchg64(ptr, o, n) \ | 9 | #define cmpxchg64(ptr, o, n) \ |
12 | ({ \ | 10 | ({ \ |
13 | BUILD_BUG_ON(sizeof(*(ptr)) != 8); \ | 11 | BUILD_BUG_ON(sizeof(*(ptr)) != 8); \ |
diff --git a/arch/x86/include/asm/mc146818rtc.h b/arch/x86/include/asm/mc146818rtc.h index a55c7efcc4ed..0f555cc31984 100644 --- a/arch/x86/include/asm/mc146818rtc.h +++ b/arch/x86/include/asm/mc146818rtc.h | |||
@@ -13,7 +13,7 @@ | |||
13 | #define RTC_ALWAYS_BCD 1 /* RTC operates in binary mode */ | 13 | #define RTC_ALWAYS_BCD 1 /* RTC operates in binary mode */ |
14 | #endif | 14 | #endif |
15 | 15 | ||
16 | #if defined(CONFIG_X86_32) && defined(__HAVE_ARCH_CMPXCHG) | 16 | #if defined(CONFIG_X86_32) |
17 | /* | 17 | /* |
18 | * This lock provides nmi access to the CMOS/RTC registers. It has some | 18 | * This lock provides nmi access to the CMOS/RTC registers. It has some |
19 | * special properties. It is owned by a CPU and stores the index register | 19 | * special properties. It is owned by a CPU and stores the index register |
diff --git a/arch/x86/include/asm/mutex_32.h b/arch/x86/include/asm/mutex_32.h index 0208c3c2cbc6..85e6cda45a02 100644 --- a/arch/x86/include/asm/mutex_32.h +++ b/arch/x86/include/asm/mutex_32.h | |||
@@ -100,23 +100,11 @@ do { \ | |||
100 | static inline int __mutex_fastpath_trylock(atomic_t *count, | 100 | static inline int __mutex_fastpath_trylock(atomic_t *count, |
101 | int (*fail_fn)(atomic_t *)) | 101 | int (*fail_fn)(atomic_t *)) |
102 | { | 102 | { |
103 | /* | 103 | /* cmpxchg because it never induces a false contention state. */ |
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 | ||
114 | if (likely(atomic_cmpxchg(count, 1, 0) == 1)) | 104 | if (likely(atomic_cmpxchg(count, 1, 0) == 1)) |
115 | return 1; | 105 | return 1; |
106 | |||
116 | return 0; | 107 | return 0; |
117 | #else | ||
118 | return fail_fn(count); | ||
119 | #endif | ||
120 | } | 108 | } |
121 | 109 | ||
122 | #endif /* _ASM_X86_MUTEX_32_H */ | 110 | #endif /* _ASM_X86_MUTEX_32_H */ |
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index 86281ffb96d6..a531f6564ed0 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c | |||
@@ -74,10 +74,6 @@ int acpi_fix_pin2_polarity __initdata; | |||
74 | static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE; | 74 | static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE; |
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | #ifndef __HAVE_ARCH_CMPXCHG | ||
78 | #warning ACPI uses CMPXCHG, i486 and later hardware | ||
79 | #endif | ||
80 | |||
81 | /* -------------------------------------------------------------------------- | 77 | /* -------------------------------------------------------------------------- |
82 | Boot-time Configuration | 78 | Boot-time Configuration |
83 | -------------------------------------------------------------------------- */ | 79 | -------------------------------------------------------------------------- */ |