Author: jchandra
Date: Thu May 30 01:21:08 2019
New Revision: 348377
URL: https://svnweb.freebsd.org/changeset/base/348377

Log:
  gic_v3: consolidate per-cpu redistributor information
  
  Update 'struct gic_redists' to consolidate all per-cpu redistributor
  information into a new 'struct redist_pcpu'. Provide a new interface
  (GICV3_IVAR_REDIST) for the GIC driver, which can be used to retrieve
  the per-cpu data.
  
  This per-cpu redistributor struct will be later used to improve the
  GIC ITS setup.
  
  While there, remove some unused fields in gic_v3_var.h interface.
  No functional changes.
  
  Reviewed by:  andrew
  Differential Revision:        https://reviews.freebsd.org/D19842

Modified:
  head/sys/arm64/arm64/gic_v3.c
  head/sys/arm64/arm64/gic_v3_var.h
  head/sys/arm64/arm64/gicv3_its.c

Modified: head/sys/arm64/arm64/gic_v3.c
==============================================================================
--- head/sys/arm64/arm64/gic_v3.c       Wed May 29 23:50:31 2019        
(r348376)
+++ head/sys/arm64/arm64/gic_v3.c       Thu May 30 01:21:08 2019        
(r348377)
@@ -183,36 +183,44 @@ uint32_t
 gic_r_read_4(device_t dev, bus_size_t offset)
 {
        struct gic_v3_softc *sc;
+       struct resource *rdist;
 
        sc = device_get_softc(dev);
-       return (bus_read_4(sc->gic_redists.pcpu[PCPU_GET(cpuid)], offset));
+       rdist = &sc->gic_redists.pcpu[PCPU_GET(cpuid)]->res;
+       return (bus_read_4(rdist, offset));
 }
 
 uint64_t
 gic_r_read_8(device_t dev, bus_size_t offset)
 {
        struct gic_v3_softc *sc;
+       struct resource *rdist;
 
        sc = device_get_softc(dev);
-       return (bus_read_8(sc->gic_redists.pcpu[PCPU_GET(cpuid)], offset));
+       rdist = &sc->gic_redists.pcpu[PCPU_GET(cpuid)]->res;
+       return (bus_read_8(rdist, offset));
 }
 
 void
 gic_r_write_4(device_t dev, bus_size_t offset, uint32_t val)
 {
        struct gic_v3_softc *sc;
+       struct resource *rdist;
 
        sc = device_get_softc(dev);
-       bus_write_4(sc->gic_redists.pcpu[PCPU_GET(cpuid)], offset, val);
+       rdist = &sc->gic_redists.pcpu[PCPU_GET(cpuid)]->res;
+       bus_write_4(rdist, offset, val);
 }
 
 void
 gic_r_write_8(device_t dev, bus_size_t offset, uint64_t val)
 {
        struct gic_v3_softc *sc;
+       struct resource *rdist;
 
        sc = device_get_softc(dev);
-       bus_write_8(sc->gic_redists.pcpu[PCPU_GET(cpuid)], offset, val);
+       rdist = &sc->gic_redists.pcpu[PCPU_GET(cpuid)]->res;
+       bus_write_8(rdist, offset, val);
 }
 
 /*
@@ -384,8 +392,11 @@ gic_v3_read_ivar(device_t dev, device_t child, int whi
                return (0);
        case GICV3_IVAR_REDIST_VADDR:
                *result = (uintptr_t)rman_get_virtual(
-                   sc->gic_redists.pcpu[PCPU_GET(cpuid)]);
+                   &sc->gic_redists.pcpu[PCPU_GET(cpuid)]->res);
                return (0);
+       case GICV3_IVAR_REDIST:
+               *result = (uintptr_t)sc->gic_redists.pcpu[PCPU_GET(cpuid)];
+               return (0);
        case GIC_IVAR_HW_REV:
                KASSERT(
                    GICR_PIDR2_ARCH(sc->gic_pidr2) == GICR_PIDR2_ARCH_GICv3 ||
@@ -979,7 +990,7 @@ gic_v3_wait_for_rwp(struct gic_v3_softc *sc, enum gic_
                res = sc->gic_dist;
                break;
        case REDIST:
-               res = sc->gic_redists.pcpu[cpuid];
+               res = &sc->gic_redists.pcpu[cpuid]->res;
                break;
        default:
                KASSERT(0, ("%s: Attempt to wait for unknown RWP", __func__));
@@ -1173,7 +1184,7 @@ gic_v3_redist_find(struct gic_v3_softc *sc)
                                KASSERT(sc->gic_redists.pcpu[cpuid] != NULL,
                                    ("Invalid pointer to per-CPU 
redistributor"));
                                /* Copy res contents to its final destination */
-                               *sc->gic_redists.pcpu[cpuid] = r_res;
+                               sc->gic_redists.pcpu[cpuid]->res = r_res;
                                if (bootverbose) {
                                        device_printf(sc->dev,
                                            "CPU%u Re-Distributor has been 
found\n",

Modified: head/sys/arm64/arm64/gic_v3_var.h
==============================================================================
--- head/sys/arm64/arm64/gic_v3_var.h   Wed May 29 23:50:31 2019        
(r348376)
+++ head/sys/arm64/arm64/gic_v3_var.h   Thu May 30 01:21:08 2019        
(r348377)
@@ -40,10 +40,9 @@ DECLARE_CLASS(gic_v3_driver);
 
 struct gic_v3_irqsrc;
 
-struct redist_lpis {
-       vm_offset_t             conf_base;
-       vm_offset_t             pend_base[MAXCPU];
-       uint64_t                flags;
+struct redist_pcpu {
+       struct resource         res;
+       vm_offset_t             pend_base;
 };
 
 struct gic_redists {
@@ -55,10 +54,8 @@ struct gic_redists {
        struct resource **      regions;
        /* Number of Re-Distributor regions */
        u_int                   nregions;
-       /* Per-CPU Re-Distributor handler */
-       struct resource *       pcpu[MAXCPU];
-       /* LPIs data */
-       struct redist_lpis      lpis;
+       /* Per-CPU Re-Distributor data */
+       struct redist_pcpu      *pcpu[MAXCPU];
 };
 
 struct gic_v3_softc {
@@ -97,9 +94,11 @@ MALLOC_DECLARE(M_GIC_V3);
 /* ivars */
 #define        GICV3_IVAR_NIRQS        1000
 #define        GICV3_IVAR_REDIST_VADDR 1001
+#define        GICV3_IVAR_REDIST       1002
 
 __BUS_ACCESSOR(gicv3, nirqs, GICV3, NIRQS, u_int);
 __BUS_ACCESSOR(gicv3, redist_vaddr, GICV3, REDIST_VADDR, void *);
+__BUS_ACCESSOR(gicv3, redist, GICV3, REDIST, void *);
 
 /* Device methods */
 int gic_v3_attach(device_t dev);
@@ -131,7 +130,7 @@ void gic_r_write_8(device_t, bus_size_t, uint64_t var)
        u_int cpu = PCPU_GET(cpuid);            \
                                                \
        bus_read_##len(                         \
-           sc->gic_redists.pcpu[cpu],          \
+           &sc->gic_redists.pcpu[cpu]->res,    \
            reg);                               \
 })
 
@@ -140,7 +139,7 @@ void gic_r_write_8(device_t, bus_size_t, uint64_t var)
        u_int cpu = PCPU_GET(cpuid);            \
                                                \
        bus_write_##len(                        \
-           sc->gic_redists.pcpu[cpu],          \
+           &sc->gic_redists.pcpu[cpu]->res,    \
            reg, val);                          \
 })
 

Modified: head/sys/arm64/arm64/gicv3_its.c
==============================================================================
--- head/sys/arm64/arm64/gicv3_its.c    Wed May 29 23:50:31 2019        
(r348376)
+++ head/sys/arm64/arm64/gicv3_its.c    Thu May 30 01:21:08 2019        
(r348377)
@@ -577,6 +577,7 @@ gicv3_its_pendtables_init(struct gicv3_its_softc *sc)
 static int
 its_init_cpu(device_t dev, struct gicv3_its_softc *sc)
 {
+       struct redist_pcpu *rpcpu;
        device_t gicv3;
        vm_paddr_t target;
        uint64_t xbaser, tmp;
@@ -664,7 +665,8 @@ its_init_cpu(device_t dev, struct gicv3_its_softc *sc)
 
        if ((gic_its_read_8(sc, GITS_TYPER) & GITS_TYPER_PTA) != 0) {
                /* This ITS wants the redistributor physical address */
-               target = vtophys(gicv3_get_redist_vaddr(dev));
+               rpcpu = gicv3_get_redist(dev);
+               target = vtophys(rman_get_virtual(&rpcpu->res));
        } else {
                /* This ITS wants the unique processor number */
                target = GICR_TYPER_CPUNUM(gic_r_read_8(gicv3, GICR_TYPER));
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to