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 Stop searching for redistributors in a regi...



details:   https://anonhg.NetBSD.org/src/rev/1f439e5f980a
branches:  trunk
changeset: 993774:1f439e5f980a
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Sep 29 18:27:36 2018 +0000

description:
Stop searching for redistributors in a region after we find a redistributor
with the Last bit set in GICR_TYPER.

diffstat:

 sys/arch/arm/fdt/gicv3_fdt.c |  23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diffs (75 lines):

diff -r a104f0a38d18 -r 1f439e5f980a sys/arch/arm/fdt/gicv3_fdt.c
--- a/sys/arch/arm/fdt/gicv3_fdt.c      Sat Sep 29 18:00:35 2018 +0000
+++ b/sys/arch/arm/fdt/gicv3_fdt.c      Sat Sep 29 18:27:36 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3_fdt.c,v 1.2 2018/08/12 21:44:17 jmcneill Exp $ */
+/* $NetBSD: gicv3_fdt.c,v 1.3 2018/09/29 18:27:36 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015-2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
 #define        _INTR_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.2 2018/08/12 21:44:17 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.3 2018/09/29 18:27:36 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -44,6 +44,7 @@
 #include <dev/fdt/fdtvar.h>
 
 #include <arm/cortex/gicv3.h>
+#include <arm/cortex/gic_reg.h>
 
 #define        GICV3_MAXIRQ    1020
 
@@ -163,7 +164,7 @@
        bus_size_t size, region_off;
        bus_addr_t addr;
        size_t reg_off;
-       int n, r;
+       int n, r, max_redist, redist;
 
        if (of_getprop_uint32(phandle, "#redistributor-regions", &redistributor_regions))
                redistributor_regions = 1;
@@ -185,15 +186,15 @@
        /*
         * GIC Redistributors (GICR)
         */
-       for (reg_off = 1, n = 0; n < redistributor_regions; n++, reg_off++) {
+       for (reg_off = 1, max_redist = 0, n = 0; n < redistributor_regions; n++, reg_off++) {
                if (fdtbus_get_reg(phandle, reg_off, NULL, &size) != 0) {
                        aprint_error_dev(gic->sc_dev, "couldn't get redistributor registers\n");
                        return ENXIO;
                }
-               gic->sc_bsh_r_count += howmany(size, redistributor_stride);
+               max_redist += howmany(size, redistributor_stride);
        }
-       gic->sc_bsh_r = kmem_alloc(sizeof(bus_space_handle_t) * gic->sc_bsh_r_count, KM_SLEEP);
-       for (reg_off = 1, n = 0; n < redistributor_regions; n++, reg_off++) {
+       gic->sc_bsh_r = kmem_alloc(sizeof(bus_space_handle_t) * max_redist, KM_SLEEP);
+       for (reg_off = 1, redist = 0, n = 0; n < redistributor_regions; n++, reg_off++) {
                if (fdtbus_get_reg(phandle, reg_off, &addr, &size) != 0) {
                        aprint_error_dev(gic->sc_dev, "couldn't get redistributor registers\n");
                        return ENXIO;
@@ -204,12 +205,18 @@
                }
                const int count = howmany(size, redistributor_stride);
                for (r = 0, region_off = 0; r < count; r++, region_off += redistributor_stride) {
-                       if (bus_space_subregion(sc->sc_gic.sc_bst, bsh, region_off, redistributor_stride, &gic->sc_bsh_r[r]) != 0) {
+                       if (bus_space_subregion(sc->sc_gic.sc_bst, bsh, region_off, redistributor_stride, &gic->sc_bsh_r[redist++]) != 0) {
                                aprint_error_dev(gic->sc_dev, "couldn't subregion redistributor registers\n");
                                return ENXIO;
                        }
+
+                       /* If this is the last redist in this region, skip to the next one */
+                       const uint32_t typer = bus_space_read_4(sc->sc_gic.sc_bst, gic->sc_bsh_r[redist - 1], GICR_TYPER);
+                       if (typer & GICR_TYPER_Last)
+                               break;
                }
        }
+       gic->sc_bsh_r_count = redist;
 
        return 0;
 }



Home | Main Index | Thread Index | Old Index