diff options
Diffstat (limited to 'arch/ia64/include')
| -rw-r--r-- | arch/ia64/include/asm/cmpxchg.h | 148 | ||||
| -rw-r--r-- | arch/ia64/include/asm/dma-mapping.h | 18 | ||||
| -rw-r--r-- | arch/ia64/include/asm/futex.h | 9 | ||||
| -rw-r--r-- | arch/ia64/include/asm/intrinsics.h | 114 |
4 files changed, 165 insertions, 124 deletions
diff --git a/arch/ia64/include/asm/cmpxchg.h b/arch/ia64/include/asm/cmpxchg.h index 4c96187e2049..4f37dbbb8640 100644 --- a/arch/ia64/include/asm/cmpxchg.h +++ b/arch/ia64/include/asm/cmpxchg.h | |||
| @@ -1 +1,147 @@ | |||
| 1 | #include <asm/intrinsics.h> | 1 | #ifndef _ASM_IA64_CMPXCHG_H |
| 2 | #define _ASM_IA64_CMPXCHG_H | ||
| 3 | |||
| 4 | /* | ||
| 5 | * Compare/Exchange, forked from asm/intrinsics.h | ||
| 6 | * which was: | ||
| 7 | * | ||
| 8 | * Copyright (C) 2002-2003 Hewlett-Packard Co | ||
| 9 | * David Mosberger-Tang <davidm@hpl.hp.com> | ||
| 10 | */ | ||
| 11 | |||
| 12 | #ifndef __ASSEMBLY__ | ||
| 13 | |||
| 14 | #include <linux/types.h> | ||
| 15 | /* include compiler specific intrinsics */ | ||
| 16 | #include <asm/ia64regs.h> | ||
| 17 | #ifdef __INTEL_COMPILER | ||
| 18 | # include <asm/intel_intrin.h> | ||
| 19 | #else | ||
| 20 | # include <asm/gcc_intrin.h> | ||
| 21 | #endif | ||
| 22 | |||
| 23 | /* | ||
| 24 | * This function doesn't exist, so you'll get a linker error if | ||
| 25 | * something tries to do an invalid xchg(). | ||
| 26 | */ | ||
| 27 | extern void ia64_xchg_called_with_bad_pointer(void); | ||
| 28 | |||
| 29 | #define __xchg(x, ptr, size) \ | ||
| 30 | ({ \ | ||
| 31 | unsigned long __xchg_result; \ | ||
| 32 | \ | ||
| 33 | switch (size) { \ | ||
| 34 | case 1: \ | ||
| 35 | __xchg_result = ia64_xchg1((__u8 *)ptr, x); \ | ||
| 36 | break; \ | ||
| 37 | \ | ||
| 38 | case 2: \ | ||
| 39 | __xchg_result = ia64_xchg2((__u16 *)ptr, x); \ | ||
| 40 | break; \ | ||
| 41 | \ | ||
| 42 | case 4: \ | ||
| 43 | __xchg_result = ia64_xchg4((__u32 *)ptr, x); \ | ||
| 44 | break; \ | ||
| 45 | \ | ||
| 46 | case 8: \ | ||
| 47 | __xchg_result = ia64_xchg8((__u64 *)ptr, x); \ | ||
| 48 | break; \ | ||
| 49 | default: \ | ||
| 50 | ia64_xchg_called_with_bad_pointer(); \ | ||
| 51 | } \ | ||
| 52 | __xchg_result; \ | ||
| 53 | }) | ||
| 54 | |||
| 55 | #define xchg(ptr, x) \ | ||
| 56 | ((__typeof__(*(ptr))) __xchg((unsigned long) (x), (ptr), sizeof(*(ptr)))) | ||
| 57 | |||
| 58 | /* | ||
| 59 | * Atomic compare and exchange. Compare OLD with MEM, if identical, | ||
| 60 | * store NEW in MEM. Return the initial value in MEM. Success is | ||
| 61 | * indicated by comparing RETURN with OLD. | ||
| 62 | */ | ||
| 63 | |||
| 64 | #define __HAVE_ARCH_CMPXCHG 1 | ||
| 65 | |||
| 66 | /* | ||
| 67 | * This function doesn't exist, so you'll get a linker error | ||
| 68 | * if something tries to do an invalid cmpxchg(). | ||
| 69 | */ | ||
| 70 | extern long ia64_cmpxchg_called_with_bad_pointer(void); | ||
| 71 | |||
| 72 | #define ia64_cmpxchg(sem, ptr, old, new, size) \ | ||
| 73 | ({ \ | ||
| 74 | __u64 _o_, _r_; \ | ||
| 75 | \ | ||
| 76 | switch (size) { \ | ||
| 77 | case 1: \ | ||
| 78 | _o_ = (__u8) (long) (old); \ | ||
| 79 | break; \ | ||
| 80 | case 2: \ | ||
| 81 | _o_ = (__u16) (long) (old); \ | ||
| 82 | break; \ | ||
| 83 | case 4: \ | ||
| 84 | _o_ = (__u32) (long) (old); \ | ||
| 85 | break; \ | ||
| 86 | case 8: \ | ||
| 87 | _o_ = (__u64) (long) (old); \ | ||
| 88 | break; \ | ||
| 89 | default: \ | ||
| 90 | break; \ | ||
| 91 | } \ | ||
| 92 | switch (size) { \ | ||
| 93 | case 1: \ | ||
| 94 | _r_ = ia64_cmpxchg1_##sem((__u8 *) ptr, new, _o_); \ | ||
| 95 | break; \ | ||
| 96 | \ | ||
| 97 | case 2: \ | ||
| 98 | _r_ = ia64_cmpxchg2_##sem((__u16 *) ptr, new, _o_); \ | ||
| 99 | break; \ | ||
| 100 | \ | ||
| 101 | case 4: \ | ||
| 102 | _r_ = ia64_cmpxchg4_##sem((__u32 *) ptr, new, _o_); \ | ||
| 103 | break; \ | ||
| 104 | \ | ||
| 105 | case 8: \ | ||
| 106 | _r_ = ia64_cmpxchg8_##sem((__u64 *) ptr, new, _o_); \ | ||
| 107 | break; \ | ||
| 108 | \ | ||
| 109 | default: \ | ||
| 110 | _r_ = ia64_cmpxchg_called_with_bad_pointer(); \ | ||
| 111 | break; \ | ||
| 112 | } \ | ||
| 113 | (__typeof__(old)) _r_; \ | ||
| 114 | }) | ||
| 115 | |||
| 116 | #define cmpxchg_acq(ptr, o, n) \ | ||
| 117 | ia64_cmpxchg(acq, (ptr), (o), (n), sizeof(*(ptr))) | ||
| 118 | #define cmpxchg_rel(ptr, o, n) \ | ||
| 119 | ia64_cmpxchg(rel, (ptr), (o), (n), sizeof(*(ptr))) | ||
| 120 | |||
| 121 | /* for compatibility with other platforms: */ | ||
| 122 | #define cmpxchg(ptr, o, n) cmpxchg_acq((ptr), (o), (n)) | ||
| 123 | #define cmpxchg64(ptr, o, n) cmpxchg_acq((ptr), (o), (n)) | ||
| 124 | |||
| 125 | #define cmpxchg_local cmpxchg | ||
| 126 | #define cmpxchg64_local cmpxchg64 | ||
| 127 | |||
| 128 | #ifdef CONFIG_IA64_DEBUG_CMPXCHG | ||
| 129 | # define CMPXCHG_BUGCHECK_DECL int _cmpxchg_bugcheck_count = 128; | ||
| 130 | # define CMPXCHG_BUGCHECK(v) \ | ||
| 131 | do { \ | ||
| 132 | if (_cmpxchg_bugcheck_count-- <= 0) { \ | ||
| 133 | void *ip; \ | ||
| 134 | extern int printk(const char *fmt, ...); \ | ||
| 135 | ip = (void *) ia64_getreg(_IA64_REG_IP); \ | ||
| 136 | printk("CMPXCHG_BUGCHECK: stuck at %p on word %p\n", ip, (v));\ | ||
| 137 | break; \ | ||
| 138 | } \ | ||
| 139 | } while (0) | ||
| 140 | #else /* !CONFIG_IA64_DEBUG_CMPXCHG */ | ||
| 141 | # define CMPXCHG_BUGCHECK_DECL | ||
| 142 | # define CMPXCHG_BUGCHECK(v) | ||
| 143 | #endif /* !CONFIG_IA64_DEBUG_CMPXCHG */ | ||
| 144 | |||
| 145 | #endif /* !__ASSEMBLY__ */ | ||
| 146 | |||
| 147 | #endif /* _ASM_IA64_CMPXCHG_H */ | ||
diff --git a/arch/ia64/include/asm/dma-mapping.h b/arch/ia64/include/asm/dma-mapping.h index 4336d080b241..4f5e8148440d 100644 --- a/arch/ia64/include/asm/dma-mapping.h +++ b/arch/ia64/include/asm/dma-mapping.h | |||
| @@ -23,23 +23,29 @@ extern void machvec_dma_sync_single(struct device *, dma_addr_t, size_t, | |||
| 23 | extern void machvec_dma_sync_sg(struct device *, struct scatterlist *, int, | 23 | extern void machvec_dma_sync_sg(struct device *, struct scatterlist *, int, |
| 24 | enum dma_data_direction); | 24 | enum dma_data_direction); |
| 25 | 25 | ||
| 26 | static inline void *dma_alloc_coherent(struct device *dev, size_t size, | 26 | #define dma_alloc_coherent(d,s,h,f) dma_alloc_attrs(d,s,h,f,NULL) |
| 27 | dma_addr_t *daddr, gfp_t gfp) | 27 | |
| 28 | static inline void *dma_alloc_attrs(struct device *dev, size_t size, | ||
| 29 | dma_addr_t *daddr, gfp_t gfp, | ||
| 30 | struct dma_attrs *attrs) | ||
| 28 | { | 31 | { |
| 29 | struct dma_map_ops *ops = platform_dma_get_ops(dev); | 32 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
| 30 | void *caddr; | 33 | void *caddr; |
| 31 | 34 | ||
| 32 | caddr = ops->alloc_coherent(dev, size, daddr, gfp); | 35 | caddr = ops->alloc(dev, size, daddr, gfp, attrs); |
| 33 | debug_dma_alloc_coherent(dev, size, *daddr, caddr); | 36 | debug_dma_alloc_coherent(dev, size, *daddr, caddr); |
| 34 | return caddr; | 37 | return caddr; |
| 35 | } | 38 | } |
| 36 | 39 | ||
| 37 | static inline void dma_free_coherent(struct device *dev, size_t size, | 40 | #define dma_free_coherent(d,s,c,h) dma_free_attrs(d,s,c,h,NULL) |
| 38 | void *caddr, dma_addr_t daddr) | 41 | |
| 42 | static inline void dma_free_attrs(struct device *dev, size_t size, | ||
| 43 | void *caddr, dma_addr_t daddr, | ||
| 44 | struct dma_attrs *attrs) | ||
| 39 | { | 45 | { |
| 40 | struct dma_map_ops *ops = platform_dma_get_ops(dev); | 46 | struct dma_map_ops *ops = platform_dma_get_ops(dev); |
| 41 | debug_dma_free_coherent(dev, size, caddr, daddr); | 47 | debug_dma_free_coherent(dev, size, caddr, daddr); |
| 42 | ops->free_coherent(dev, size, caddr, daddr); | 48 | ops->free(dev, size, caddr, daddr, attrs); |
| 43 | } | 49 | } |
| 44 | 50 | ||
| 45 | #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) | 51 | #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) |
diff --git a/arch/ia64/include/asm/futex.h b/arch/ia64/include/asm/futex.h index 0ab82cc2dc8f..d2bf1fd5e44f 100644 --- a/arch/ia64/include/asm/futex.h +++ b/arch/ia64/include/asm/futex.h | |||
| @@ -106,15 +106,16 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, | |||
| 106 | return -EFAULT; | 106 | return -EFAULT; |
| 107 | 107 | ||
| 108 | { | 108 | { |
| 109 | register unsigned long r8 __asm ("r8") = 0; | 109 | register unsigned long r8 __asm ("r8"); |
| 110 | unsigned long prev; | 110 | unsigned long prev; |
| 111 | __asm__ __volatile__( | 111 | __asm__ __volatile__( |
| 112 | " mf;; \n" | 112 | " mf;; \n" |
| 113 | " mov ar.ccv=%3;; \n" | 113 | " mov %0=r0 \n" |
| 114 | "[1:] cmpxchg4.acq %0=[%1],%2,ar.ccv \n" | 114 | " mov ar.ccv=%4;; \n" |
| 115 | "[1:] cmpxchg4.acq %1=[%2],%3,ar.ccv \n" | ||
| 115 | " .xdata4 \"__ex_table\", 1b-., 2f-. \n" | 116 | " .xdata4 \"__ex_table\", 1b-., 2f-. \n" |
| 116 | "[2:]" | 117 | "[2:]" |
| 117 | : "=r" (prev) | 118 | : "=r" (r8), "=r" (prev) |
| 118 | : "r" (uaddr), "r" (newval), | 119 | : "r" (uaddr), "r" (newval), |
| 119 | "rO" ((long) (unsigned) oldval) | 120 | "rO" ((long) (unsigned) oldval) |
| 120 | : "memory"); | 121 | : "memory"); |
diff --git a/arch/ia64/include/asm/intrinsics.h b/arch/ia64/include/asm/intrinsics.h index e4076b511829..d129e367e764 100644 --- a/arch/ia64/include/asm/intrinsics.h +++ b/arch/ia64/include/asm/intrinsics.h | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #else | 18 | #else |
| 19 | # include <asm/gcc_intrin.h> | 19 | # include <asm/gcc_intrin.h> |
| 20 | #endif | 20 | #endif |
| 21 | #include <asm/cmpxchg.h> | ||
| 21 | 22 | ||
| 22 | #define ia64_native_get_psr_i() (ia64_native_getreg(_IA64_REG_PSR) & IA64_PSR_I) | 23 | #define ia64_native_get_psr_i() (ia64_native_getreg(_IA64_REG_PSR) & IA64_PSR_I) |
| 23 | 24 | ||
| @@ -81,119 +82,6 @@ extern unsigned long __bad_increment_for_ia64_fetch_and_add (void); | |||
| 81 | 82 | ||
| 82 | #define ia64_fetch_and_add(i,v) (ia64_fetchadd(i, v, rel) + (i)) /* return new value */ | 83 | #define ia64_fetch_and_add(i,v) (ia64_fetchadd(i, v, rel) + (i)) /* return new value */ |
| 83 | 84 | ||
| 84 | /* | ||
| 85 | * This function doesn't exist, so you'll get a linker error if | ||
| 86 | * something tries to do an invalid xchg(). | ||
| 87 | */ | ||
| 88 | extern void ia64_xchg_called_with_bad_pointer (void); | ||
| 89 | |||
| 90 | #define __xchg(x,ptr,size) \ | ||
| 91 | ({ \ | ||
| 92 | unsigned long __xchg_result; \ | ||
| 93 | \ | ||
| 94 | switch (size) { \ | ||
| 95 | case 1: \ | ||
| 96 | __xchg_result = ia64_xchg1((__u8 *)ptr, x); \ | ||
| 97 | break; \ | ||
| 98 | \ | ||
| 99 | case 2: \ | ||
| 100 | __xchg_result = ia64_xchg2((__u16 *)ptr, x); \ | ||
| 101 | break; \ | ||
| 102 | \ | ||
| 103 | case 4: \ | ||
| 104 | __xchg_result = ia64_xchg4((__u32 *)ptr, x); \ | ||
| 105 | break; \ | ||
| 106 | \ | ||
| 107 | case 8: \ | ||
| 108 | __xchg_result = ia64_xchg8((__u64 *)ptr, x); \ | ||
| 109 | break; \ | ||
| 110 | default: \ | ||
| 111 | ia64_xchg_called_with_bad_pointer(); \ | ||
| 112 | } \ | ||
| 113 | __xchg_result; \ | ||
| 114 | }) | ||
| 115 | |||
| 116 | #define xchg(ptr,x) \ | ||
| 117 | ((__typeof__(*(ptr))) __xchg ((unsigned long) (x), (ptr), sizeof(*(ptr)))) | ||
| 118 | |||
| 119 | /* | ||
| 120 | * Atomic compare and exchange. Compare OLD with MEM, if identical, | ||
| 121 | * store NEW in MEM. Return the initial value in MEM. Success is | ||
| 122 | * indicated by comparing RETURN with OLD. | ||
| 123 | */ | ||
| 124 | |||
| 125 | #define __HAVE_ARCH_CMPXCHG 1 | ||
| 126 | |||
| 127 | /* | ||
| 128 | * This function doesn't exist, so you'll get a linker error | ||
| 129 | * if something tries to do an invalid cmpxchg(). | ||
| 130 | */ | ||
| 131 | extern long ia64_cmpxchg_called_with_bad_pointer (void); | ||
| 132 | |||
| 133 | #define ia64_cmpxchg(sem,ptr,old,new,size) \ | ||
| 134 | ({ \ | ||
| 135 | __u64 _o_, _r_; \ | ||
| 136 | \ | ||
| 137 | switch (size) { \ | ||
| 138 | case 1: _o_ = (__u8 ) (long) (old); break; \ | ||
| 139 | case 2: _o_ = (__u16) (long) (old); break; \ | ||
| 140 | case 4: _o_ = (__u32) (long) (old); break; \ | ||
| 141 | case 8: _o_ = (__u64) (long) (old); break; \ | ||
| 142 | default: break; \ | ||
| 143 | } \ | ||
| 144 | switch (size) { \ | ||
| 145 | case 1: \ | ||
| 146 | _r_ = ia64_cmpxchg1_##sem((__u8 *) ptr, new, _o_); \ | ||
| 147 | break; \ | ||
| 148 | \ | ||
| 149 | case 2: \ | ||
| 150 | _r_ = ia64_cmpxchg2_##sem((__u16 *) ptr, new, _o_); \ | ||
| 151 | break; \ | ||
| 152 | \ | ||
| 153 | case 4: \ | ||
| 154 | _r_ = ia64_cmpxchg4_##sem((__u32 *) ptr, new, _o_); \ | ||
| 155 | break; \ | ||
| 156 | \ | ||
| 157 | case 8: \ | ||
| 158 | _r_ = ia64_cmpxchg8_##sem((__u64 *) ptr, new, _o_); \ | ||
| 159 | break; \ | ||
| 160 | \ | ||
| 161 | default: \ | ||
| 162 | _r_ = ia64_cmpxchg_called_with_bad_pointer(); \ | ||
| 163 | break; \ | ||
| 164 | } \ | ||
| 165 | (__typeof__(old)) _r_; \ | ||
| 166 | }) | ||
| 167 | |||
| 168 | #define cmpxchg_acq(ptr, o, n) \ | ||
| 169 | ia64_cmpxchg(acq, (ptr), (o), (n), sizeof(*(ptr))) | ||
| 170 | #define cmpxchg_rel(ptr, o, n) \ | ||
| 171 | ia64_cmpxchg(rel, (ptr), (o), (n), sizeof(*(ptr))) | ||
| 172 | |||
| 173 | /* for compatibility with other platforms: */ | ||
| 174 | #define cmpxchg(ptr, o, n) cmpxchg_acq((ptr), (o), (n)) | ||
| 175 | #define cmpxchg64(ptr, o, n) cmpxchg_acq((ptr), (o), (n)) | ||
| 176 | |||
| 177 | #define cmpxchg_local cmpxchg | ||
| 178 | #define cmpxchg64_local cmpxchg64 | ||
| 179 | |||
| 180 | #ifdef CONFIG_IA64_DEBUG_CMPXCHG | ||
| 181 | # define CMPXCHG_BUGCHECK_DECL int _cmpxchg_bugcheck_count = 128; | ||
| 182 | # define CMPXCHG_BUGCHECK(v) \ | ||
| 183 | do { \ | ||
| 184 | if (_cmpxchg_bugcheck_count-- <= 0) { \ | ||
| 185 | void *ip; \ | ||
| 186 | extern int printk(const char *fmt, ...); \ | ||
| 187 | ip = (void *) ia64_getreg(_IA64_REG_IP); \ | ||
| 188 | printk("CMPXCHG_BUGCHECK: stuck at %p on word %p\n", ip, (v)); \ | ||
| 189 | break; \ | ||
| 190 | } \ | ||
| 191 | } while (0) | ||
| 192 | #else /* !CONFIG_IA64_DEBUG_CMPXCHG */ | ||
| 193 | # define CMPXCHG_BUGCHECK_DECL | ||
| 194 | # define CMPXCHG_BUGCHECK(v) | ||
| 195 | #endif /* !CONFIG_IA64_DEBUG_CMPXCHG */ | ||
| 196 | |||
| 197 | #endif | 85 | #endif |
| 198 | 86 | ||
| 199 | #ifdef __KERNEL__ | 87 | #ifdef __KERNEL__ |
