Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/fdt Disallow sharing between MPSAFE and non-MPS...



details:   https://anonhg.NetBSD.org/src/rev/ccd722e6ff75
branches:  trunk
changeset: 825186:ccd722e6ff75
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Jul 02 21:59:14 2017 +0000

description:
Disallow sharing between MPSAFE and non-MPSAFE handlers.

diffstat:

 sys/arch/arm/fdt/gic_fdt.c |  21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diffs (72 lines):

diff -r cd887055e11e -r ccd722e6ff75 sys/arch/arm/fdt/gic_fdt.c
--- a/sys/arch/arm/fdt/gic_fdt.c        Sun Jul 02 21:13:06 2017 +0000
+++ b/sys/arch/arm/fdt/gic_fdt.c        Sun Jul 02 21:59:14 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_fdt.c,v 1.6 2017/06/29 20:54:28 jmcneill Exp $ */
+/* $NetBSD: gic_fdt.c,v 1.7 2017/07/02 21:59:14 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.6 2017/06/29 20:54:28 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.7 2017/07/02 21:59:14 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -78,6 +78,7 @@
        int                     intr_refcnt;
        int                     intr_ipl;
        int                     intr_level;
+       int                     intr_mpsafe;
        TAILQ_HEAD(, gic_fdt_irqhandler) intr_handlers;
 };
 
@@ -178,6 +179,8 @@
        const u_int trig = be32toh(specifier[2]) & 0xf;
        const u_int level = (trig & 0x3) ? IST_EDGE : IST_LEVEL;
 
+       const u_int mpsafe = (flags & FDT_INTR_MPSAFE) ? IST_MPSAFE : 0;
+
        firq = sc->sc_irq[irq];
        if (firq == NULL) {
                firq = kmem_alloc(sizeof(*firq), KM_SLEEP);
@@ -185,8 +188,9 @@
                firq->intr_refcnt = 0;
                firq->intr_ipl = ipl;
                firq->intr_level = level;
+               firq->intr_mpsafe = mpsafe;
                TAILQ_INIT(&firq->intr_handlers);
-               firq->intr_ih = intr_establish(irq, ipl, level | IST_MPSAFE,
+               firq->intr_ih = intr_establish(irq, ipl, level | mpsafe,
                    gic_fdt_intr, firq);
                if (firq->intr_ih == NULL) {
                        kmem_free(firq, sizeof(*firq));
@@ -203,6 +207,10 @@
                device_printf(dev, "cannot share edge and level interrupts\n");
                return NULL;
        }
+       if (firq->intr_mpsafe != mpsafe) {
+               device_printf(dev, "cannot share between mpsafe/non-mpsafe\n");
+               return NULL;
+       }
 
        firq->intr_refcnt++;
 
@@ -241,13 +249,8 @@
        struct gic_fdt_irqhandler *firqh;
        int handled = 0;
 
-       TAILQ_FOREACH(firqh, &firq->intr_handlers, ih_next) {
-               if (!firqh->ih_mpsafe)
-                       KERNEL_LOCK(1, curlwp);
+       TAILQ_FOREACH(firqh, &firq->intr_handlers, ih_next)
                handled += firqh->ih_fn(firqh->ih_arg);
-               if (!firqh->ih_mpsafe)
-                       KERNEL_UNLOCK_ONE(curlwp);
-       }
 
        return handled;
 }



Home | Main Index | Thread Index | Old Index