summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2009-04-19 17:50:19 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2009-04-19 17:50:19 +0000
commitc9eacd92073efd8ad00f150bc65934fcd0b10192 (patch)
tree0e2fadfa6ebfd904b43cbfa2fec78227912aca41
parentdaf87eb28ec0bc166d6dcff7f6e3701e8bf82852 (diff)
Switch the softinterrupt code on x86 over to mutexes instead of
simplelocks + splhigh(). First part of making it possible to make mpsafe softinterrupts. "oh yes, definitely" miod@
-rw-r--r--sys/arch/amd64/amd64/softintr.c16
-rw-r--r--sys/arch/amd64/include/intr.h25
-rw-r--r--sys/arch/i386/i386/softintr.c16
-rw-r--r--sys/arch/i386/include/intr.h26
4 files changed, 27 insertions, 56 deletions
diff --git a/sys/arch/amd64/amd64/softintr.c b/sys/arch/amd64/amd64/softintr.c
index d81a61a03dc..a6e659d2744 100644
--- a/sys/arch/amd64/amd64/softintr.c
+++ b/sys/arch/amd64/amd64/softintr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softintr.c,v 1.3 2008/06/26 05:42:09 ray Exp $ */
+/* $OpenBSD: softintr.c,v 1.4 2009/04/19 17:50:18 oga Exp $ */
/* $NetBSD: softintr.c,v 1.1 2003/02/26 21:26:12 fvdl Exp $ */
/*-
@@ -63,7 +63,7 @@ softintr_init(void)
for (i = 0; i < X86_NSOFTINTR; i++) {
si = &x86_soft_intrs[i];
TAILQ_INIT(&si->softintr_q);
- simple_lock_init(&si->softintr_slock);
+ mtx_init(&si->softintr_lock, IPL_HIGH);
si->softintr_ssir = x86_soft_intr_to_ssir[i];
}
}
@@ -78,18 +78,17 @@ softintr_dispatch(int which)
{
struct x86_soft_intr *si = &x86_soft_intrs[which];
struct x86_soft_intrhand *sih;
- int s;
for (;;) {
- x86_softintr_lock(si, s);
+ mtx_enter(&si->softintr_lock);
sih = TAILQ_FIRST(&si->softintr_q);
if (sih == NULL) {
- x86_softintr_unlock(si, s);
+ mtx_leave(&si->softintr_lock);
break;
}
TAILQ_REMOVE(&si->softintr_q, sih, sih_q);
sih->sih_pending = 0;
- x86_softintr_unlock(si, s);
+ mtx_leave(&si->softintr_lock);
uvmexp.softs++;
(*sih->sih_fn)(sih->sih_arg);
@@ -148,14 +147,13 @@ softintr_disestablish(void *arg)
{
struct x86_soft_intrhand *sih = arg;
struct x86_soft_intr *si = sih->sih_intrhead;
- int s;
- x86_softintr_lock(si, s);
+ mtx_enter(&si->softintr_lock);
if (sih->sih_pending) {
TAILQ_REMOVE(&si->softintr_q, sih, sih_q);
sih->sih_pending = 0;
}
- x86_softintr_unlock(si, s);
+ mtx_leave(&si->softintr_lock);
free(sih, M_DEVBUF);
}
diff --git a/sys/arch/amd64/include/intr.h b/sys/arch/amd64/include/intr.h
index f3076a10d35..2207a60d3d1 100644
--- a/sys/arch/amd64/include/intr.h
+++ b/sys/arch/amd64/include/intr.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: intr.h,v 1.16 2009/03/15 19:40:40 miod Exp $ */
+/* $OpenBSD: intr.h,v 1.17 2009/04/19 17:50:18 oga Exp $ */
/* $NetBSD: intr.h,v 1.2 2003/05/04 22:01:56 fvdl Exp $ */
/*-
@@ -255,23 +255,11 @@ struct x86_soft_intrhand {
struct x86_soft_intr {
TAILQ_HEAD(, x86_soft_intrhand)
- softintr_q;
- int softintr_ssir;
- struct simplelock softintr_slock;
+ softintr_q;
+ int softintr_ssir;
+ struct mutex softintr_lock;
};
-#define x86_softintr_lock(si, s) \
-do { \
- (s) = splhigh(); \
- simple_lock(&si->softintr_slock); \
-} while (/*CONSTCOND*/ 0)
-
-#define x86_softintr_unlock(si, s) \
-do { \
- simple_unlock(&si->softintr_slock); \
- splx((s)); \
-} while (/*CONSTCOND*/ 0)
-
void *softintr_establish(int, void (*)(void *), void *);
void softintr_disestablish(void *);
void softintr_init(void);
@@ -281,15 +269,14 @@ void softintr_dispatch(int);
do { \
struct x86_soft_intrhand *__sih = (arg); \
struct x86_soft_intr *__si = __sih->sih_intrhead; \
- int __s; \
\
- x86_softintr_lock(__si, __s); \
+ mtx_enter(&__si->softintr_lock); \
if (__sih->sih_pending == 0) { \
TAILQ_INSERT_TAIL(&__si->softintr_q, __sih, sih_q); \
__sih->sih_pending = 1; \
softintr(__si->softintr_ssir); \
} \
- x86_softintr_unlock(__si, __s); \
+ mtx_leave(&__si->softintr_lock); \
} while (/*CONSTCOND*/ 0)
#endif /* _LOCORE */
diff --git a/sys/arch/i386/i386/softintr.c b/sys/arch/i386/i386/softintr.c
index 5010e70fdb4..4a9a65a04d4 100644
--- a/sys/arch/i386/i386/softintr.c
+++ b/sys/arch/i386/i386/softintr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softintr.c,v 1.2 2008/06/26 05:42:10 ray Exp $ */
+/* $OpenBSD: softintr.c,v 1.3 2009/04/19 17:50:18 oga Exp $ */
/* $NetBSD: softintr.c,v 1.1 2003/02/26 21:26:12 fvdl Exp $ */
/*-
@@ -63,7 +63,7 @@ softintr_init(void)
for (i = 0; i < I386_NSOFTINTR; i++) {
si = &i386_soft_intrs[i];
TAILQ_INIT(&si->softintr_q);
- simple_lock_init(&si->softintr_slock);
+ mtx_init(&si->softintr_lock, IPL_HIGH);
si->softintr_ssir = i386_soft_intr_to_ssir[i];
}
}
@@ -78,18 +78,17 @@ softintr_dispatch(int which)
{
struct i386_soft_intr *si = &i386_soft_intrs[which];
struct i386_soft_intrhand *sih;
- int s;
for (;;) {
- i386_softintr_lock(si, s);
+ mtx_enter(&si->softintr_lock);
sih = TAILQ_FIRST(&si->softintr_q);
if (sih == NULL) {
- i386_softintr_unlock(si, s);
+ mtx_leave(&si->softintr_lock);
break;
}
TAILQ_REMOVE(&si->softintr_q, sih, sih_q);
sih->sih_pending = 0;
- i386_softintr_unlock(si, s);
+ mtx_leave(&si->softintr_lock);
uvmexp.softs++;
(*sih->sih_fn)(sih->sih_arg);
@@ -148,14 +147,13 @@ softintr_disestablish(void *arg)
{
struct i386_soft_intrhand *sih = arg;
struct i386_soft_intr *si = sih->sih_intrhead;
- int s;
- i386_softintr_lock(si, s);
+ mtx_enter(&si->softintr_lock);
if (sih->sih_pending) {
TAILQ_REMOVE(&si->softintr_q, sih, sih_q);
sih->sih_pending = 0;
}
- i386_softintr_unlock(si, s);
+ mtx_leave(&si->softintr_lock);
free(sih, M_DEVBUF);
}
diff --git a/sys/arch/i386/include/intr.h b/sys/arch/i386/include/intr.h
index 812af4d74d1..fd5f02fa4af 100644
--- a/sys/arch/i386/include/intr.h
+++ b/sys/arch/i386/include/intr.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: intr.h,v 1.37 2009/03/15 19:40:40 miod Exp $ */
+/* $OpenBSD: intr.h,v 1.38 2009/04/19 17:50:18 oga Exp $ */
/* $NetBSD: intr.h,v 1.5 1996/05/13 06:11:28 mycroft Exp $ */
/*
@@ -36,6 +36,7 @@
#include <machine/intrdefs.h>
#ifndef _LOCORE
+#include <sys/mutex.h>
#include <machine/cpu.h>
extern volatile u_int32_t lapic_tpr; /* Current interrupt priority level. */
@@ -170,23 +171,11 @@ struct i386_soft_intrhand {
struct i386_soft_intr {
TAILQ_HEAD(, i386_soft_intrhand)
- softintr_q;
- int softintr_ssir;
- struct simplelock softintr_slock;
+ softintr_q;
+ int softintr_ssir;
+ struct mutex softintr_lock;
};
-#define i386_softintr_lock(si, s) \
-do { \
- (s) = splhigh(); \
- simple_lock(&si->softintr_slock); \
-} while (/*CONSTCOND*/ 0)
-
-#define i386_softintr_unlock(si, s) \
-do { \
- simple_unlock(&si->softintr_slock); \
- splx((s)); \
-} while (/*CONSTCOND*/ 0)
-
void *softintr_establish(int, void (*)(void *), void *);
void softintr_disestablish(void *);
void softintr_init(void);
@@ -196,15 +185,14 @@ void softintr_dispatch(int);
do { \
struct i386_soft_intrhand *__sih = (arg); \
struct i386_soft_intr *__si = __sih->sih_intrhead; \
- int __s; \
\
- i386_softintr_lock(__si, __s); \
+ mtx_enter(&__si->softintr_lock); \
if (__sih->sih_pending == 0) { \
TAILQ_INSERT_TAIL(&__si->softintr_q, __sih, sih_q); \
__sih->sih_pending = 1; \
softintr(__si->softintr_ssir); \
} \
- i386_softintr_unlock(__si, __s); \
+ mtx_leave(&__si->softintr_lock); \
} while (/*CONSTCOND*/ 0)
#endif /* _LOCORE */