This is a note to let you know that I've just added the patch titled

    ARM: 7749/1: spinlock: retry trylock operation if strex fails on free lock

to the 3.10-stable tree which can be found at:
    
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     
arm-7749-1-spinlock-retry-trylock-operation-if-strex-fails-on-free-lock.patch
and it can be found in the queue-3.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.


>From 15e7e5c1ebf556cd620c9b091e121091ac760f6d Mon Sep 17 00:00:00 2001
From: Will Deacon <[email protected]>
Date: Wed, 5 Jun 2013 11:27:26 +0100
Subject: ARM: 7749/1: spinlock: retry trylock operation if strex fails on free 
lock

From: Will Deacon <[email protected]>

commit 15e7e5c1ebf556cd620c9b091e121091ac760f6d upstream.

An exclusive store instruction may fail for reasons other than lock
contention (e.g. a cache eviction during the critical section) so, in
line with other architectures using similar exclusive instructions
(alpha, mips, powerpc), retry the trylock operation if the lock appears
to be free but the strex reported failure.

Reported-by: Tony Thompson <[email protected]>
Signed-off-by: Will Deacon <[email protected]>
Signed-off-by: Russell King <[email protected]>
Cc: Li Zefan <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
 arch/arm/include/asm/spinlock.h |   23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

--- a/arch/arm/include/asm/spinlock.h
+++ b/arch/arm/include/asm/spinlock.h
@@ -97,19 +97,22 @@ static inline void arch_spin_lock(arch_s
 
 static inline int arch_spin_trylock(arch_spinlock_t *lock)
 {
-       unsigned long tmp;
+       unsigned long contended, res;
        u32 slock;
 
-       __asm__ __volatile__(
-"      ldrex   %0, [%2]\n"
-"      subs    %1, %0, %0, ror #16\n"
-"      addeq   %0, %0, %3\n"
-"      strexeq %1, %0, [%2]"
-       : "=&r" (slock), "=&r" (tmp)
-       : "r" (&lock->slock), "I" (1 << TICKET_SHIFT)
-       : "cc");
+       do {
+               __asm__ __volatile__(
+               "       ldrex   %0, [%3]\n"
+               "       mov     %2, #0\n"
+               "       subs    %1, %0, %0, ror #16\n"
+               "       addeq   %0, %0, %4\n"
+               "       strexeq %2, %0, [%3]"
+               : "=&r" (slock), "=&r" (contended), "=r" (res)
+               : "r" (&lock->slock), "I" (1 << TICKET_SHIFT)
+               : "cc");
+       } while (res);
 
-       if (tmp == 0) {
+       if (!contended) {
                smp_mb();
                return 1;
        } else {


Patches currently in stable-queue which might be from [email protected] are

queue-3.10/perf-fix-hotplug-splat.patch
queue-3.10/arm-7812-1-rwlocks-retry-trylock-operation-if-strex-fails-on-free-lock.patch
queue-3.10/arm-7953-1-mm-ensure-tlb-invalidation-is-complete-before-enabling-mmu.patch
queue-3.10/arm-7749-1-spinlock-retry-trylock-operation-if-strex-fails-on-free-lock.patch
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to