From 94782bc2a8daaa4b6122aae527dfd463ffbed739 Mon Sep 17 00:00:00 2001 From: Brent DeGraaf Date: Thu, 3 Feb 2011 15:18:54 -0500 Subject: [PATCH] ARM: Add smp barriers to mutex fastpath routines For smp, barriers are required when a mutex lock is acquired or released. Mutex slowpath routines already contain the necessary barriers. Change-Id: I774fc6e7bd5b1db9a0f51dee456b71c569cd512e Signed-off-by: Brent DeGraaf (cherry picked from commit 62c6b43d05a6aab278eb7d5d0030bd731b7684ea) --- arch/arm/include/asm/mutex.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm/include/asm/mutex.h b/arch/arm/include/asm/mutex.h index 93226cf23ae..fd3f17ef94a 100644 --- a/arch/arm/include/asm/mutex.h +++ b/arch/arm/include/asm/mutex.h @@ -41,6 +41,8 @@ __mutex_fastpath_lock(atomic_t *count, void (*fail_fn)(atomic_t *)) __res |= __ex_flag; if (unlikely(__res != 0)) fail_fn(count); + else + smp_rmb(); } static inline int @@ -61,6 +63,9 @@ __mutex_fastpath_lock_retval(atomic_t *count, int (*fail_fn)(atomic_t *)) __res |= __ex_flag; if (unlikely(__res != 0)) __res = fail_fn(count); + else + smp_rmb(); + return __res; } @@ -74,6 +79,7 @@ __mutex_fastpath_unlock(atomic_t *count, void (*fail_fn)(atomic_t *)) { int __ex_flag, __res, __orig; + smp_wmb(); __asm__ ( "ldrex %0, [%3] \n\t" @@ -119,6 +125,8 @@ __mutex_fastpath_trylock(atomic_t *count, int (*fail_fn)(atomic_t *)) : "=&r" (__orig), "=&r" (__res), "=&r" (__ex_flag) : "r" (&count->counter) : "cc", "memory" ); + if (__orig) + smp_rmb(); return __orig; }