diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2013-12-26 21:02:38 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2013-12-26 21:02:38 +0000 |
commit | 2bc60b2f2f0bccab1a38b485aaa8221aa8c9521d (patch) | |
tree | 344e7eed6c854134b2183abc565bf25620e2b0eb /sys/arch | |
parent | 35eedb96d89d1bea4c1850759744df5908a15fee (diff) |
When running the ll/sc version of the mutex code (for MULTIPROCESSOR kernels),
correctly handle sc failures. All other ll/sc constructs were doing this
correctly but apparently noone had noticed mutex did not.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/octeon/octeon/mutex.c | 15 | ||||
-rw-r--r-- | sys/arch/sgi/sgi/mutex.c | 15 |
2 files changed, 18 insertions, 12 deletions
diff --git a/sys/arch/octeon/octeon/mutex.c b/sys/arch/octeon/octeon/mutex.c index 2026a6088e3..8876a5edd66 100644 --- a/sys/arch/octeon/octeon/mutex.c +++ b/sys/arch/octeon/octeon/mutex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mutex.c,v 1.5 2011/04/21 04:34:12 miod Exp $ */ +/* $OpenBSD: mutex.c,v 1.6 2013/12/26 21:02:37 miod Exp $ */ /* * Copyright (c) 2004 Artur Grabowski <art@openbsd.org> @@ -39,12 +39,15 @@ try_lock(struct mutex *mtx) asm volatile ( ".set noreorder\n" - "ll %0, %2\n" - "bnez %0, 1f\n" - "nop\n" - "li %1, 1\n" - "sc %1, %2\n" "1:\n" + "ll %0, %2\n" /* tmp = mtx->mtx_lock */ + "bnez %0, 2f\n" + " li %1, 0\n" /* ret = 0 */ + "li %1, 1\n" /* ret = 1 */ + "sc %1, %2\n" /* mtx->mtx_lock = 1 */ + "beqz %1, 1b\n" /* update failed */ + " nop\n" + "2:\n" ".set reorder\n" : "+r"(tmp), "+r"(ret) : "m"(mtx->mtx_lock)); diff --git a/sys/arch/sgi/sgi/mutex.c b/sys/arch/sgi/sgi/mutex.c index 2c85fa89e19..3fa43dac71c 100644 --- a/sys/arch/sgi/sgi/mutex.c +++ b/sys/arch/sgi/sgi/mutex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mutex.c,v 1.12 2011/04/21 04:34:12 miod Exp $ */ +/* $OpenBSD: mutex.c,v 1.13 2013/12/26 21:02:37 miod Exp $ */ /* * Copyright (c) 2004 Artur Grabowski <art@openbsd.org> @@ -39,12 +39,15 @@ try_lock(struct mutex *mtx) asm volatile ( ".set noreorder\n" - "ll %0, %2\n" - "bnez %0, 1f\n" - "nop\n" - "li %1, 1\n" - "sc %1, %2\n" "1:\n" + "ll %0, %2\n" /* tmp = mtx->mtx_lock */ + "bnez %0, 2f\n" + " li %1, 0\n" /* ret = 0 */ + "li %1, 1\n" /* ret = 1 */ + "sc %1, %2\n" /* mtx->mtx_lock = 1 */ + "beqz %1, 1b\n" /* update failed */ + " nop\n" + "2:\n" ".set reorder\n" : "+r"(tmp), "+r"(ret) : "m"(mtx->mtx_lock)); |