Module Name:    src
Committed By:   mrg
Date:           Sun Jan  3 12:39:23 UTC 2010

Modified Files:
        src/sys/arch/sparc/include: cpu.h
        src/sys/arch/sparc/sparc: intr.c locore.s

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sys/arch/sparc/include/cpu.h
cvs rdiff -u -r1.105 -r1.106 src/sys/arch/sparc/sparc/intr.c
cvs rdiff -u -r1.251 -r1.252 src/sys/arch/sparc/sparc/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc/include/cpu.h
diff -u src/sys/arch/sparc/include/cpu.h:1.87 src/sys/arch/sparc/include/cpu.h:1.88
--- src/sys/arch/sparc/include/cpu.h:1.87	Wed Oct 21 21:12:02 2009
+++ src/sys/arch/sparc/include/cpu.h	Sun Jan  3 12:39:22 2010
@@ -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));

Index: src/sys/arch/sparc/sparc/intr.c
diff -u src/sys/arch/sparc/sparc/intr.c:1.105 src/sys/arch/sparc/sparc/intr.c:1.106
--- src/sys/arch/sparc/sparc/intr.c:1.105	Fri Jun  5 01:36:07 2009
+++ src/sys/arch/sparc/sparc/intr.c	Sun Jan  3 12:39:22 2010
@@ -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)

Index: src/sys/arch/sparc/sparc/locore.s
diff -u src/sys/arch/sparc/sparc/locore.s:1.251 src/sys/arch/sparc/sparc/locore.s:1.252
--- src/sys/arch/sparc/sparc/locore.s:1.251	Sun Jan  3 11:44:58 2010
+++ src/sys/arch/sparc/sparc/locore.s	Sun Jan  3 12:39:22 2010
@@ -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

Reply via email to