summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorskrll <skrll@NetBSD.org>2014-03-20 06:48:54 +0000
committerskrll <skrll@NetBSD.org>2014-03-20 06:48:54 +0000
commit97615f8920ae6fc5bd2d5015048b98b5a8c33db9 (patch)
treea809852f1098850237e17e2f8a4cf53c4eca3115 /sys/dev
parent56fd2ca7bbb94ed0af8f420ed5940838c1caeeaa (diff)
Mechanically replace simplelock with kmutex_t.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/mca/ed_mca.c10
-rw-r--r--sys/dev/mca/edc_mca.c10
-rw-r--r--sys/dev/mca/edvar.h6
-rw-r--r--sys/dev/pci/cxgb/cxgb_osdep.h12
-rw-r--r--sys/dev/pci/cy82c693.c68
5 files changed, 51 insertions, 55 deletions
diff --git a/sys/dev/mca/ed_mca.c b/sys/dev/mca/ed_mca.c
index 84b56c19296..1059bf4d15b 100644
--- a/sys/dev/mca/ed_mca.c
+++ b/sys/dev/mca/ed_mca.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ed_mca.c,v 1.54 2014/03/16 05:20:28 dholland Exp $ */
+/* $NetBSD: ed_mca.c,v 1.55 2014/03/20 06:48:54 skrll Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ed_mca.c,v 1.54 2014/03/16 05:20:28 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ed_mca.c,v 1.55 2014/03/20 06:48:54 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -158,7 +158,7 @@ ed_mca_attach(device_t parent, device_t self, void *aux)
edc_add_disk(sc, ed);
bufq_alloc(&ed->sc_q, "disksort", BUFQ_SORT_RAWBLOCK);
- simple_lock_init(&ed->sc_q_lock);
+ mutex_init(&ed->sc_q_lock, MUTEX_DEFAULT, IPL_VM);
if (ed_get_params(ed, &drv_flags)) {
printf(": IDENTIFY failed, no disk found\n");
@@ -257,9 +257,9 @@ edmcastrategy(struct buf *bp)
bp->b_rawblkno = blkno;
/* Queue transfer on drive, activate drive and controller if idle. */
- simple_lock(&ed->sc_q_lock);
+ mutex_enter(&ed->sc_q_lock);
bufq_put(ed->sc_q, bp);
- simple_unlock(&ed->sc_q_lock);
+ mutex_exit(&ed->sc_q_lock);
/* Ring the worker thread */
wakeup(ed->edc_softc);
diff --git a/sys/dev/mca/edc_mca.c b/sys/dev/mca/edc_mca.c
index 4f121197d49..ed4b416cf11 100644
--- a/sys/dev/mca/edc_mca.c
+++ b/sys/dev/mca/edc_mca.c
@@ -1,4 +1,4 @@
-/* $NetBSD: edc_mca.c,v 1.48 2013/10/12 21:11:42 christos Exp $ */
+/* $NetBSD: edc_mca.c,v 1.49 2014/03/20 06:48:54 skrll Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -46,7 +46,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: edc_mca.c,v 1.48 2013/10/12 21:11:42 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: edc_mca.c,v 1.49 2014/03/20 06:48:54 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -815,13 +815,13 @@ edcworker(void *arg)
}
/* Is there a buf for us ? */
- simple_lock(&ed->sc_q_lock);
+ mutex_enter(&ed->sc_q_lock);
if ((bp = bufq_get(ed->sc_q)) == NULL) {
- simple_unlock(&ed->sc_q_lock);
+ mutex_exit(&ed->sc_q_lock);
i++;
continue;
}
- simple_unlock(&ed->sc_q_lock);
+ mutex_exit(&ed->sc_q_lock);
/* Instrumentation. */
disk_busy(&ed->sc_dk);
diff --git a/sys/dev/mca/edvar.h b/sys/dev/mca/edvar.h
index 2faca91c619..5f8c18dc864 100644
--- a/sys/dev/mca/edvar.h
+++ b/sys/dev/mca/edvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: edvar.h,v 1.16 2012/10/27 17:18:26 chs Exp $ */
+/* $NetBSD: edvar.h,v 1.17 2014/03/20 06:48:54 skrll Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/simplelock.h>
+#include <sys/mutex.h>
struct edc_mca_softc;
@@ -39,7 +39,7 @@ struct ed_softc {
/* General disk infos */
struct disk sc_dk;
struct bufq_state *sc_q;
- struct simplelock sc_q_lock;
+ kmutex_t sc_q_lock;
struct edc_mca_softc *edc_softc; /* pointer to our controller */
diff --git a/sys/dev/pci/cxgb/cxgb_osdep.h b/sys/dev/pci/cxgb/cxgb_osdep.h
index f87d86f2228..f54c8fa082d 100644
--- a/sys/dev/pci/cxgb/cxgb_osdep.h
+++ b/sys/dev/pci/cxgb/cxgb_osdep.h
@@ -47,8 +47,6 @@ typedef char *caddr_t;
#include <netinet/in.h>
#include <netinet/ip.h>
-#include <sys/simplelock.h>
-
#include <sys/kthread.h>
#include <sys/workqueue.h>
@@ -69,12 +67,12 @@ void cxgb_make_task(void *);
void m_cljset(struct mbuf *m, void *cl, int type);
-#define mtx simplelock
-#define mtx_init(a, b, c, d) { (a)->lock_data = __SIMPLELOCK_UNLOCKED; }
+#define mtx kmutex_t
+#define mtx_init(a, b, c, d) { mutex_init(a, MUTEX_DEFAULT, IPL_HIGH) }
#define mtx_destroy(a)
-#define mtx_lock(a) simple_lock(a)
-#define mtx_unlock(a) simple_unlock(a)
-#define mtx_trylock(a) simple_lock_try(a)
+#define mtx_lock(a) mutex_spin_enter(a)
+#define mtx_unlock(a) mutex_spin_exit(a)
+#define mtx_trylock(a) mutex_tryenter(a)
#define MA_OWNED 1
#define MA_NOTOWNED 0
#define mtx_assert(a, w)
diff --git a/sys/dev/pci/cy82c693.c b/sys/dev/pci/cy82c693.c
index 4258c6fcd50..49aec061146 100644
--- a/sys/dev/pci/cy82c693.c
+++ b/sys/dev/pci/cy82c693.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cy82c693.c,v 1.8 2010/04/19 18:24:27 dyoung Exp $ */
+/* $NetBSD: cy82c693.c,v 1.9 2014/03/20 06:48:54 skrll Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -35,16 +35,13 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cy82c693.c,v 1.8 2010/04/19 18:24:27 dyoung Exp $");
-
-#include "opt_multiprocessor.h"
-#include "opt_lockdebug.h"
+__KERNEL_RCSID(0, "$NetBSD: cy82c693.c,v 1.9 2014/03/20 06:48:54 skrll Exp $");
#include <sys/param.h>
#include <sys/device.h>
#include <sys/systm.h>
#include <sys/bus.h>
-#include <sys/simplelock.h>
+#include <sys/once.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
@@ -52,40 +49,43 @@ __KERNEL_RCSID(0, "$NetBSD: cy82c693.c,v 1.8 2010/04/19 18:24:27 dyoung Exp $");
#include <dev/pci/cy82c693reg.h>
#include <dev/pci/cy82c693var.h>
+ONCE_DECL(cyhc_once);
+
static struct cy82c693_handle cyhc_handle;
static int cyhc_initialized;
-static struct simplelock cyhc_slock = SIMPLELOCK_INITIALIZER;
+static kmutex_t cyhc_slock;
-#define CYHC_LOCK(s) \
-do { \
- s = splhigh(); \
- simple_lock(&cyhc_slock); \
-} while (0)
+static int
+cy82c693_onceinit(void)
+{
-#define CYHC_UNLOCK(s) \
-do { \
- simple_unlock(&cyhc_slock); \
- splx(s); \
-} while (0)
+ mutex_init(&cyhc_slock, MUTEX_DEFAULT, IPL_HIGH);
+
+ return 0;
+}
const struct cy82c693_handle *
cy82c693_init(bus_space_tag_t iot)
{
bus_space_handle_t ioh;
- int s;
+ int err;
- CYHC_LOCK(s);
+ err = RUN_ONCE(&cyhc_once, cy82c693_onceinit);
+ if (err)
+ return NULL;
+
+ mutex_spin_enter(&cyhc_slock);
if (cyhc_initialized) {
- CYHC_UNLOCK(s);
+ mutex_spin_exit(&cyhc_slock);;
KASSERT(bus_space_is_equal(iot, cyhc_handle.cyhc_iot));
- return (&cyhc_handle);
+ return &cyhc_handle;
}
if (bus_space_map(iot, CYHC_CONFIG_ADDR, 2, 0, &ioh) != 0) {
- CYHC_UNLOCK(s);
- return (NULL);
+ mutex_spin_exit(&cyhc_slock);;
+ return NULL;
}
cyhc_handle.cyhc_iot = iot;
@@ -93,46 +93,44 @@ cy82c693_init(bus_space_tag_t iot)
cyhc_initialized = 1;
- CYHC_UNLOCK(s);
+ mutex_spin_exit(&cyhc_slock);;
- return (&cyhc_handle);
+ return &cyhc_handle;
}
u_int8_t
cy82c693_read(const struct cy82c693_handle *cyhc, int reg)
{
- int s;
- u_int8_t rv;
+ uint8_t rv;
- CYHC_LOCK(s);
+ mutex_spin_enter(&cyhc_slock);
if (cyhc_initialized == 0) {
- CYHC_UNLOCK(s);
+ mutex_spin_exit(&cyhc_slock);;
panic("cy82c693_read");
}
bus_space_write_1(cyhc->cyhc_iot, cyhc->cyhc_ioh, 0, reg);
rv = bus_space_read_1(cyhc->cyhc_iot, cyhc->cyhc_ioh, 1);
- CYHC_UNLOCK(s);
+ mutex_spin_exit(&cyhc_slock);;
- return (rv);
+ return rv;
}
void
cy82c693_write(const struct cy82c693_handle *cyhc, int reg, u_int8_t val)
{
- int s;
- CYHC_LOCK(s);
+ mutex_spin_enter(&cyhc_slock);
if (cyhc_initialized == 0) {
- CYHC_UNLOCK(s);
+ mutex_spin_exit(&cyhc_slock);;
panic("cy82c693_write");
}
bus_space_write_1(cyhc->cyhc_iot, cyhc->cyhc_ioh, 0, reg);
bus_space_write_1(cyhc->cyhc_iot, cyhc->cyhc_ioh, 1, val);
- CYHC_UNLOCK(s);
+ mutex_spin_exit(&cyhc_slock);;
}