diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-23 13:35:43 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-23 13:35:43 -0400 |
| commit | 148a7b1725b3ca89ee13e410eec10ce2c2094d9b (patch) | |
| tree | cdddea55ba65c1c090d13b91e1b9965b5d30419b | |
| parent | 9d0715630ebf7bf70daa5e6d8db0e3061268c61e (diff) | |
| parent | 3824abd1279ef75f791c43a6b1e3162ae0692b42 (diff) | |
Merge branch 'x86-atomic-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'x86-atomic-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
x86: Add support for cmpxchg_double
| -rw-r--r-- | arch/x86/Kconfig.cpu | 3 | ||||
| -rw-r--r-- | arch/x86/include/asm/cmpxchg_32.h | 48 | ||||
| -rw-r--r-- | arch/x86/include/asm/cmpxchg_64.h | 45 | ||||
| -rw-r--r-- | arch/x86/include/asm/cpufeature.h | 2 |
4 files changed, 98 insertions, 0 deletions
diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu index 6a7cfdf8ff69..e3ca7e0d858c 100644 --- a/arch/x86/Kconfig.cpu +++ b/arch/x86/Kconfig.cpu | |||
| @@ -312,6 +312,9 @@ config X86_CMPXCHG | |||
| 312 | config CMPXCHG_LOCAL | 312 | config CMPXCHG_LOCAL |
| 313 | def_bool X86_64 || (X86_32 && !M386) | 313 | def_bool X86_64 || (X86_32 && !M386) |
| 314 | 314 | ||
| 315 | config CMPXCHG_DOUBLE | ||
| 316 | def_bool y | ||
| 317 | |||
| 315 | config X86_L1_CACHE_SHIFT | 318 | config X86_L1_CACHE_SHIFT |
| 316 | int | 319 | int |
| 317 | default "7" if MPENTIUM4 || MPSC | 320 | default "7" if MPENTIUM4 || MPSC |
diff --git a/arch/x86/include/asm/cmpxchg_32.h b/arch/x86/include/asm/cmpxchg_32.h index 284a6e8f7ce1..3deb7250624c 100644 --- a/arch/x86/include/asm/cmpxchg_32.h +++ b/arch/x86/include/asm/cmpxchg_32.h | |||
| @@ -280,4 +280,52 @@ static inline unsigned long cmpxchg_386(volatile void *ptr, unsigned long old, | |||
| 280 | 280 | ||
| 281 | #endif | 281 | #endif |
| 282 | 282 | ||
| 283 | #define cmpxchg8b(ptr, o1, o2, n1, n2) \ | ||
| 284 | ({ \ | ||
| 285 | char __ret; \ | ||
| 286 | __typeof__(o2) __dummy; \ | ||
| 287 | __typeof__(*(ptr)) __old1 = (o1); \ | ||
| 288 | __typeof__(o2) __old2 = (o2); \ | ||
| 289 | __typeof__(*(ptr)) __new1 = (n1); \ | ||
| 290 | __typeof__(o2) __new2 = (n2); \ | ||
| 291 | asm volatile(LOCK_PREFIX "cmpxchg8b %2; setz %1" \ | ||
| 292 | : "=d"(__dummy), "=a" (__ret), "+m" (*ptr)\ | ||
| 293 | : "a" (__old1), "d"(__old2), \ | ||
| 294 | "b" (__new1), "c" (__new2) \ | ||
| 295 | : "memory"); \ | ||
| 296 | __ret; }) | ||
| 297 | |||
| 298 | |||
| 299 | #define cmpxchg8b_local(ptr, o1, o2, n1, n2) \ | ||
| 300 | ({ \ | ||
| 301 | char __ret; \ | ||
| 302 | __typeof__(o2) __dummy; \ | ||
| 303 | __typeof__(*(ptr)) __old1 = (o1); \ | ||
| 304 | __typeof__(o2) __old2 = (o2); \ | ||
| 305 | __typeof__(*(ptr)) __new1 = (n1); \ | ||
| 306 | __typeof__(o2) __new2 = (n2); \ | ||
| 307 | asm volatile("cmpxchg8b %2; setz %1" \ | ||
| 308 | : "=d"(__dummy), "=a"(__ret), "+m" (*ptr)\ | ||
| 309 | : "a" (__old), "d"(__old2), \ | ||
| 310 | "b" (__new1), "c" (__new2), \ | ||
| 311 | : "memory"); \ | ||
| 312 | __ret; }) | ||
| 313 | |||
| 314 | |||
| 315 | #define cmpxchg_double(ptr, o1, o2, n1, n2) \ | ||
| 316 | ({ \ | ||
| 317 | BUILD_BUG_ON(sizeof(*(ptr)) != 4); \ | ||
| 318 | VM_BUG_ON((unsigned long)(ptr) % 8); \ | ||
| 319 | cmpxchg8b((ptr), (o1), (o2), (n1), (n2)); \ | ||
| 320 | }) | ||
| 321 | |||
| 322 | #define cmpxchg_double_local(ptr, o1, o2, n1, n2) \ | ||
| 323 | ({ \ | ||
| 324 | BUILD_BUG_ON(sizeof(*(ptr)) != 4); \ | ||
| 325 | VM_BUG_ON((unsigned long)(ptr) % 8); \ | ||
| 326 | cmpxchg16b_local((ptr), (o1), (o2), (n1), (n2)); \ | ||
| 327 | }) | ||
| 328 | |||
| 329 | #define system_has_cmpxchg_double() cpu_has_cx8 | ||
| 330 | |||
| 283 | #endif /* _ASM_X86_CMPXCHG_32_H */ | 331 | #endif /* _ASM_X86_CMPXCHG_32_H */ |
diff --git a/arch/x86/include/asm/cmpxchg_64.h b/arch/x86/include/asm/cmpxchg_64.h index 423ae58aa020..7cf5c0a24434 100644 --- a/arch/x86/include/asm/cmpxchg_64.h +++ b/arch/x86/include/asm/cmpxchg_64.h | |||
| @@ -151,4 +151,49 @@ extern void __cmpxchg_wrong_size(void); | |||
| 151 | cmpxchg_local((ptr), (o), (n)); \ | 151 | cmpxchg_local((ptr), (o), (n)); \ |
| 152 | }) | 152 | }) |
| 153 | 153 | ||
| 154 | #define cmpxchg16b(ptr, o1, o2, n1, n2) \ | ||
| 155 | ({ \ | ||
| 156 | char __ret; \ | ||
| 157 | __typeof__(o2) __junk; \ | ||
| 158 | __typeof__(*(ptr)) __old1 = (o1); \ | ||
| 159 | __typeof__(o2) __old2 = (o2); \ | ||
| 160 | __typeof__(*(ptr)) __new1 = (n1); \ | ||
| 161 | __typeof__(o2) __new2 = (n2); \ | ||
| 162 | asm volatile(LOCK_PREFIX "cmpxchg16b %2;setz %1" \ | ||
| 163 | : "=d"(__junk), "=a"(__ret), "+m" (*ptr) \ | ||
| 164 | : "b"(__new1), "c"(__new2), \ | ||
| 165 | "a"(__old1), "d"(__old2)); \ | ||
| 166 | __ret; }) | ||
| 167 | |||
| 168 | |||
| 169 | #define cmpxchg16b_local(ptr, o1, o2, n1, n2) \ | ||
| 170 | ({ \ | ||
| 171 | char __ret; \ | ||
| 172 | __typeof__(o2) __junk; \ | ||
| 173 | __typeof__(*(ptr)) __old1 = (o1); \ | ||
| 174 | __typeof__(o2) __old2 = (o2); \ | ||
| 175 | __typeof__(*(ptr)) __new1 = (n1); \ | ||
| 176 | __typeof__(o2) __new2 = (n2); \ | ||
| 177 | asm volatile("cmpxchg16b %2;setz %1" \ | ||
| 178 | : "=d"(__junk), "=a"(__ret), "+m" (*ptr) \ | ||
| 179 | : "b"(__new1), "c"(__new2), \ | ||
| 180 | "a"(__old1), "d"(__old2)); \ | ||
| 181 | __ret; }) | ||
| 182 | |||
| 183 | #define cmpxchg_double(ptr, o1, o2, n1, n2) \ | ||
| 184 | ({ \ | ||
| 185 | BUILD_BUG_ON(sizeof(*(ptr)) != 8); \ | ||
| 186 | VM_BUG_ON((unsigned long)(ptr) % 16); \ | ||
| 187 | cmpxchg16b((ptr), (o1), (o2), (n1), (n2)); \ | ||
| 188 | }) | ||
| 189 | |||
| 190 | #define cmpxchg_double_local(ptr, o1, o2, n1, n2) \ | ||
| 191 | ({ \ | ||
| 192 | BUILD_BUG_ON(sizeof(*(ptr)) != 8); \ | ||
| 193 | VM_BUG_ON((unsigned long)(ptr) % 16); \ | ||
| 194 | cmpxchg16b_local((ptr), (o1), (o2), (n1), (n2)); \ | ||
| 195 | }) | ||
| 196 | |||
| 197 | #define system_has_cmpxchg_double() cpu_has_cx16 | ||
| 198 | |||
| 154 | #endif /* _ASM_X86_CMPXCHG_64_H */ | 199 | #endif /* _ASM_X86_CMPXCHG_64_H */ |
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index 9929b35929ff..4258aac99a6e 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h | |||
| @@ -288,6 +288,8 @@ extern const char * const x86_power_flags[32]; | |||
| 288 | #define cpu_has_hypervisor boot_cpu_has(X86_FEATURE_HYPERVISOR) | 288 | #define cpu_has_hypervisor boot_cpu_has(X86_FEATURE_HYPERVISOR) |
| 289 | #define cpu_has_pclmulqdq boot_cpu_has(X86_FEATURE_PCLMULQDQ) | 289 | #define cpu_has_pclmulqdq boot_cpu_has(X86_FEATURE_PCLMULQDQ) |
| 290 | #define cpu_has_perfctr_core boot_cpu_has(X86_FEATURE_PERFCTR_CORE) | 290 | #define cpu_has_perfctr_core boot_cpu_has(X86_FEATURE_PERFCTR_CORE) |
| 291 | #define cpu_has_cx8 boot_cpu_has(X86_FEATURE_CX8) | ||
| 292 | #define cpu_has_cx16 boot_cpu_has(X86_FEATURE_CX16) | ||
| 291 | 293 | ||
| 292 | #if defined(CONFIG_X86_INVLPG) || defined(CONFIG_X86_64) | 294 | #if defined(CONFIG_X86_INVLPG) || defined(CONFIG_X86_64) |
| 293 | # define cpu_has_invlpg 1 | 295 | # define cpu_has_invlpg 1 |
