Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc add two new members to struct intrhand: ih_re...
details: https://anonhg.NetBSD.org/src/rev/369cd807f36a
branches: trunk
changeset: 750501:369cd807f36a
user: mrg <mrg%NetBSD.org@localhost>
date: Sun Jan 03 12:39:22 2010 +0000
description:
add two new members to struct intrhand: ih_realfun and ih_realarg, and
use them to take the kernel lock around non-IPL_VM interrupts, using
a intr_biglock_wrapper() function ike x86 does.
diffstat:
sys/arch/sparc/include/cpu.h | 7 ++++-
sys/arch/sparc/sparc/intr.c | 54 +++++++++++++++++++++++++++++++++---------
sys/arch/sparc/sparc/locore.s | 42 +--------------------------------
3 files changed, 49 insertions(+), 54 deletions(-)
diffs (223 lines):
diff -r 12104a710555 -r 369cd807f36a sys/arch/sparc/include/cpu.h
--- a/sys/arch/sparc/include/cpu.h Sun Jan 03 11:44:58 2010 +0000
+++ b/sys/arch/sparc/include/cpu.h Sun Jan 03 12:39:22 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.87 2009/10/21 21:12:02 rmind Exp $ */
+/* $NetBSD: cpu.h,v 1.88 2010/01/03 12:39:22 mrg Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -156,12 +156,17 @@
* ``not me'' or 1 (``I took care of it''). intr_establish() inserts a
* handler into the list. The handler is called with its (single)
* argument, or with a pointer to a clockframe if ih_arg is NULL.
+ *
+ * realfun/realarg are used to chain callers, usually with the
+ * biglock wrapper.
*/
extern struct intrhand {
int (*ih_fun)(void *);
void *ih_arg;
struct intrhand *ih_next;
int ih_classipl;
+ int (*ih_realfun)(void *);
+ void *ih_realarg;
} *intrhand[15];
void intr_establish(int, int, struct intrhand *, void (*)(void));
diff -r 12104a710555 -r 369cd807f36a sys/arch/sparc/sparc/intr.c
--- a/sys/arch/sparc/sparc/intr.c Sun Jan 03 11:44:58 2010 +0000
+++ b/sys/arch/sparc/sparc/intr.c Sun Jan 03 12:39:22 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: intr.c,v 1.105 2009/06/05 01:36:07 mrg Exp $ */
+/* $NetBSD: intr.c,v 1.106 2010/01/03 12:39:22 mrg Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.105 2009/06/05 01:36:07 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.106 2010/01/03 12:39:22 mrg Exp $");
#include "opt_multiprocessor.h"
#include "opt_sparc_arch.h"
@@ -71,6 +71,8 @@
#endif
#if defined(MULTIPROCESSOR)
+static int intr_biglock_wrapper(void *);
+
void *xcall_cookie;
/* Stats */
@@ -636,6 +638,9 @@
struct intrhand *ih, void (*vec)(void))
{
int s = splhigh();
+#ifdef MULTIPROCESSOR
+ bool mpsafe = (level != IPL_VM);
+#endif /* MULTIPROCESSOR */
#ifdef DIAGNOSTIC
if (CPU_ISSUN4C) {
@@ -673,6 +678,15 @@
/* pre-shift to PIL field in %psr */
ih->ih_classipl = (classipl << 8) & PSR_PIL;
+#ifdef MULTIPROCESSOR
+ if (!mpsafe) {
+ ih->ih_realfun = ih->ih_fun;
+ ih->ih_realarg = ih->ih_arg;
+ ih->ih_fun = intr_biglock_wrapper;
+ ih->ih_arg = ih;
+ }
+#endif /* MULTIPROCESSOR */
+
ih_insert(&intrhand[level], ih);
splx(s);
}
@@ -722,6 +736,9 @@
struct intrhand *ih;
int pilreq;
int pil;
+#ifdef MULTIPROCESSOR
+ bool mpsafe = (level != IPL_VM);
+#endif /* MULTIPROCESSOR */
/*
* On a sun4m, the processor interrupt level is stored
@@ -750,8 +767,18 @@
sic->sic_pil = pil;
sic->sic_pilreq = pilreq;
ih = &sic->sic_hand;
- ih->ih_fun = (int (*)(void *))fun;
- ih->ih_arg = arg;
+#ifdef MULTIPROCESSOR
+ if (!mpsafe) {
+ ih->ih_realfun = (int (*)(void *))fun;
+ ih->ih_realarg = arg;
+ ih->ih_fun = intr_biglock_wrapper;
+ ih->ih_arg = ih;
+ } else
+#endif /* MULTIPROCESSOR */
+ {
+ ih->ih_fun = (int (*)(void *))fun;
+ ih->ih_arg = arg;
+ }
/*
* Always run the handler at the requested level, which might
@@ -803,23 +830,26 @@
#endif
#ifdef MULTIPROCESSOR
+
/*
- * Called by interrupt stubs, etc., to lock/unlock the kernel.
+ * intr_biglock_wrapper: grab biglock and call a real interrupt handler.
*/
-void
-intr_lock_kernel(void)
+
+static int
+intr_biglock_wrapper(void *vp)
{
+ struct intrhand *ih = vp;
+ int ret;
KERNEL_LOCK(1, NULL);
-}
-void
-intr_unlock_kernel(void)
-{
+ ret = (*ih->ih_realfun)(ih->ih_realarg);
KERNEL_UNLOCK_ONE(NULL);
+
+ return ret;
}
-#endif
+#endif /* MULTIPROCESSOR */
bool
cpu_intr_p(void)
diff -r 12104a710555 -r 369cd807f36a sys/arch/sparc/sparc/locore.s
--- a/sys/arch/sparc/sparc/locore.s Sun Jan 03 11:44:58 2010 +0000
+++ b/sys/arch/sparc/sparc/locore.s Sun Jan 03 12:39:22 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.s,v 1.251 2010/01/03 11:44:58 mrg Exp $ */
+/* $NetBSD: locore.s,v 1.252 2010/01/03 12:39:22 mrg Exp $ */
/*
* Copyright (c) 1996 Paul Kranenburg
@@ -2542,18 +2542,6 @@
inc %o3
st %o3, [ %o2 + CPUINFO_IDEPTH ]
-#if defined(MULTIPROCESSOR)
- /*
- * Grab the kernel lock for interrupt levels <= IPL_VM
- * XXX Must not happen for fast soft interrupts!
- */
- cmp %l3, IPL_VM
- bne 3f
- st %fp, [%sp + CCFSZ + 16]
- call _C_LABEL(intr_lock_kernel)
- nop
-#endif
-
b 3f
st %fp, [%sp + CCFSZ + 16]
@@ -2573,15 +2561,6 @@
bnz 1b
nop
-#if defined(MULTIPROCESSOR)
- cmp %l3, IPL_VM
- bne 0f
- nop
- call _C_LABEL(intr_unlock_kernel)
- nop
-0:
-#endif
-
sethi %hi(CPUINFO_VA), %o2
ld [ %o2 + CPUINFO_IDEPTH ], %o3
dec %o3
@@ -2743,17 +2722,6 @@
inc %o3
st %o3, [ %o2 + CPUINFO_IDEPTH ]
-#if defined(MULTIPROCESSOR)
- /* Grab the kernel lock for interrupt levels =< IPL_VM */
- cmp %l3, IPL_VM
- bne 3f
- st %fp, [%sp + CCFSZ + 16]
- call _C_LABEL(intr_lock_kernel)
- nop
-#endif
- b 3f
- st %fp, [%sp + CCFSZ + 16]
-
1: ld [%l4 + IH_CLASSIPL], %o2 ! ih->ih_classipl
rd %psr, %o3 ! (bits already shifted to PIL field)
andn %o3, PSR_PIL, %o3 ! %o3 = psr & ~PSR_PIL
@@ -2784,14 +2752,6 @@
add %sp, CCFSZ, %o0
/* all done: restore registers and go return */
4:
-#if defined(MULTIPROCESSOR)
- cmp %l3, IPL_VM
- bne 0f
- nop
- call _C_LABEL(intr_unlock_kernel)
- nop
-0:
-#endif
sethi %hi(CPUINFO_VA), %o2
ld [ %o2 + CPUINFO_IDEPTH ], %o3
dec %o3
Home |
Main Index |
Thread Index |
Old Index