diff mbox series

[Xen-devel,4/7] ARM: GICv3: use hardware GICv3 redistributor regions for Dom0

Message ID 20180124143517.18469-5-andre.przywara@linaro.org
State New
Headers show
Series ARM: vGICv3: clean up optional DT properties | expand

Commit Message

Andre Przywara Jan. 24, 2018, 2:35 p.m. UTC
The code to generate the DT node or MADT table for Dom0 reaches into the
domain's VGIC structure to learn the number of redistributor regions and
their base addresses.
Since those values are copied from the hardware, we can as well use
those hardware values directly when setting up the hardware domain.

This avoids the hardware GIC code to reference vGIC data structures,
making this variable VGIC internal.

Signed-off-by: Andre Przywara <andre.przywara@linaro.org>
---
 xen/arch/arm/gic-v3.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

Comments

Julien Grall Jan. 24, 2018, 4:47 p.m. UTC | #1
Hi Andre,

On 24/01/18 14:35, Andre Przywara wrote:
> The code to generate the DT node or MADT table for Dom0 reaches into the
> domain's VGIC structure to learn the number of redistributor regions and
> their base addresses.
> Since those values are copied from the hardware, we can as well use
> those hardware values directly when setting up the hardware domain.

Now the function is using a mix of fields (see dbase) from vgic and 
gicv3. Please either remove all or none.

> 
> This avoids the hardware GIC code to reference vGIC data structures,
> making this variable VGIC internal.

I don't understand the bits after the comma.

> 
> Signed-off-by: Andre Przywara <andre.przywara@linaro.org>
> ---
>   xen/arch/arm/gic-v3.c | 21 ++++++++++-----------
>   1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
> index 9ad0cd19ef..1c24ecbba7 100644
> --- a/xen/arch/arm/gic-v3.c
> +++ b/xen/arch/arm/gic-v3.c
> @@ -1168,10 +1168,10 @@ static int gicv3_make_hwdom_dt_node(const struct domain *d,
>       if ( res )
>           return res;
>   
> -    if ( d->arch.vgic.nr_regions > 1 )
> +    if ( gicv3.rdist_count > 1 )
>       {
>           res = fdt_property_cell(fdt, "#redistributor-regions",
> -                                d->arch.vgic.nr_regions);
> +                                gicv3.rdist_count);
>           if ( res )
>               return res;
>       }
> @@ -1182,7 +1182,7 @@ static int gicv3_make_hwdom_dt_node(const struct domain *d,
>        * CPU interface and virtual cpu interfaces accessesed as System registers
>        * So cells are created only for Distributor and rdist regions
>        */
> -    len = len * (d->arch.vgic.nr_regions + 1);
> +    len = len * (gicv3.rdist_count + 1);
>       new_cells = xzalloc_bytes(len);
>       if ( new_cells == NULL )
>           return -FDT_ERR_XEN(ENOMEM);
> @@ -1191,9 +1191,9 @@ static int gicv3_make_hwdom_dt_node(const struct domain *d,
>   
>       dt_set_range(&tmp, gic, d->arch.vgic.dbase, SZ_64K);
>   
> -    for ( i = 0; i < d->arch.vgic.nr_regions; i++ )
> -        dt_set_range(&tmp, gic, d->arch.vgic.rdist_regions[i].base,
> -                     d->arch.vgic.rdist_regions[i].size);
> +    for ( i = 0; i < gicv3.rdist_count; i++ )
> +        dt_set_range(&tmp, gic, gicv3.rdist_regions[i].base,
> +                     gicv3.rdist_regions[i].size);
>   
>       res = fdt_property(fdt, "reg", new_cells, len);
>       xfree(new_cells);
> @@ -1419,13 +1419,13 @@ static int gicv3_make_hwdom_madt(const struct domain *d, u32 offset)
>   
>       /* Add Generic Redistributor */
>       size = sizeof(struct acpi_madt_generic_redistributor);
> -    for ( i = 0; i < d->arch.vgic.nr_regions; i++ )
> +    for ( i = 0; i < gicv3.rdist_count; i++ )
>       {
>           gicr = (struct acpi_madt_generic_redistributor *)(base_ptr + table_len);
>           gicr->header.type = ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR;
>           gicr->header.length = size;
> -        gicr->base_address = d->arch.vgic.rdist_regions[i].base;
> -        gicr->length = d->arch.vgic.rdist_regions[i].size;
> +        gicr->base_address = gicv3.rdist_regions[i].base;
> +        gicr->length = gicv3.rdist_regions[i].size;
>           table_len += size;
>       }
>   
> @@ -1438,8 +1438,7 @@ static unsigned long gicv3_get_hwdom_extra_madt_size(const struct domain *d)
>   {
>       unsigned long size;
>   
> -    size = sizeof(struct acpi_madt_generic_redistributor)
> -           * d->arch.vgic.nr_regions;
> +    size = sizeof(struct acpi_madt_generic_redistributor) * gicv3.rdist_count;
>   
>       size += sizeof(struct acpi_madt_generic_translator)
>               * vgic_v3_its_count(d);
> 

Cheers,
diff mbox series

Patch

diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index 9ad0cd19ef..1c24ecbba7 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -1168,10 +1168,10 @@  static int gicv3_make_hwdom_dt_node(const struct domain *d,
     if ( res )
         return res;
 
-    if ( d->arch.vgic.nr_regions > 1 )
+    if ( gicv3.rdist_count > 1 )
     {
         res = fdt_property_cell(fdt, "#redistributor-regions",
-                                d->arch.vgic.nr_regions);
+                                gicv3.rdist_count);
         if ( res )
             return res;
     }
@@ -1182,7 +1182,7 @@  static int gicv3_make_hwdom_dt_node(const struct domain *d,
      * CPU interface and virtual cpu interfaces accessesed as System registers
      * So cells are created only for Distributor and rdist regions
      */
-    len = len * (d->arch.vgic.nr_regions + 1);
+    len = len * (gicv3.rdist_count + 1);
     new_cells = xzalloc_bytes(len);
     if ( new_cells == NULL )
         return -FDT_ERR_XEN(ENOMEM);
@@ -1191,9 +1191,9 @@  static int gicv3_make_hwdom_dt_node(const struct domain *d,
 
     dt_set_range(&tmp, gic, d->arch.vgic.dbase, SZ_64K);
 
-    for ( i = 0; i < d->arch.vgic.nr_regions; i++ )
-        dt_set_range(&tmp, gic, d->arch.vgic.rdist_regions[i].base,
-                     d->arch.vgic.rdist_regions[i].size);
+    for ( i = 0; i < gicv3.rdist_count; i++ )
+        dt_set_range(&tmp, gic, gicv3.rdist_regions[i].base,
+                     gicv3.rdist_regions[i].size);
 
     res = fdt_property(fdt, "reg", new_cells, len);
     xfree(new_cells);
@@ -1419,13 +1419,13 @@  static int gicv3_make_hwdom_madt(const struct domain *d, u32 offset)
 
     /* Add Generic Redistributor */
     size = sizeof(struct acpi_madt_generic_redistributor);
-    for ( i = 0; i < d->arch.vgic.nr_regions; i++ )
+    for ( i = 0; i < gicv3.rdist_count; i++ )
     {
         gicr = (struct acpi_madt_generic_redistributor *)(base_ptr + table_len);
         gicr->header.type = ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR;
         gicr->header.length = size;
-        gicr->base_address = d->arch.vgic.rdist_regions[i].base;
-        gicr->length = d->arch.vgic.rdist_regions[i].size;
+        gicr->base_address = gicv3.rdist_regions[i].base;
+        gicr->length = gicv3.rdist_regions[i].size;
         table_len += size;
     }
 
@@ -1438,8 +1438,7 @@  static unsigned long gicv3_get_hwdom_extra_madt_size(const struct domain *d)
 {
     unsigned long size;
 
-    size = sizeof(struct acpi_madt_generic_redistributor)
-           * d->arch.vgic.nr_regions;
+    size = sizeof(struct acpi_madt_generic_redistributor) * gicv3.rdist_count;
 
     size += sizeof(struct acpi_madt_generic_translator)
             * vgic_v3_its_count(d);