aboutsummaryrefslogtreecommitdiffstats
path: root/arch/tile
diff options
context:
space:
mode:
authorChris Metcalf <cmetcalf@tilera.com>2013-02-01 12:37:48 -0500
committerChris Metcalf <cmetcalf@tilera.com>2013-03-22 15:47:00 -0400
commitadf6d9b30f089c52e674e84ca2960581e504e5e3 (patch)
treef680f2877480201116e54da1e6a1af848884d646 /arch/tile
parentef567f25d5d9d803b89bc2aec6bb71fe8b4bebd9 (diff)
tile: support atomic64_dec_if_positive()
Use the normal cmpxchg() idiom to implement this functionality. Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Diffstat (limited to 'arch/tile')
-rw-r--r--arch/tile/Kconfig1
-rw-r--r--arch/tile/include/asm/atomic.h21
2 files changed, 22 insertions, 0 deletions
diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
index 0e500d90c2a0..9a9d08637ab9 100644
--- a/arch/tile/Kconfig
+++ b/arch/tile/Kconfig
@@ -24,6 +24,7 @@ config TILE
24 select MODULES_USE_ELF_RELA 24 select MODULES_USE_ELF_RELA
25 select HAVE_ARCH_TRACEHOOK 25 select HAVE_ARCH_TRACEHOOK
26 select HAVE_SYSCALL_TRACEPOINTS 26 select HAVE_SYSCALL_TRACEPOINTS
27 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
27 28
28# FIXME: investigate whether we need/want these options. 29# FIXME: investigate whether we need/want these options.
29# select HAVE_IOREMAP_PROT 30# select HAVE_IOREMAP_PROT
diff --git a/arch/tile/include/asm/atomic.h b/arch/tile/include/asm/atomic.h
index f2461429a4a4..e71387ab20ca 100644
--- a/arch/tile/include/asm/atomic.h
+++ b/arch/tile/include/asm/atomic.h
@@ -131,4 +131,25 @@ static inline int atomic_read(const atomic_t *v)
131#include <asm/atomic_64.h> 131#include <asm/atomic_64.h>
132#endif 132#endif
133 133
134#ifndef __ASSEMBLY__
135
136static inline long long atomic64_dec_if_positive(atomic64_t *v)
137{
138 long long c, old, dec;
139
140 c = atomic64_read(v);
141 for (;;) {
142 dec = c - 1;
143 if (unlikely(dec < 0))
144 break;
145 old = atomic64_cmpxchg((v), c, dec);
146 if (likely(old == c))
147 break;
148 c = old;
149 }
150 return dec;
151}
152
153#endif /* __ASSEMBLY__ */
154
134#endif /* _ASM_TILE_ATOMIC_H */ 155#endif /* _ASM_TILE_ATOMIC_H */