aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/tile/include/asm/atomic.h52
-rw-r--r--arch/tile/include/asm/atomic_32.h85
-rw-r--r--arch/tile/include/asm/atomic_64.h42
-rw-r--r--arch/tile/include/asm/bitops_32.h2
-rw-r--r--arch/tile/include/asm/bitops_64.h8
-rw-r--r--arch/tile/include/asm/cmpxchg.h97
-rw-r--r--arch/tile/lib/atomic_32.c34
7 files changed, 156 insertions, 164 deletions
diff --git a/arch/tile/include/asm/atomic.h b/arch/tile/include/asm/atomic.h
index e71387ab20ca..d385eaadece7 100644
--- a/arch/tile/include/asm/atomic.h
+++ b/arch/tile/include/asm/atomic.h
@@ -114,6 +114,32 @@ static inline int atomic_read(const atomic_t *v)
114#define atomic_inc_and_test(v) (atomic_inc_return(v) == 0) 114#define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
115 115
116/** 116/**
117 * atomic_xchg - atomically exchange contents of memory with a new value
118 * @v: pointer of type atomic_t
119 * @i: integer value to store in memory
120 *
121 * Atomically sets @v to @i and returns old @v
122 */
123static inline int atomic_xchg(atomic_t *v, int n)
124{
125 return xchg(&v->counter, n);
126}
127
128/**
129 * atomic_cmpxchg - atomically exchange contents of memory if it matches
130 * @v: pointer of type atomic_t
131 * @o: old value that memory should have
132 * @n: new value to write to memory if it matches
133 *
134 * Atomically checks if @v holds @o and replaces it with @n if so.
135 * Returns the old value at @v.
136 */
137static inline int atomic_cmpxchg(atomic_t *v, int o, int n)
138{
139 return cmpxchg(&v->counter, o, n);
140}
141
142/**
117 * atomic_add_negative - add and test if negative 143 * atomic_add_negative - add and test if negative
118 * @v: pointer of type atomic_t 144 * @v: pointer of type atomic_t
119 * @i: integer value to add 145 * @i: integer value to add
@@ -133,6 +159,32 @@ static inline int atomic_read(const atomic_t *v)
133 159
134#ifndef __ASSEMBLY__ 160#ifndef __ASSEMBLY__
135 161
162/**
163 * atomic64_xchg - atomically exchange contents of memory with a new value
164 * @v: pointer of type atomic64_t
165 * @i: integer value to store in memory
166 *
167 * Atomically sets @v to @i and returns old @v
168 */
169static inline u64 atomic64_xchg(atomic64_t *v, u64 n)
170{
171 return xchg64(&v->counter, n);
172}
173
174/**
175 * atomic64_cmpxchg - atomically exchange contents of memory if it matches
176 * @v: pointer of type atomic64_t
177 * @o: old value that memory should have
178 * @n: new value to write to memory if it matches
179 *
180 * Atomically checks if @v holds @o and replaces it with @n if so.
181 * Returns the old value at @v.
182 */
183static inline u64 atomic64_cmpxchg(atomic64_t *v, u64 o, u64 n)
184{
185 return cmpxchg64(&v->counter, o, n);
186}
187
136static inline long long atomic64_dec_if_positive(atomic64_t *v) 188static inline long long atomic64_dec_if_positive(atomic64_t *v)
137{ 189{
138 long long c, old, dec; 190 long long c, old, dec;
diff --git a/arch/tile/include/asm/atomic_32.h b/arch/tile/include/asm/atomic_32.h
index 96156f5ba640..0d0395b1b152 100644
--- a/arch/tile/include/asm/atomic_32.h
+++ b/arch/tile/include/asm/atomic_32.h
@@ -22,40 +22,6 @@
22 22
23#ifndef __ASSEMBLY__ 23#ifndef __ASSEMBLY__
24 24
25/* Tile-specific routines to support <linux/atomic.h>. */
26int _atomic_xchg(atomic_t *v, int n);
27int _atomic_xchg_add(atomic_t *v, int i);
28int _atomic_xchg_add_unless(atomic_t *v, int a, int u);
29int _atomic_cmpxchg(atomic_t *v, int o, int n);
30
31/**
32 * atomic_xchg - atomically exchange contents of memory with a new value
33 * @v: pointer of type atomic_t
34 * @i: integer value to store in memory
35 *
36 * Atomically sets @v to @i and returns old @v
37 */
38static inline int atomic_xchg(atomic_t *v, int n)
39{
40 smp_mb(); /* barrier for proper semantics */
41 return _atomic_xchg(v, n);
42}
43
44/**
45 * atomic_cmpxchg - atomically exchange contents of memory if it matches
46 * @v: pointer of type atomic_t
47 * @o: old value that memory should have
48 * @n: new value to write to memory if it matches
49 *
50 * Atomically checks if @v holds @o and replaces it with @n if so.
51 * Returns the old value at @v.
52 */
53static inline int atomic_cmpxchg(atomic_t *v, int o, int n)
54{
55 smp_mb(); /* barrier for proper semantics */
56 return _atomic_cmpxchg(v, o, n);
57}
58
59/** 25/**
60 * atomic_add - add integer to atomic variable 26 * atomic_add - add integer to atomic variable
61 * @i: integer value to add 27 * @i: integer value to add
@@ -65,7 +31,7 @@ static inline int atomic_cmpxchg(atomic_t *v, int o, int n)
65 */ 31 */
66static inline void atomic_add(int i, atomic_t *v) 32static inline void atomic_add(int i, atomic_t *v)
67{ 33{
68 _atomic_xchg_add(v, i); 34 _atomic_xchg_add(&v->counter, i);
69} 35}
70 36
71/** 37/**
@@ -78,7 +44,7 @@ static inline void atomic_add(int i, atomic_t *v)
78static inline int atomic_add_return(int i, atomic_t *v) 44static inline int atomic_add_return(int i, atomic_t *v)
79{ 45{
80 smp_mb(); /* barrier for proper semantics */ 46 smp_mb(); /* barrier for proper semantics */
81 return _atomic_xchg_add(v, i) + i; 47 return _atomic_xchg_add(&v->counter, i) + i;
82} 48}
83 49
84/** 50/**
@@ -93,7 +59,7 @@ static inline int atomic_add_return(int i, atomic_t *v)
93static inline int __atomic_add_unless(atomic_t *v, int a, int u) 59static inline int __atomic_add_unless(atomic_t *v, int a, int u)
94{ 60{
95 smp_mb(); /* barrier for proper semantics */ 61 smp_mb(); /* barrier for proper semantics */
96 return _atomic_xchg_add_unless(v, a, u); 62 return _atomic_xchg_add_unless(&v->counter, a, u);
97} 63}
98 64
99/** 65/**
@@ -108,7 +74,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
108 */ 74 */
109static inline void atomic_set(atomic_t *v, int n) 75static inline void atomic_set(atomic_t *v, int n)
110{ 76{
111 _atomic_xchg(v, n); 77 _atomic_xchg(&v->counter, n);
112} 78}
113 79
114/* A 64bit atomic type */ 80/* A 64bit atomic type */
@@ -119,11 +85,6 @@ typedef struct {
119 85
120#define ATOMIC64_INIT(val) { (val) } 86#define ATOMIC64_INIT(val) { (val) }
121 87
122u64 _atomic64_xchg(atomic64_t *v, u64 n);
123u64 _atomic64_xchg_add(atomic64_t *v, u64 i);
124u64 _atomic64_xchg_add_unless(atomic64_t *v, u64 a, u64 u);
125u64 _atomic64_cmpxchg(atomic64_t *v, u64 o, u64 n);
126
127/** 88/**
128 * atomic64_read - read atomic variable 89 * atomic64_read - read atomic variable
129 * @v: pointer of type atomic64_t 90 * @v: pointer of type atomic64_t
@@ -137,35 +98,7 @@ static inline u64 atomic64_read(const atomic64_t *v)
137 * Casting away const is safe since the atomic support routines 98 * Casting away const is safe since the atomic support routines
138 * do not write to memory if the value has not been modified. 99 * do not write to memory if the value has not been modified.
139 */ 100 */
140 return _atomic64_xchg_add((atomic64_t *)v, 0); 101 return _atomic64_xchg_add((u64 *)&v->counter, 0);
141}
142
143/**
144 * atomic64_xchg - atomically exchange contents of memory with a new value
145 * @v: pointer of type atomic64_t
146 * @i: integer value to store in memory
147 *
148 * Atomically sets @v to @i and returns old @v