Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/alpha Use a wrapper to acquire the kernel lock for ...



details:   https://anonhg.NetBSD.org/src/rev/3411bfe258a7
branches:  trunk
changeset: 944216:3411bfe258a7
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Sep 23 18:46:02 2020 +0000

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

diffstat:

 sys/arch/alpha/common/shared_intr.c |  39 +++++++++++++++++++++++++-----------
 sys/arch/alpha/include/intr.h       |   5 ++-
 2 files changed, 30 insertions(+), 14 deletions(-)

diffs (97 lines):

diff -r 22644b097b54 -r 3411bfe258a7 sys/arch/alpha/common/shared_intr.c
--- a/sys/arch/alpha/common/shared_intr.c       Wed Sep 23 15:30:36 2020 +0000
+++ b/sys/arch/alpha/common/shared_intr.c       Wed Sep 23 18:46:02 2020 +0000
@@ -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 @@
                 *      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 @@
        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 @@
        }
 
        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);
diff -r 22644b097b54 -r 3411bfe258a7 sys/arch/alpha/include/intr.h
--- a/sys/arch/alpha/include/intr.h     Wed Sep 23 15:30:36 2020 +0000
+++ b/sys/arch/alpha/include/intr.h     Wed Sep 23 18:46:02 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: intr.h,v 1.79 2020/09/22 15:24:01 thorpej Exp $ */
+/* $NetBSD: intr.h,v 1.80 2020/09/23 18:47:21 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2000, 2001, 2002 The NetBSD Foundation, Inc.
@@ -203,9 +203,10 @@
        struct alpha_shared_intr *ih_intrhead;
        int     (*ih_fn)(void *);
        void    *ih_arg;
+       int     (*ih_real_fn)(void *);
+       void    *ih_real_arg;
        int     ih_level;
        unsigned int ih_num;
-       int     ih_mpsafe;
 };
 
 struct alpha_shared_intr {



Home | Main Index | Thread Index | Old Index