]> bbs.cooldavid.org Git - net-next-2.6.git/blame - arch/sparc/lib/atomic_64.S
Merge branch 'for-linus' of git://android.git.kernel.org/kernel/tegra
[net-next-2.6.git] / arch / sparc / lib / atomic_64.S
CommitLineData
24f287e4 1/* atomic.S: These things are too big to do inline.
1da177e4 2 *
24f287e4 3 * Copyright (C) 1999, 2007 David S. Miller (davem@davemloft.net)
1da177e4
LT
4 */
5
1da177e4 6#include <asm/asi.h>
24f287e4 7#include <asm/backoff.h>
1da177e4 8
1da177e4
LT
9 .text
10
11 /* Two versions of the atomic routines, one that
12 * does not return a value and does not perform
13 * memory barriers, and a second which returns
14 * a value and does the barriers.
15 */
16 .globl atomic_add
17 .type atomic_add,#function
18atomic_add: /* %o0 = increment, %o1 = atomic_ptr */
24f287e4 19 BACKOFF_SETUP(%o2)
1da177e4
LT
201: lduw [%o1], %g1
21 add %g1, %o0, %g7
22 cas [%o1], %g1, %g7
23 cmp %g1, %g7
0f58189d 24 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
1da177e4
LT
25 nop
26 retl
27 nop
24f287e4 282: BACKOFF_SPIN(%o2, %o3, 1b)
1da177e4
LT
29 .size atomic_add, .-atomic_add
30
31 .globl atomic_sub
32 .type atomic_sub,#function
33atomic_sub: /* %o0 = decrement, %o1 = atomic_ptr */
24f287e4 34 BACKOFF_SETUP(%o2)
1da177e4
LT
351: lduw [%o1], %g1
36 sub %g1, %o0, %g7
37 cas [%o1], %g1, %g7
38 cmp %g1, %g7
0f58189d 39 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
1da177e4
LT
40 nop
41 retl
42 nop
24f287e4 432: BACKOFF_SPIN(%o2, %o3, 1b)
1da177e4
LT
44 .size atomic_sub, .-atomic_sub
45
46 .globl atomic_add_ret
47 .type atomic_add_ret,#function
48atomic_add_ret: /* %o0 = increment, %o1 = atomic_ptr */
24f287e4 49 BACKOFF_SETUP(%o2)
1da177e4
LT
501: lduw [%o1], %g1
51 add %g1, %o0, %g7
52 cas [%o1], %g1, %g7
53 cmp %g1, %g7
0f58189d 54 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
6ec27475 55 add %g1, %o0, %g1
1da177e4 56 retl
6ec27475 57 sra %g1, 0, %o0
24f287e4 582: BACKOFF_SPIN(%o2, %o3, 1b)
1da177e4
LT
59 .size atomic_add_ret, .-atomic_add_ret
60
61 .globl atomic_sub_ret
62 .type atomic_sub_ret,#function
63atomic_sub_ret: /* %o0 = decrement, %o1 = atomic_ptr */
24f287e4 64 BACKOFF_SETUP(%o2)
1da177e4
LT
651: lduw [%o1], %g1
66 sub %g1, %o0, %g7
67 cas [%o1], %g1, %g7
68 cmp %g1, %g7
0f58189d 69 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
6ec27475 70 sub %g1, %o0, %g1
1da177e4 71 retl
6ec27475 72 sra %g1, 0, %o0
24f287e4 732: BACKOFF_SPIN(%o2, %o3, 1b)
1da177e4
LT
74 .size atomic_sub_ret, .-atomic_sub_ret
75
76 .globl atomic64_add
77 .type atomic64_add,#function
78atomic64_add: /* %o0 = increment, %o1 = atomic_ptr */
24f287e4 79 BACKOFF_SETUP(%o2)
1da177e4
LT
801: ldx [%o1], %g1
81 add %g1, %o0, %g7
82 casx [%o1], %g1, %g7
83 cmp %g1, %g7
0f58189d 84 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
1da177e4
LT
85 nop
86 retl
87 nop
24f287e4 882: BACKOFF_SPIN(%o2, %o3, 1b)
1da177e4
LT
89 .size atomic64_add, .-atomic64_add
90
91 .globl atomic64_sub
92 .type atomic64_sub,#function
93atomic64_sub: /* %o0 = decrement, %o1 = atomic_ptr */
24f287e4 94 BACKOFF_SETUP(%o2)
1da177e4
LT
951: ldx [%o1], %g1
96 sub %g1, %o0, %g7
97 casx [%o1], %g1, %g7
98 cmp %g1, %g7
0f58189d 99 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
1da177e4
LT
100 nop
101 retl
102 nop
24f287e4 1032: BACKOFF_SPIN(%o2, %o3, 1b)
1da177e4
LT
104 .size atomic64_sub, .-atomic64_sub
105
106 .globl atomic64_add_ret
107 .type atomic64_add_ret,#function
108atomic64_add_ret: /* %o0 = increment, %o1 = atomic_ptr */
24f287e4 109 BACKOFF_SETUP(%o2)
1da177e4
LT
1101: ldx [%o1], %g1
111 add %g1, %o0, %g7
112 casx [%o1], %g1, %g7
113 cmp %g1, %g7
0f58189d 114 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
b445e26c 115 nop
6ec27475
MP
116 retl
117 add %g1, %o0, %o0
24f287e4 1182: BACKOFF_SPIN(%o2, %o3, 1b)
1da177e4
LT
119 .size atomic64_add_ret, .-atomic64_add_ret
120
121 .globl atomic64_sub_ret
122 .type atomic64_sub_ret,#function
123atomic64_sub_ret: /* %o0 = decrement, %o1 = atomic_ptr */
24f287e4 124 BACKOFF_SETUP(%o2)
1da177e4
LT
1251: ldx [%o1], %g1
126 sub %g1, %o0, %g7
127 casx [%o1], %g1, %g7
128 cmp %g1, %g7
0f58189d 129 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
b445e26c 130 nop
6ec27475
MP
131 retl
132 sub %g1, %o0, %o0
24f287e4 1332: BACKOFF_SPIN(%o2, %o3, 1b)
1da177e4 134 .size atomic64_sub_ret, .-atomic64_sub_ret