From 4e4f5ce5df824245a88784d72d01c9b9dc18d0a5 Mon Sep 17 00:00:00 2001 From: visa Date: Thu, 6 Jul 2023 10:17:43 +0000 Subject: [PATCH] Use mtx_init() to initialize stack-based mutexes mtx_init() ensures the mutex' lock_object has static storage duration. This makes it safe to re-enable WITNESS with stack-based mutexes. OK bluhm@ miod@ --- sys/dev/ic/mfi.c | 7 ++++--- sys/dev/ic/mpi.c | 7 ++++--- sys/dev/pci/mfii.c | 7 ++++--- sys/dev/pci/mpii.c | 7 ++++--- sys/scsi/scsi_base.c | 7 ++++--- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/sys/dev/ic/mfi.c b/sys/dev/ic/mfi.c index 3867bb94e4d..8dd9c33a3e6 100644 --- a/sys/dev/ic/mfi.c +++ b/sys/dev/ic/mfi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mfi.c,v 1.189 2023/05/25 19:35:58 kurt Exp $ */ +/* $OpenBSD: mfi.c,v 1.190 2023/07/06 10:17:43 visa Exp $ */ /* * Copyright (c) 2006 Marco Peereboom * @@ -925,8 +925,9 @@ mfi_poll(struct mfi_softc *sc, struct mfi_ccb *ccb) void mfi_exec(struct mfi_softc *sc, struct mfi_ccb *ccb) { - struct mutex m = MUTEX_INITIALIZER_FLAGS(IPL_BIO, __MTX_NAME, - MTX_NOWITNESS); + struct mutex m; + + mtx_init(&m, IPL_BIO); #ifdef DIAGNOSTIC if (ccb->ccb_cookie != NULL || ccb->ccb_done != NULL) diff --git a/sys/dev/ic/mpi.c b/sys/dev/ic/mpi.c index 5ded2b169df..a8ef8fa3bc4 100644 --- a/sys/dev/ic/mpi.c +++ b/sys/dev/ic/mpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpi.c,v 1.225 2023/05/25 19:35:58 kurt Exp $ */ +/* $OpenBSD: mpi.c,v 1.226 2023/07/06 10:17:43 visa Exp $ */ /* * Copyright (c) 2005, 2006, 2009 David Gwynne @@ -1263,10 +1263,11 @@ mpi_poll_done(struct mpi_ccb *ccb) void mpi_wait(struct mpi_softc *sc, struct mpi_ccb *ccb) { - struct mutex cookie = MUTEX_INITIALIZER_FLAGS( - IPL_BIO, __MTX_NAME, MTX_NOWITNESS); + struct mutex cookie; void (*done)(struct mpi_ccb *); + mtx_init(&cookie, IPL_BIO); + done = ccb->ccb_done; ccb->ccb_done = mpi_wait_done; ccb->ccb_cookie = &cookie; diff --git a/sys/dev/pci/mfii.c b/sys/dev/pci/mfii.c index 760b30d1f2f..80590fa5304 100644 --- a/sys/dev/pci/mfii.c +++ b/sys/dev/pci/mfii.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mfii.c,v 1.88 2023/05/25 19:35:58 kurt Exp $ */ +/* $OpenBSD: mfii.c,v 1.89 2023/07/06 10:17:43 visa Exp $ */ /* * Copyright (c) 2012 David Gwynne @@ -1764,8 +1764,9 @@ mfii_poll_done(struct mfii_softc *sc, struct mfii_ccb *ccb) int mfii_exec(struct mfii_softc *sc, struct mfii_ccb *ccb) { - struct mutex m = MUTEX_INITIALIZER_FLAGS(IPL_BIO, __MTX_NAME, - MTX_NOWITNESS); + struct mutex m; + + mtx_init(&m, IPL_BIO); #ifdef DIAGNOSTIC if (ccb->ccb_cookie != NULL || ccb->ccb_done != NULL) diff --git a/sys/dev/pci/mpii.c b/sys/dev/pci/mpii.c index 51da9d5748a..726dd4fdb00 100644 --- a/sys/dev/pci/mpii.c +++ b/sys/dev/pci/mpii.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpii.c,v 1.145 2023/05/25 19:35:58 kurt Exp $ */ +/* $OpenBSD: mpii.c,v 1.146 2023/07/06 10:17:43 visa Exp $ */ /* * Copyright (c) 2010, 2012 Mike Belopuhov * Copyright (c) 2009 James Giannoules @@ -2857,11 +2857,12 @@ mpii_init_queues(struct mpii_softc *sc) void mpii_wait(struct mpii_softc *sc, struct mpii_ccb *ccb) { - struct mutex mtx = MUTEX_INITIALIZER_FLAGS(IPL_BIO, - __MTX_NAME, MTX_NOWITNESS); + struct mutex mtx; void (*done)(struct mpii_ccb *); void *cookie; + mtx_init(&mtx, IPL_BIO); + done = ccb->ccb_done; cookie = ccb->ccb_cookie; diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c index 50aa10fd6cd..559df94fcfb 100644 --- a/sys/scsi/scsi_base.c +++ b/sys/scsi/scsi_base.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_base.c,v 1.281 2023/05/25 19:35:58 kurt Exp $ */ +/* $OpenBSD: scsi_base.c,v 1.282 2023/07/06 10:17:43 visa Exp $ */ /* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */ /* @@ -1497,10 +1497,11 @@ scsi_done(struct scsi_xfer *xs) int scsi_xs_sync(struct scsi_xfer *xs) { - struct mutex cookie = MUTEX_INITIALIZER_FLAGS(IPL_BIO, __MTX_NAME, - MTX_NOWITNESS); + struct mutex cookie; int error; + mtx_init(&cookie, IPL_BIO); + #ifdef DIAGNOSTIC if (xs->cookie != NULL) panic("xs->cookie != NULL in scsi_xs_sync"); -- 2.20.1