Sun Feb 27 19:21:44 2022 UTC ()
mips: Make sure that mutex_spin_exit works even if !DIAGNOSTIC.

The critical store has been under #ifdef DIAGNOSTIC since, uh, 2011.


(riastradh)
diff -r1.13 -r1.14 src/sys/arch/mips/mips/lock_stubs_llsc.S

cvs diff -r1.13 -r1.14 src/sys/arch/mips/mips/lock_stubs_llsc.S (expand / switch to unified diff)

--- src/sys/arch/mips/mips/lock_stubs_llsc.S 2020/09/26 08:21:27 1.13
+++ src/sys/arch/mips/mips/lock_stubs_llsc.S 2022/02/27 19:21:44 1.14
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lock_stubs_llsc.S,v 1.13 2020/09/26 08:21:27 simonb Exp $ */ 1/* $NetBSD: lock_stubs_llsc.S,v 1.14 2022/02/27 19:21:44 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2007 The NetBSD Foundation, Inc. 4 * Copyright (c) 2007 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Andrew Doran. 8 * by Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -26,27 +26,27 @@ @@ -26,27 +26,27 @@
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include "opt_cputype.h" 32#include "opt_cputype.h"
33#include "opt_lockdebug.h" 33#include "opt_lockdebug.h"
34 34
35#include <sys/errno.h> 35#include <sys/errno.h>
36 36
37#include <machine/asm.h> 37#include <machine/asm.h>
38 38
39RCSID("$NetBSD: lock_stubs_llsc.S,v 1.13 2020/09/26 08:21:27 simonb Exp $") 39RCSID("$NetBSD: lock_stubs_llsc.S,v 1.14 2022/02/27 19:21:44 riastradh Exp $")
40 40
41#include "assym.h" 41#include "assym.h"
42 42
43/* 43/*
44 * Set ISA level for the assembler. 44 * Set ISA level for the assembler.
45 * XXX Clean up with a macro? Same code fragment is in mipsX_subr.S too. 45 * XXX Clean up with a macro? Same code fragment is in mipsX_subr.S too.
46 * XXX Key off build abi instead of processor type? 46 * XXX Key off build abi instead of processor type?
47 */ 47 */
48#if defined(MIPS3) 48#if defined(MIPS3)
49 .set mips3 49 .set mips3
50#endif 50#endif
51 51
52#if defined(MIPS32) 52#if defined(MIPS32)
@@ -269,28 +269,28 @@ STATIC_NESTED(llsc_mutex_spin_enter, CAL @@ -269,28 +269,28 @@ STATIC_NESTED(llsc_mutex_spin_enter, CAL
269 j _C_LABEL(mutex_spin_retry) 269 j _C_LABEL(mutex_spin_retry)
270 move a0, t0 270 move a0, t0
271END(llsc_mutex_spin_enter) 271END(llsc_mutex_spin_enter)
272 272
273/* 273/*
274 * void mutex_spin_exit(kmutex_t *mtx); 274 * void mutex_spin_exit(kmutex_t *mtx);
275 */ 275 */
276LEAF(llsc_mutex_spin_exit) 276LEAF(llsc_mutex_spin_exit)
277 PTR_L t2, L_CPU(MIPS_CURLWP) 277 PTR_L t2, L_CPU(MIPS_CURLWP)
278#if defined(DIAGNOSTIC) 278#if defined(DIAGNOSTIC)
279 INT_L t0, MTX_LOCK(a0) 279 INT_L t0, MTX_LOCK(a0)
280 beqz t0, 2f 280 beqz t0, 2f
281 nop 281 nop
282 INT_S zero, MTX_LOCK(a0) 
283#endif 282#endif
 283 INT_S zero, MTX_LOCK(a0)
284 284
285 /* 285 /*
286 * We need to grab this before the mutex count is incremented 286 * We need to grab this before the mutex count is incremented
287 * because if we get an interrupt, it may see the count as zero 287 * because if we get an interrupt, it may see the count as zero
288 * and overwrite the oldspl value with a bogus value. 288 * and overwrite the oldspl value with a bogus value.
289 */ 289 */
290#ifdef PARANOIA 290#ifdef PARANOIA
291 INT_L a2, MTX_IPL(a0) 291 INT_L a2, MTX_IPL(a0)
292#endif 292#endif
293 INT_L a0, CPU_INFO_MTX_OLDSPL(t2) 293 INT_L a0, CPU_INFO_MTX_OLDSPL(t2)
294 294
295 /* 295 /*
296 * Increment the mutex count 296 * Increment the mutex count