diff options
author | Takashi Iwai <tiwai@suse.de> | 2012-09-05 09:17:31 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2012-09-05 09:17:31 +0200 |
commit | 14e42917216ab0859827c2d8024df45a917301b4 (patch) | |
tree | efbea5d1c54387d62a6fd66a21560232cf312fda /include/asm-generic/mutex-xchg.h | |
parent | ALSA: emu10k1: use list_move_tail instead of list_del/list_add_tail (diff) | |
parent | ALSA: remove the main version information (diff) | |
download | linux-14e42917216ab0859827c2d8024df45a917301b4.tar.xz linux-14e42917216ab0859827c2d8024df45a917301b4.zip |
Merge branch 'fixes' of git://git.alsa-project.org/alsa-kernel into for-next
Diffstat (limited to 'include/asm-generic/mutex-xchg.h')
-rw-r--r-- | include/asm-generic/mutex-xchg.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/include/asm-generic/mutex-xchg.h b/include/asm-generic/mutex-xchg.h index 580a6d35c700..c04e0db8a2d6 100644 --- a/include/asm-generic/mutex-xchg.h +++ b/include/asm-generic/mutex-xchg.h @@ -26,7 +26,13 @@ static inline void __mutex_fastpath_lock(atomic_t *count, void (*fail_fn)(atomic_t *)) { if (unlikely(atomic_xchg(count, 0) != 1)) - fail_fn(count); + /* + * We failed to acquire the lock, so mark it contended + * to ensure that any waiting tasks are woken up by the + * unlock slow path. + */ + if (likely(atomic_xchg(count, -1) != 1)) + fail_fn(count); } /** @@ -43,7 +49,8 @@ static inline int __mutex_fastpath_lock_retval(atomic_t *count, int (*fail_fn)(atomic_t *)) { if (unlikely(atomic_xchg(count, 0) != 1)) - return fail_fn(count); + if (likely(atomic_xchg(count, -1) != 1)) + return fail_fn(count); return 0; } |