[PATCH v2] irqchip/gic-v3: Pass #redistributor-regions to gic_of_setup_kvm_info()

From: Geert Uytterhoeven
Date: Tue Jul 02 2024 - 05:24:39 EST


The caller of gic_of_setup_kvm_info() already queried DT for the value
of the #redistributor-regions property. So just pass this value,
instead of doing the DT look-up again in the callee.

Signed-off-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
Acked-by: Marc Zyngier <maz@xxxxxxxxxx>
---
This is v2 of "irqchip/gic-v3: Pass GICV index to
gic_of_setup_kvm_info()".

v2:
- Pass nr_redist_regions instead of gicv_idx,
- Keep comment about skipping GICD, GICC, GICH,
- Add Acked-by.
---
drivers/irqchip/irq-gic-v3.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index 1f70262742f3b7c7..79a8a2f189e94c7f 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -2185,11 +2185,10 @@ static void __init gic_populate_ppi_partitions(struct device_node *gic_node)
of_node_put(parts_node);
}

-static void __init gic_of_setup_kvm_info(struct device_node *node)
+static void __init gic_of_setup_kvm_info(struct device_node *node, u32 nr_redist_regions)
{
int ret;
struct resource r;
- u32 gicv_idx;

gic_v3_kvm_info.type = GIC_V3;

@@ -2197,12 +2196,8 @@ static void __init gic_of_setup_kvm_info(struct device_node *node)
if (!gic_v3_kvm_info.maint_irq)
return;

- if (of_property_read_u32(node, "#redistributor-regions",
- &gicv_idx))
- gicv_idx = 1;
-
- gicv_idx += 3; /* Also skip GICD, GICC, GICH */
- ret = of_address_to_resource(node, gicv_idx, &r);
+ /* Also skip GICD, GICC, GICH */
+ ret = of_address_to_resource(node, nr_redist_regions + 3, &r);
if (!ret)
gic_v3_kvm_info.vcpu = r;

@@ -2292,7 +2287,7 @@ static int __init gic_of_init(struct device_node *node, struct device_node *pare
gic_populate_ppi_partitions(node);

if (static_branch_likely(&supports_deactivate_key))
- gic_of_setup_kvm_info(node);
+ gic_of_setup_kvm_info(node, nr_redist_regions);
return 0;

out_unmap_rdist:
--
2.34.1