]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ARM: 7854/1: lockref: add support for lockless lockrefs using cmpxchg64
authorWill Deacon <will.deacon@arm.com>
Wed, 9 Oct 2013 16:19:22 +0000 (17:19 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Mon, 14 Oct 2013 15:18:12 +0000 (16:18 +0100)
Our spinlocks are only 32-bit (2x16-bit tickets) and, on processors
with 64-bit atomic instructions, cmpxchg64 makes use of the double-word
exclusive accessors.

This patch wires up the cmpxchg-based lockless lockref implementation
for ARM.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/Kconfig
arch/arm/include/asm/spinlock.h

index 3f7714d8d2d216bf3bbd7b4a5b227ea982997554..d2cc20a512770e80bfc77fdcab03dde0aa55d5ce 100644 (file)
@@ -5,6 +5,7 @@ config ARM
        select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
        select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
        select ARCH_HAVE_CUSTOM_GPIO_H
+       select ARCH_USE_CMPXCHG_LOCKREF
        select ARCH_WANT_IPC_PARSE_VERSION
        select BUILDTIME_EXTABLE_SORT if MMU
        select CLONE_BACKWARDS
index 4f2c28060c9aa227c47e73ac6557c45add91128f..ed6c22919e473e2de059d905373b6d98a9a29a50 100644 (file)
@@ -127,10 +127,14 @@ static inline void arch_spin_unlock(arch_spinlock_t *lock)
        dsb_sev();
 }
 
+static inline int arch_spin_value_unlocked(arch_spinlock_t lock)
+{
+       return lock.tickets.owner == lock.tickets.next;
+}
+
 static inline int arch_spin_is_locked(arch_spinlock_t *lock)
 {
-       struct __raw_tickets tickets = ACCESS_ONCE(lock->tickets);
-       return tickets.owner != tickets.next;
+       return !arch_spin_value_unlocked(ACCESS_ONCE(*lock));
 }
 
 static inline int arch_spin_is_contended(arch_spinlock_t *lock)