Skip to content

Commit fbb3dce

Browse files
committed
fix atomic operation and spinlock bug
Signed-off-by: liuyuncheng <[email protected]>
1 parent 67026ef commit fbb3dce

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

opal/include/opal/sys/arm64/atomic.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ static inline bool opal_atomic_compare_exchange_strong_32(opal_atomic_int32_t *a
7070
int32_t prev, tmp;
7171
bool ret;
7272

73-
__asm__ __volatile__("1: ldaxr %w0, [%2] \n"
73+
__asm__ __volatile__("1: ldaxr %w0, [%2] \n"
7474
" cmp %w0, %w3 \n"
7575
" bne 2f \n"
76-
" stxr %w1, %w4, [%2] \n"
76+
" stlxr %w1, %w4, [%2] \n"
7777
" cbnz %w1, 1b \n"
7878
"2: \n"
7979
: "=&r"(prev), "=&r"(tmp)
@@ -99,7 +99,7 @@ static inline bool opal_atomic_compare_exchange_strong_acq_32(opal_atomic_int32_
9999
__asm__ __volatile__("1: ldaxr %w0, [%2] \n"
100100
" cmp %w0, %w3 \n"
101101
" bne 2f \n"
102-
" stxr %w1, %w4, [%2] \n"
102+
" stlxr %w1, %w4, [%2] \n"
103103
" cbnz %w1, 1b \n"
104104
"2: \n"
105105
: "=&r"(prev), "=&r"(tmp)
@@ -117,7 +117,7 @@ static inline bool opal_atomic_compare_exchange_strong_rel_32(opal_atomic_int32_
117117
int32_t prev, tmp;
118118
bool ret;
119119

120-
__asm__ __volatile__("1: ldxr %w0, [%2] \n"
120+
__asm__ __volatile__("1: ldaxr %w0, [%2] \n"
121121
" cmp %w0, %w3 \n"
122122
" bne 2f \n"
123123
" stlxr %w1, %w4, [%2] \n"
@@ -139,10 +139,10 @@ static inline bool opal_atomic_compare_exchange_strong_64(opal_atomic_int64_t *a
139139
int tmp;
140140
bool ret;
141141

142-
__asm__ __volatile__("1: ldaxr %0, [%2] \n"
142+
__asm__ __volatile__("1: ldaxr %0, [%2] \n"
143143
" cmp %0, %3 \n"
144144
" bne 2f \n"
145-
" stxr %w1, %4, [%2] \n"
145+
" stlxr %w1, %4, [%2] \n"
146146
" cbnz %w1, 1b \n"
147147
"2: \n"
148148
: "=&r"(prev), "=&r"(tmp)
@@ -169,7 +169,7 @@ static inline bool opal_atomic_compare_exchange_strong_acq_64(opal_atomic_int64_
169169
__asm__ __volatile__("1: ldaxr %0, [%2] \n"
170170
" cmp %0, %3 \n"
171171
" bne 2f \n"
172-
" stxr %w1, %4, [%2] \n"
172+
" stlxr %w1, %4, [%2] \n"
173173
" cbnz %w1, 1b \n"
174174
"2: \n"
175175
: "=&r"(prev), "=&r"(tmp)
@@ -188,7 +188,7 @@ static inline bool opal_atomic_compare_exchange_strong_rel_64(opal_atomic_int64_
188188
int tmp;
189189
bool ret;
190190

191-
__asm__ __volatile__("1: ldxr %0, [%2] \n"
191+
__asm__ __volatile__("1: ldaxr %0, [%2] \n"
192192
" cmp %0, %3 \n"
193193
" bne 2f \n"
194194
" stlxr %w1, %4, [%2] \n"
@@ -266,9 +266,9 @@ static inline int64_t opal_atomic_swap_64(opal_atomic_int64_t *addr, int64_t new
266266
type newval, old; \
267267
int32_t tmp; \
268268
\
269-
__asm__ __volatile__("1: ldxr %" reg "1, [%3] \n" \
269+
__asm__ __volatile__("1: ldaxr %" reg "1, [%3] \n" \
270270
" " inst " %" reg "0, %" reg "1, %" reg "4 \n" \
271-
" stxr %w2, %" reg "0, [%3] \n" \
271+
" stlxr %w2, %" reg "0, [%3] \n" \
272272
" cbnz %w2, 1b \n" \
273273
: "=&r"(newval), "=&r"(old), "=&r"(tmp) \
274274
: "r"(addr), "r"(value) \
@@ -282,9 +282,9 @@ static inline int64_t opal_atomic_swap_64(opal_atomic_int64_t *addr, int64_t new
282282
type newval, old; \
283283
int32_t tmp; \
284284
\
285-
__asm__ __volatile__("1: ldxr %" reg "1, [%3] \n" \
285+
__asm__ __volatile__("1: ldaxr %" reg "1, [%3] \n" \
286286
" " inst " %" reg "0, %" reg "1, %" reg "4 \n" \
287-
" stxr %w2, %" reg "0, [%3] \n" \
287+
" stlxr %w2, %" reg "0, [%3] \n" \
288288
" cbnz %w2, 1b \n" \
289289
: "=&r"(newval), "=&r"(old), "=&r"(tmp) \
290290
: "r"(addr), "r"(value) \

0 commit comments

Comments
 (0)