Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/cortex Since all ITS instances share a common L...



details:   https://anonhg.NetBSD.org/src/rev/b5283f6e278c
branches:  trunk
changeset: 1007285:b5283f6e278c
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Thu Feb 13 00:42:59 2020 +0000

description:
Since all ITS instances share a common LPI configuration table, used a
shared vmem arena to allocate pic irqs. Idea from FreeBSD.

diffstat:

 sys/arch/arm/cortex/gicv3.c     |  10 ++++++++--
 sys/arch/arm/cortex/gicv3.h     |   6 +++++-
 sys/arch/arm/cortex/gicv3_its.c |  28 ++++++++++++++++------------
 3 files changed, 29 insertions(+), 15 deletions(-)

diffs (128 lines):

diff -r 1670d6a53f7e -r b5283f6e278c sys/arch/arm/cortex/gicv3.c
--- a/sys/arch/arm/cortex/gicv3.c       Thu Feb 13 00:02:40 2020 +0000
+++ b/sys/arch/arm/cortex/gicv3.c       Thu Feb 13 00:42:59 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3.c,v 1.22 2019/12/24 09:12:56 skrll Exp $ */
+/* $NetBSD: gicv3.c,v 1.23 2020/02/13 00:42:59 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
 #define        _INTR_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gicv3.c,v 1.22 2019/12/24 09:12:56 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3.c,v 1.23 2020/02/13 00:42:59 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -40,6 +40,7 @@
 #include <sys/intr.h>
 #include <sys/systm.h>
 #include <sys/cpu.h>
+#include <sys/vmem.h>
 
 #include <machine/cpufunc.h>
 
@@ -828,6 +829,11 @@
                snprintf(sc->sc_lpi.pic_name, sizeof(sc->sc_lpi.pic_name), "gicv3-lpi");
                pic_add(&sc->sc_lpi, GIC_LPI_BASE);
 
+               sc->sc_lpi_pool = vmem_create("gicv3-lpi", 0, sc->sc_lpi.pic_maxsources,
+                   1, NULL, NULL, NULL, 0, VM_SLEEP, IPL_HIGH);
+               if (sc->sc_lpi_pool == NULL)
+                       panic("failed to create gicv3 lpi pool\n");
+
                gicv3_lpi_init(sc);
        }
 
diff -r 1670d6a53f7e -r b5283f6e278c sys/arch/arm/cortex/gicv3.h
--- a/sys/arch/arm/cortex/gicv3.h       Thu Feb 13 00:02:40 2020 +0000
+++ b/sys/arch/arm/cortex/gicv3.h       Thu Feb 13 00:42:59 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3.h,v 1.7 2019/06/30 11:11:38 jmcneill Exp $ */
+/* $NetBSD: gicv3.h,v 1.8 2020/02/13 00:42:59 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -30,6 +30,7 @@
 #define _ARM_CORTEX_GICV3_H
 
 #include <sys/intr.h>
+#include <sys/vmem.h>
 
 struct gicv3_dma {
        bus_dma_segment_t       segs[1];
@@ -73,6 +74,9 @@
        /* LPI pending tables */
        struct gicv3_dma        sc_lpipend[MAXCPUS];
 
+       /* LPI IDs */
+       vmem_t                  *sc_lpi_pool;
+
        /* Unique identifier for PEs */
        u_int                   sc_processor_id[MAXCPUS];
 
diff -r 1670d6a53f7e -r b5283f6e278c sys/arch/arm/cortex/gicv3_its.c
--- a/sys/arch/arm/cortex/gicv3_its.c   Thu Feb 13 00:02:40 2020 +0000
+++ b/sys/arch/arm/cortex/gicv3_its.c   Thu Feb 13 00:42:59 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3_its.c,v 1.25 2020/02/01 15:33:48 jmcneill Exp $ */
+/* $NetBSD: gicv3_its.c,v 1.26 2020/02/13 00:42:59 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #define _INTR_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gicv3_its.c,v 1.25 2020/02/01 15:33:48 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3_its.c,v 1.26 2020/02/13 00:42:59 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -284,18 +284,19 @@
     const struct pci_attach_args *pa)
 {
        struct pci_attach_args *new_pa;
-       int n;
+       vmem_addr_t n;
+
+       KASSERT(its->its_gic->sc_lpi_pool != NULL);
 
-       for (n = 0; n < its->its_pic->pic_maxsources; n++) {
-               if (its->its_pa[n] == NULL) {
-                       new_pa = kmem_alloc(sizeof(*new_pa), KM_SLEEP);
-                       memcpy(new_pa, pa, sizeof(*new_pa));
-                       its->its_pa[n] = new_pa;
-                       return n + its->its_pic->pic_irqbase;
-               }
-       }
+       if (vmem_alloc(its->its_gic->sc_lpi_pool, 1, VM_INSTANTFIT|VM_SLEEP, &n) != 0)
+               return -1;
+       
+       KASSERT(its->its_pa[n] == NULL);
 
-        return -1;
+       new_pa = kmem_alloc(sizeof(*new_pa), KM_SLEEP);
+       memcpy(new_pa, pa, sizeof(*new_pa));
+       its->its_pa[n] = new_pa;
+       return n + its->its_pic->pic_irqbase;
 }
 
 static void
@@ -303,11 +304,14 @@
 {
        struct pci_attach_args *pa;
 
+       KASSERT(its->its_gic->sc_lpi_pool != NULL);
        KASSERT(lpi >= its->its_pic->pic_irqbase);
 
        pa = its->its_pa[lpi - its->its_pic->pic_irqbase];
        its->its_pa[lpi - its->its_pic->pic_irqbase] = NULL;
        kmem_free(pa, sizeof(*pa));
+
+       vmem_free(its->its_gic->sc_lpi_pool, lpi - its->its_pic->pic_irqbase, 1);
 }
 
 static uint32_t



Home | Main Index | Thread Index | Old Index