Subject: Re: splraiseipl()
To: None <tech-kern@netbsd.org>
From: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
List: tech-kern
Date: 03/29/2006 21:36:47
--NextPart-20060329212825-2502400
Content-Type: Text/Plain; charset=us-ascii

- patch attached to this mail.  please test/review.
	sparc
	sparc64 (ported from newlock branch)

YAMAMOTO Takashi

--NextPart-20060329212825-2502400
Content-Type: Text/Plain; charset=us-ascii
Content-Disposition: attachment; filename="sparc.splraiseipl.diff"

Index: sparc/include/intr.h
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc/include/intr.h,v
retrieving revision 1.8
diff -u -p -r1.8 intr.h
--- sparc/include/intr.h	4 Mar 2006 03:39:02 -0000	1.8
+++ sparc/include/intr.h	29 Mar 2006 12:23:03 -0000
@@ -58,6 +58,7 @@
 #define IPL_SERIAL	13	/* serial */
 #define IPL_STATCLOCK	14	/* statclock */
 #define IPL_HIGH	15	/* everything */
+#define	IPL_LOCK	IPL_HIGH
 
 #if defined(_KERNEL) && !defined(_LOCORE)
 void *
Index: sparc/include/psl.h
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc/include/psl.h,v
retrieving revision 1.39
diff -u -p -r1.39 psl.h
--- sparc/include/psl.h	16 Feb 2006 20:17:15 -0000	1.39
+++ sparc/include/psl.h	29 Mar 2006 12:23:32 -0000
@@ -299,7 +299,7 @@ _SPLSET(spllowerschedclock, IPL_SCHED)
 
 /* Raise IPL and return previous value */
 static __inline int
-splraise(int newipl)
+splraiseipl(int newipl)
 {
 	int psr, oldipl;
 
@@ -318,48 +318,21 @@ splraise(int newipl)
 	return (oldipl);
 }
 
-#define	splsoftclock()	splraise(IPL_SOFTCLOCK)
-#define	splsoftnet()	splraise(IPL_SOFTNET)
+#include <sys/spl.h>
 
-#define	splausoft()	splraise(IPL_SOFTAUDIO)
-#define	splfdsoft()	splraise(IPL_SOFTFDC)
-
-#define	splbio()	splraise(IPL_BIO)
-#define	spltty()	splraise(IPL_TTY)
-#define	splnet()	splraise(IPL_NET)
-#define	splvm()		splraise(IPL_VM)
-#define	splclock()	splraise(IPL_CLOCK)
-#define	splsched()	splraise(IPL_SCHED)
+#define	splausoft()	splraiseipl(IPL_SOFTAUDIO)
+#define	splfdsoft()	splraiseipl(IPL_SOFTFDC)
 
 /* fd hardware, ts102, and tadpole microcontoller interrupts are at level 11 */
-#define	splfd()		splraise(11)
-#define	splts102()	splraise(11)
+#define	splfd()		splraiseipl(11)
+#define	splts102()	splraiseipl(11)
 
 /*
  * zs hardware interrupts are at level 12
  * su (com) hardware interrupts are at level 13
  * IPL_SERIAL must protect them all.
  */
-#define	splzs()		splraise(12)
-#define	splserial()	splraise(IPL_SERIAL)
-
-#define	splaudio()	splraise(IPL_AUDIO)
-
-#define	splstatclock()	splraise(IPL_STATCLOCK)
-
-static __inline int
-splhigh(void)
-{
-	int psr, oldipl;
-
-	__asm volatile("rd %%psr,%0" : "=r" (psr));
-	__asm volatile("wr %0,0,%%psr" : : "r" (psr | PSR_PIL));
-	__asm volatile("and %1,%2,%0; nop; nop" : "=r" (oldipl) : \
-	    "r" (psr), "n" (PSR_PIL));
-	return (oldipl);
-}
-
-#define	spllock()	splhigh()
+#define	splzs()		splraiseipl(12)
 
 /* splx does not have a return value */
 static __inline void
Index: sparc64/include/intr.h
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc64/include/intr.h,v
retrieving revision 1.12
diff -u -p -r1.12 intr.h
--- sparc64/include/intr.h	11 Dec 2005 12:19:10 -0000	1.12
+++ sparc64/include/intr.h	29 Mar 2006 12:24:36 -0000
@@ -50,15 +50,18 @@
 #define	IPL_NET		PIL_NET		/* network */
 #define	IPL_SOFTSERIAL	4		/* serial */
 #define	IPL_TTY		PIL_TTY		/* terminal */
-#define	IPL_VM		PIL_IMP		/* memory allocation */
+#define	IPL_VM		PIL_VM		/* memory allocation */
 #define	IPL_AUDIO	PIL_AUD		/* audio */
 #define	IPL_CLOCK	PIL_CLOCK	/* clock */
+#define	IPL_STATCLOCK	PIL_STATCLOCK	/* statclock */
 #define	IPL_SERIAL	PIL_SER		/* serial */
 #define	IPL_SCHED	PIL_SCHED	/* scheduler */
 #define	IPL_LOCK	PIL_LOCK	/* locks */
 #define	IPL_HIGH	PIL_HIGH	/* everything */
 #define	IPL_HALT	5		/* cpu stop-self */
 #define	IPL_PAUSE	13		/* pause cpu */
+#define	IPL_LPT		PIL_LPT
+#define	IPL_IPI		PIL_HIGH
 
 /*
  * Interprocessor interrupts. In order how we want them processed.
Index: sparc64/include/psl.h
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc64/include/psl.h,v
retrieving revision 1.32
diff -u -p -r1.32 psl.h
--- sparc64/include/psl.h	20 Feb 2006 19:00:27 -0000	1.32
+++ sparc64/include/psl.h	29 Mar 2006 12:24:41 -0000
@@ -81,11 +81,12 @@
 #define PIL_TTY		6
 #define PIL_LPT		6
 #define PIL_NET		6
-#define PIL_IMP		7
+#define PIL_VM		7
 #define	PIL_AUD		8
 #define PIL_CLOCK	10
 #define PIL_FD		11
 #define PIL_SER		12
+#define	PIL_STATCLOCK	14
 #define PIL_HIGH	15
 #define PIL_SCHED	PIL_CLOCK
 #define PIL_LOCK	PIL_HIGH
@@ -365,6 +366,22 @@ static __inline int name(void) \
 }
 #endif
 
+static __inline int __attribute__((__unused__))
+splraiseipl(int newpil)
+{
+	int oldpil;
+
+	/*
+	 * NetBSD/sparc64's IPL_* constants equate directly to the
+	 * corresponding PIL_* names; no need to map them here.
+	 */
+	__asm __volatile("rdpr %%pil,%0" : "=r" (oldpil));
+	if (newpil <= oldpil)
+		return (oldpil);
+	__asm __volatile("wrpr %0,0,%%pil" : : "r" (newpil));
+	return (oldpil);
+}
+
 SPL(spl0, 0)
 
 SPL(spllowersoftclock, 1)
@@ -396,7 +413,7 @@ SPLHOLD(spllpt, PIL_LPT)
 /*
  * Memory allocation (must be as high as highest network, tty, or disk device)
  */
-SPLHOLD(splvm, PIL_IMP)
+SPLHOLD(splvm, PIL_VM)
 
 SPLHOLD(splclock, PIL_CLOCK)
 
@@ -411,7 +428,7 @@ SPLHOLD(splserial, PIL_SER)
 SPLHOLD(splaudio, PIL_AUD)
 
 /* second sparc timer interrupts at level 14 */
-SPLHOLD(splstatclock, 14)
+SPLHOLD(splstatclock, PIL_STATCLOCK)
 
 SPLHOLD(splsched, PIL_SCHED)
 SPLHOLD(spllock, PIL_LOCK)

--NextPart-20060329212825-2502400--