Module Name:    src
Committed By:   thorpej
Date:           Tue Apr 20 00:09:45 UTC 2021

Modified Files:
        src/sys/arch/alpha/alpha: interrupt.c
        src/sys/arch/alpha/include: cpu.h

Log Message:
Slight tweak to previous changes:

Rather than simply increment the interrupt depth for the clock interrupt,
we add 0x10.  Why?  Because while we only use a single Alpha IPL (4) for
IPL_{BIO,NET,TTY,VM}, technically the architecture specification suports
two in the OSF/1 PALcode (3 [low-pri] and 4 [high-pri]), meaning we could
conceiveably have intrdepth > 1 just for device interrupts.

Adding 0x10 here means that cpu_intr_p() can check for "intrdepth != 0" for
"in interrupt context" and CLKF_INTR() can check "(intrdepth & 0xf) != 0" for
"was processing interrupts when the clock interrupt happened".


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/alpha/alpha/interrupt.c
cvs rdiff -u -r1.100 -r1.101 src/sys/arch/alpha/include/cpu.h

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/alpha/alpha/interrupt.c
diff -u src/sys/arch/alpha/alpha/interrupt.c:1.93 src/sys/arch/alpha/alpha/interrupt.c:1.94
--- src/sys/arch/alpha/alpha/interrupt.c:1.93	Thu Apr 15 00:19:52 2021
+++ src/sys/arch/alpha/alpha/interrupt.c	Tue Apr 20 00:09:45 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: interrupt.c,v 1.93 2021/04/15 00:19:52 rin Exp $ */
+/* $NetBSD: interrupt.c,v 1.94 2021/04/20 00:09:45 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.93 2021/04/15 00:19:52 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.94 2021/04/20 00:09:45 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -212,7 +212,21 @@ interrupt(unsigned long a0, unsigned lon
 		break;
 		
 	case ALPHA_INTR_CLOCK:	/* clock interrupt */
-		atomic_inc_ulong(&ci->ci_intrdepth);
+		/*
+		 * Rather than simply increment the interrupt depth
+		 * for the clock interrupt, we add 0x10.  Why?  Because
+		 * while we only call out a single device interrupt
+		 * level, technically the architecture specification
+		 * suports two, meaning we could have intrdepth > 1
+		 * just for device interrupts.
+		 *
+		 * Adding 0x10 here means that cpu_intr_p() can check
+		 * for "intrdepth != 0" for "in interrupt context" and
+		 * CLKF_INTR() can check "(intrdepth & 0xf) != 0" for
+		 * "was processing interrupts when the clock interrupt
+		 * happened".
+		 */
+		atomic_add_long(&ci->ci_intrdepth, 0x10);
 		sc->sc_evcnt_clock.ev_count++;
 		ci->ci_data.cpu_nintr++;
 		if (platform.clockintr) {
@@ -237,7 +251,7 @@ interrupt(unsigned long a0, unsigned lon
 			    schedhz != 0)
 				schedclock(ci->ci_curlwp);
 		}
-		atomic_dec_ulong(&ci->ci_intrdepth);
+		atomic_add_long(&ci->ci_intrdepth, -0x10);
 		break;
 
 	case ALPHA_INTR_ERROR:	/* Machine Check or Correctable Error */

Index: src/sys/arch/alpha/include/cpu.h
diff -u src/sys/arch/alpha/include/cpu.h:1.100 src/sys/arch/alpha/include/cpu.h:1.101
--- src/sys/arch/alpha/include/cpu.h:1.100	Thu Apr 15 08:23:24 2021
+++ src/sys/arch/alpha/include/cpu.h	Tue Apr 20 00:09:45 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.100 2021/04/15 08:23:24 rin Exp $ */
+/* $NetBSD: cpu.h,v 1.101 2021/04/20 00:09:45 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -206,7 +206,7 @@ struct clockframe {
  * like this stastic has to be extremely accurate.
  */
 #define	CLKF_INTR(framep)						\
-	(curcpu()->ci_intrdepth > 1)	/* one for clock interrupt itself */
+	((curcpu()->ci_intrdepth & 0xf) != 0)	/* see interrupt() */
 
 /*
  * This is used during profiling to integrate system time.  It can safely

Reply via email to