aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-alpha/atomic.h
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-10-28 12:31:34 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-10-28 12:31:34 -0400
commit96b88fb850cc419171f926ad04650ec509e9f543 (patch)
tree5bf9537bde467534608b3acdbfa5f7726ede8c3f /include/asm-alpha/atomic.h
parente78a57de94480226f7fc90d0b4837bfc6c99a9e0 (diff)
parent5fadd053d9bb4345ec6f405d24db4e7eb49cf81e (diff)
Merge branch 'master'
Diffstat (limited to 'include/asm-alpha/atomic.h')
-rw-r--r--include/asm-alpha/atomic.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/include/asm-alpha/atomic.h b/include/asm-alpha/atomic.h
index 1b383e3cb68c..20ac3d95ecd9 100644
--- a/include/asm-alpha/atomic.h
+++ b/include/asm-alpha/atomic.h
@@ -1,6 +1,8 @@
1#ifndef _ALPHA_ATOMIC_H 1#ifndef _ALPHA_ATOMIC_H
2#define _ALPHA_ATOMIC_H 2#define _ALPHA_ATOMIC_H
3 3
4#include <asm/barrier.h>
5
4/* 6/*
5 * Atomic operations that C can't guarantee us. Useful for 7 * Atomic operations that C can't guarantee us. Useful for
6 * resource counting etc... 8 * resource counting etc...
@@ -100,18 +102,19 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
100static __inline__ long atomic_add_return(int i, atomic_t * v) 102static __inline__ long atomic_add_return(int i, atomic_t * v)
101{ 103{
102 long temp, result; 104 long temp, result;
105 smp_mb();
103 __asm__ __volatile__( 106 __asm__ __volatile__(
104 "1: ldl_l %0,%1\n" 107 "1: ldl_l %0,%1\n"
105 " addl %0,%3,%2\n" 108 " addl %0,%3,%2\n"
106 " addl %0,%3,%0\n" 109 " addl %0,%3,%0\n"
107 " stl_c %0,%1\n" 110 " stl_c %0,%1\n"
108 " beq %0,2f\n" 111 " beq %0,2f\n"
109 " mb\n"
110 ".subsection 2\n" 112 ".subsection 2\n"
111 "2: br 1b\n" 113 "2: br 1b\n"
112 ".previous" 114 ".previous"
113 :"=&r" (temp), "=m" (v->counter), "=&r" (result) 115 :"=&r" (temp), "=m" (v->counter), "=&r" (result)
114 :"Ir" (i), "m" (v->counter) : "memory"); 116 :"Ir" (i), "m" (v->counter) : "memory");
117 smp_mb();
115 return result; 118 return result;
116} 119}
117 120
@@ -120,54 +123,57 @@ static __inline__ long atomic_add_return(int i, atomic_t * v)
120static __inline__ long atomic64_add_return(long i, atomic64_t * v) 123static __inline__ long atomic64_add_return(long i, atomic64_t * v)
121{ 124{
122 long temp, result; 125 long temp, result;
126 smp_mb();
123 __asm__ __volatile__( 127 __asm__ __volatile__(
124 "1: ldq_l %0,%1\n" 128 "1: ldq_l %0,%1\n"
125 " addq %0,%3,%2\n" 129 " addq %0,%3,%2\n"
126 " addq %0,%3,%0\n" 130 " addq %0,%3,%0\n"
127 " stq_c %0,%1\n" 131 " stq_c %0,%1\n"
128 " beq %0,2f\n" 132 " beq %0,2f\n"
129 " mb\n"
130 ".subsection 2\n" 133 ".subsection 2\n"
131 "2: br 1b\n" 134 "2: br 1b\n"
132 ".previous" 135 ".previous"
133 :"=&r" (temp), "=m" (v->counter), "=&r" (result) 136 :"=&r" (temp), "=m" (v->counter), "=&r" (result)
134 :"Ir" (i), "m" (v->counter) : "memory"); 137 :"Ir" (i), "m" (v->counter) : "memory");
138 smp_mb();
135 return result; 139 return result;
136} 140}
137 141
138static __inline__ long atomic_sub_return(int i, atomic_t * v) 142static __inline__ long atomic_sub_return(int i, atomic_t * v)
139{ 143{
140 long temp, result; 144 long temp, result;
145 smp_mb();
141 __asm__ __volatile__( 146 __asm__ __volatile__(
142 "1: ldl_l %0,%1\n" 147 "1: ldl_l %0,%1\n"
143 " subl %0,%3,%2\n" 148 " subl %0,%3,%2\n"
144 " subl %0,%3,%0\n" 149 " subl %0,%3,%0\n"
145 " stl_c %0,%1\n" 150 " stl_c %0,%1\n"
146 " beq %0,2f\n" 151 " beq %0,2f\n"
147 " mb\n"
148 ".subsection 2\n" 152 ".subsection 2\n"
149 "2: br 1b\n" 153 "2: br 1b\n"
150 ".previous" 154 ".previous"
151 :"=&r" (temp), "=m" (v->counter), "=&r" (result) 155 :"=&r" (temp), "=m" (v->counter), "=&r" (result)
152 :"Ir" (i), "m" (v->counter) : "memory"); 156 :"Ir" (i), "m" (v->counter) : "memory");
157 smp_mb();
153 return result; 158 return result;
154} 159}
155 160
156static __inline__ long atomic64_sub_return(long i, atomic64_t * v) 161static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
157{ 162{
158 long temp, result; 163 long temp, result;
164 smp_mb();
159 __asm__ __volatile__( 165 __asm__ __volatile__(
160 "1: ldq_l %0,%1\n" 166 "1: ldq_l %0,%1\n"
161 " subq %0,%3,%2\n" 167 " subq %0,%3,%2\n"
162 " subq %0,%3,%0\n" 168 " subq %0,%3,%0\n"
163 " stq_c %0,%1\n" 169 " stq_c %0,%1\n"
164 " beq %0,2f\n" 170 " beq %0,2f\n"
165 " mb\n"
166 ".subsection 2\n" 171 ".subsection 2\n"
167 "2: br 1b\n" 172 "2: br 1b\n"
168 ".previous" 173 ".previous"
169 :"=&r" (temp), "=m" (v->counter), "=&r" (result) 174 :"=&r" (temp), "=m" (v->counter), "=&r" (result)
170 :"Ir" (i), "m" (v->counter) : "memory"); 175 :"Ir" (i), "m" (v->counter) : "memory");
176 smp_mb();
171 return result; 177 return result;
172} 178}
173 179