Module Name:    src
Committed By:   thorpej
Date:           Wed Sep 23 18:46:02 UTC 2020

Modified Files:
        src/sys/arch/alpha/common: shared_intr.c

Log Message:
Use a wrapper to acquire the kernel lock for non-MPSAFE interrupts,
rather than doing it in alpha_shared_intr_establish() directly.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/alpha/common/shared_intr.c

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/common/shared_intr.c
diff -u src/sys/arch/alpha/common/shared_intr.c:1.23 src/sys/arch/alpha/common/shared_intr.c:1.24
--- src/sys/arch/alpha/common/shared_intr.c:1.23	Tue Sep 22 15:24:01 2020
+++ src/sys/arch/alpha/common/shared_intr.c	Wed Sep 23 18:46:02 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: shared_intr.c,v 1.23 2020/09/22 15:24:01 thorpej Exp $ */
+/* $NetBSD: shared_intr.c,v 1.24 2020/09/23 18:46:02 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996 Carnegie-Mellon University.
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: shared_intr.c,v 1.23 2020/09/22 15:24:01 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: shared_intr.c,v 1.24 2020/09/23 18:46:02 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -110,13 +110,7 @@ alpha_shared_intr_dispatch(struct alpha_
 		 *      for sure.
 		 */
 
-		if (!ih->ih_mpsafe) {
-			KERNEL_LOCK(1, NULL);
-			rv = (*ih->ih_fn)(ih->ih_arg);
-			KERNEL_UNLOCK_ONE(NULL);
-		} else {
-			rv = (*ih->ih_fn)(ih->ih_arg);
-		}
+		rv = (*ih->ih_fn)(ih->ih_arg);
 
 		handled = handled || (rv != 0);
 		ih = ih->ih_q.tqe_next;
@@ -125,6 +119,19 @@ alpha_shared_intr_dispatch(struct alpha_
 	return (handled);
 }
 
+static int
+alpha_shared_intr_wrapper(void * const arg)
+{
+	struct alpha_shared_intrhand * const ih = arg;
+	int rv;
+
+	KERNEL_LOCK(1, NULL);
+	rv = (*ih->ih_real_fn)(ih->ih_real_arg);
+	KERNEL_UNLOCK_ONE(NULL);
+
+	return rv;
+}
+
 void *
 alpha_shared_intr_establish(struct alpha_shared_intr *intr, unsigned int num,
     int type, int level, int flags,
@@ -170,11 +177,19 @@ alpha_shared_intr_establish(struct alpha
 	}
 
 	ih->ih_intrhead = intr;
-	ih->ih_fn = fn;
-	ih->ih_arg = arg;
+	ih->ih_fn = ih->ih_real_fn = fn;
+	ih->ih_arg = ih->ih_real_arg = arg;
 	ih->ih_level = level;
 	ih->ih_num = num;
-	ih->ih_mpsafe = (flags & ALPHA_INTR_MPSAFE) != 0;
+
+	/*
+	 * Non-MPSAFE interrupts get a wrapper that takes the
+	 * KERNEL_LOCK.
+	 */
+	if ((flags & ALPHA_INTR_MPSAFE) == 0) {
+		ih->ih_fn = alpha_shared_intr_wrapper;
+		ih->ih_arg = ih;
+	}
 
 	intr[num].intr_sharetype = type;
 	TAILQ_INSERT_TAIL(&intr[num].intr_q, ih, ih_q);

Reply via email to