diff options
author | David S. Miller <davem@davemloft.net> | 2012-11-09 22:37:59 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-11-09 22:37:59 -0500 |
commit | 193d2aadc0ff5c687f6f0d5ef1d38c86ab511a14 (patch) | |
tree | 294286e259a08c977e3e71819b2c1d763b13312f /arch/sparc | |
parent | 0bce04be442cf4d6e4ba9dac2f0a4c5ee88af5c5 (diff) |
sparc: Support atomic64_dec_if_positive properly.
Sparc32 already supported it, as a consequence of using the
generic atomic64 implementation. And the sparc64 implementation
is rather trivial.
This allows us to set ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE for all
of sparc, and avoid the annoying warning from lib/atomic64_test.c
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc')
-rw-r--r-- | arch/sparc/Kconfig | 1 | ||||
-rw-r--r-- | arch/sparc/include/asm/atomic_64.h | 4 | ||||
-rw-r--r-- | arch/sparc/lib/atomic_64.S | 16 | ||||
-rw-r--r-- | arch/sparc/lib/ksyms.c | 1 |
4 files changed, 20 insertions, 2 deletions
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index b6b442b0d793..9f2edb5c5551 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig | |||
@@ -20,6 +20,7 @@ config SPARC | |||
20 | select HAVE_ARCH_TRACEHOOK | 20 | select HAVE_ARCH_TRACEHOOK |
21 | select SYSCTL_EXCEPTION_TRACE | 21 | select SYSCTL_EXCEPTION_TRACE |
22 | select ARCH_WANT_OPTIONAL_GPIOLIB | 22 | select ARCH_WANT_OPTIONAL_GPIOLIB |
23 | select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE | ||
23 | select RTC_CLASS | 24 | select RTC_CLASS |
24 | select RTC_DRV_M48T59 | 25 | select RTC_DRV_M48T59 |
25 | select HAVE_IRQ_WORK | 26 | select HAVE_IRQ_WORK |
diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h index ce35a1cf1a20..be56a244c9cf 100644 --- a/arch/sparc/include/asm/atomic_64.h +++ b/arch/sparc/include/asm/atomic_64.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* atomic.h: Thankfully the V9 is at least reasonable for this | 1 | /* atomic.h: Thankfully the V9 is at least reasonable for this |
2 | * stuff. | 2 | * stuff. |
3 | * | 3 | * |
4 | * Copyright (C) 1996, 1997, 2000 David S. Miller (davem@redhat.com) | 4 | * Copyright (C) 1996, 1997, 2000, 2012 David S. Miller (davem@redhat.com) |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #ifndef __ARCH_SPARC64_ATOMIC__ | 7 | #ifndef __ARCH_SPARC64_ATOMIC__ |
@@ -106,6 +106,8 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u) | |||
106 | 106 | ||
107 | #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0) | 107 | #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0) |
108 | 108 | ||
109 | extern long atomic64_dec_if_positive(atomic64_t *v); | ||
110 | |||
109 | /* Atomic operations are already serializing */ | 111 | /* Atomic operations are already serializing */ |
110 | #define smp_mb__before_atomic_dec() barrier() | 112 | #define smp_mb__before_atomic_dec() barrier() |
111 | #define smp_mb__after_atomic_dec() barrier() | 113 | #define smp_mb__after_atomic_dec() barrier() |
diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S index 4d502da3de78..85c233d0a340 100644 --- a/arch/sparc/lib/atomic_64.S +++ b/arch/sparc/lib/atomic_64.S | |||
@@ -1,6 +1,6 @@ | |||
1 | /* atomic.S: These things are too big to do inline. | 1 | /* atomic.S: These things are too big to do inline. |
2 | * | 2 | * |
3 | * Copyright (C) 1999, 2007 David S. Miller (davem@davemloft.net) | 3 | * Copyright (C) 1999, 2007 2012 David S. Miller (davem@davemloft.net) |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <linux/linkage.h> | 6 | #include <linux/linkage.h> |
@@ -117,3 +117,17 @@ ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */ | |||
117 | sub %g1, %o0, %o0 | 117 | sub %g1, %o0, %o0 |
118 | 2: BACKOFF_SPIN(%o2, %o3, 1b) | 118 | 2: BACKOFF_SPIN(%o2, %o3, 1b) |
119 | ENDPROC(atomic64_sub_ret) | 119 | ENDPROC(atomic64_sub_ret) |
120 | |||
121 | ENTRY(atomic64_dec_if_positive) /* %o0 = atomic_ptr */ | ||
122 | BACKOFF_SETUP(%o2) | ||
123 | 1: ldx [%o0], %g1 | ||
124 | brlez,pn %g1, 3f | ||
125 | sub %g1, 1, %g7 | ||
126 | casx [%o0], %g1, %g7 | ||
127 | cmp %g1, %g7 | ||
128 | bne,pn %xcc, BACKOFF_LABEL(2f, 1b) | ||
129 | nop | ||
130 | 3: retl | ||
131 | sub %g1, 1, %o0 | ||
132 | 2: BACKOFF_SPIN(%o2, %o3, 1b) | ||
133 | ENDPROC(atomic64_dec_if_positive) | ||
diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c index ee31b884c61b..0c4e35e522fa 100644 --- a/arch/sparc/lib/ksyms.c +++ b/arch/sparc/lib/ksyms.c | |||
@@ -116,6 +116,7 @@ EXPORT_SYMBOL(atomic64_add); | |||
116 | EXPORT_SYMBOL(atomic64_add_ret); | 116 | EXPORT_SYMBOL(atomic64_add_ret); |
117 | EXPORT_SYMBOL(atomic64_sub); | 117 | EXPORT_SYMBOL(atomic64_sub); |
118 | EXPORT_SYMBOL(atomic64_sub_ret); | 118 | EXPORT_SYMBOL(atomic64_sub_ret); |
119 | EXPORT_SYMBOL(atomic64_dec_if_positive); | ||
119 | 120 | ||
120 | /* Atomic bit operations. */ | 121 | /* Atomic bit operations. */ |
121 | EXPORT_SYMBOL(test_and_set_bit); | 122 | EXPORT_SYMBOL(test_and_set_bit); |