[PATCH v2 05/25] irqchip/gic-v3: Add FW info retrieval support

Marc Zyngier posted 25 patches 2 weeks, 3 days ago
There is a newer version of this series
[PATCH v2 05/25] irqchip/gic-v3: Add FW info retrieval support
Posted by Marc Zyngier 2 weeks, 3 days ago
Plug the new .get_info() callback into the GICv3 core driver,
using some of the existing PPI affinity handling infrastructure.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/irqchip/irq-gic-v3.c | 53 ++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index dbeb85677b08c..71c278ddd1e39 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -69,6 +69,8 @@ struct gic_chip_data {
 	bool			has_rss;
 	unsigned int		ppi_nr;
 	struct partition_desc	**ppi_descs;
+	struct partition_affinity *parts;
+	unsigned int		nr_parts;
 };
 
 #define T241_CHIPS_MAX		4
@@ -1796,11 +1798,58 @@ static int gic_irq_domain_select(struct irq_domain *d,
 	return d == partition_get_domain(gic_data.ppi_descs[ppi_idx]);
 }
 
+static int gic_irq_get_fwspec_info(struct irq_fwspec *fwspec, struct irq_fwspec_info *info)
+{
+	const struct cpumask *mask = NULL;
+
+	info->flags = 0;
+	info->affinity = NULL;
+
+	/* ACPI is not capable of describing PPI affinity -- yet */
+	if (!is_of_node(fwspec->fwnode))
+		return 0;
+
+	/* If the specifier provides an affinity, use it */
+	if (fwspec->param_count == 4 && fwspec->param[3]) {
+		struct fwnode_handle *fw;
+
+		switch (fwspec->param[0]) {
+		case 1:			/* PPI */
+		case 3:			/* EPPI */
+			break;
+		default:
+			return 0;
+		}
+
+		fw = of_node_to_fwnode(of_find_node_by_phandle(fwspec->param[3]));
+		if (!fw)
+			return -ENOENT;
+
+		for (int i = 0; i < gic_data.nr_parts; i++) {
+			if (gic_data.parts[i].partition_id == fw) {
+				mask = &gic_data.parts[i].mask;
+				break;
+			}
+		}
+
+		if (!mask)
+			return -ENOENT;
+	} else {
+		mask = cpu_possible_mask;
+	}
+
+	info->affinity = mask;
+	info->flags = IRQ_FWSPEC_INFO_AFFINITY_VALID;
+
+	return 0;
+}
+
 static const struct irq_domain_ops gic_irq_domain_ops = {
 	.translate = gic_irq_domain_translate,
 	.alloc = gic_irq_domain_alloc,
 	.free = gic_irq_domain_free,
 	.select = gic_irq_domain_select,
+	.get_fwspec_info = gic_irq_get_fwspec_info,
 };
 
 static int partition_domain_translate(struct irq_domain *d,
@@ -1839,6 +1888,7 @@ static int partition_domain_translate(struct irq_domain *d,
 static const struct irq_domain_ops partition_domain_ops = {
 	.translate = partition_domain_translate,
 	.select = gic_irq_domain_select,
+	.get_fwspec_info = gic_irq_get_fwspec_info,
 };
 
 static bool gic_enable_quirk_msm8996(void *data)
@@ -2231,6 +2281,9 @@ static void __init gic_populate_ppi_partitions(struct device_node *gic_node)
 		part_idx++;
 	}
 
+	gic_data.parts = parts;
+	gic_data.nr_parts = nr_parts;
+
 	for (i = 0; i < gic_data.ppi_nr; i++) {
 		unsigned int irq;
 		struct partition_desc *desc;
-- 
2.39.2
Re: [PATCH v2 05/25] irqchip/gic-v3: Add FW info retrieval support
Posted by Jonathan Cameron 2 weeks, 1 day ago
On Mon, 15 Sep 2025 09:56:42 +0100
Marc Zyngier <maz@kernel.org> wrote:

> Plug the new .get_info() callback into the GICv3 core driver,
> using some of the existing PPI affinity handling infrastructure.
> 
> Signed-off-by: Marc Zyngier <maz@kernel.org>
Hi Marc,

Yet another trivial comment. It's one of those days it seems :)

> ---
>  drivers/irqchip/irq-gic-v3.c | 53 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 53 insertions(+)
> 
> diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
> index dbeb85677b08c..71c278ddd1e39 100644
> --- a/drivers/irqchip/irq-gic-v3.c
> +++ b/drivers/irqchip/irq-gic-v3.c
> @@ -69,6 +69,8 @@ struct gic_chip_data {
>  	bool			has_rss;
>  	unsigned int		ppi_nr;
>  	struct partition_desc	**ppi_descs;
> +	struct partition_affinity *parts;
> +	unsigned int		nr_parts;
>  };
>  
>  #define T241_CHIPS_MAX		4
> @@ -1796,11 +1798,58 @@ static int gic_irq_domain_select(struct irq_domain *d,
>  	return d == partition_get_domain(gic_data.ppi_descs[ppi_idx]);
>  }
>  
> +static int gic_irq_get_fwspec_info(struct irq_fwspec *fwspec, struct irq_fwspec_info *info)
> +{
> +	const struct cpumask *mask = NULL;
> +
> +	info->flags = 0;
> +	info->affinity = NULL;
> +
> +	/* ACPI is not capable of describing PPI affinity -- yet */
> +	if (!is_of_node(fwspec->fwnode))
> +		return 0;
> +
> +	/* If the specifier provides an affinity, use it */
> +	if (fwspec->param_count == 4 && fwspec->param[3]) {
> +		struct fwnode_handle *fw;
> +
> +		switch (fwspec->param[0]) {
> +		case 1:			/* PPI */
> +		case 3:			/* EPPI */
> +			break;
> +		default:
> +			return 0;
> +		}
> +
> +		fw = of_node_to_fwnode(of_find_node_by_phandle(fwspec->param[3]));

of_node_to_fwnode() has a note that says it'll be removed in the merge window.
It was enough of an oddity I wondered why it existed.

Of course it did say it would be removed in the previous merge window and wasn't...
Probably want of_fwnode_handle()



> +		if (!fw)
> +			return -ENOENT;
> +
> +		for (int i = 0; i < gic_data.nr_parts; i++) {
> +			if (gic_data.parts[i].partition_id == fw) {
> +				mask = &gic_data.parts[i].mask;
> +				break;
> +			}
> +		}
> +
> +		if (!mask)
> +			return -ENOENT;
> +	} else {
> +		mask = cpu_possible_mask;
> +	}
> +
> +	info->affinity = mask;
> +	info->flags = IRQ_FWSPEC_INFO_AFFINITY_VALID;
> +
> +	return 0;
Re: [PATCH v2 05/25] irqchip/gic-v3: Add FW info retrieval support
Posted by Marc Zyngier 2 weeks, 1 day ago
On Tue, 16 Sep 2025 16:34:13 +0100,
Jonathan Cameron <jonathan.cameron@huawei.com> wrote:
> 
> On Mon, 15 Sep 2025 09:56:42 +0100
> Marc Zyngier <maz@kernel.org> wrote:
> 
> > Plug the new .get_info() callback into the GICv3 core driver,
> > using some of the existing PPI affinity handling infrastructure.
> > 
> > Signed-off-by: Marc Zyngier <maz@kernel.org>
> Hi Marc,
> 
> Yet another trivial comment. It's one of those days it seems :)

No worries, your trivial comments are far more interesting than some
of the emails I'm otherwise getting.. ;-)

> 
> > ---
> >  drivers/irqchip/irq-gic-v3.c | 53 ++++++++++++++++++++++++++++++++++++
> >  1 file changed, 53 insertions(+)
> > 
> > diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
> > index dbeb85677b08c..71c278ddd1e39 100644
> > --- a/drivers/irqchip/irq-gic-v3.c
> > +++ b/drivers/irqchip/irq-gic-v3.c
> > @@ -69,6 +69,8 @@ struct gic_chip_data {
> >  	bool			has_rss;
> >  	unsigned int		ppi_nr;
> >  	struct partition_desc	**ppi_descs;
> > +	struct partition_affinity *parts;
> > +	unsigned int		nr_parts;
> >  };
> >  
> >  #define T241_CHIPS_MAX		4
> > @@ -1796,11 +1798,58 @@ static int gic_irq_domain_select(struct irq_domain *d,
> >  	return d == partition_get_domain(gic_data.ppi_descs[ppi_idx]);
> >  }
> >  
> > +static int gic_irq_get_fwspec_info(struct irq_fwspec *fwspec, struct irq_fwspec_info *info)
> > +{
> > +	const struct cpumask *mask = NULL;
> > +
> > +	info->flags = 0;
> > +	info->affinity = NULL;
> > +
> > +	/* ACPI is not capable of describing PPI affinity -- yet */
> > +	if (!is_of_node(fwspec->fwnode))
> > +		return 0;
> > +
> > +	/* If the specifier provides an affinity, use it */
> > +	if (fwspec->param_count == 4 && fwspec->param[3]) {
> > +		struct fwnode_handle *fw;
> > +
> > +		switch (fwspec->param[0]) {
> > +		case 1:			/* PPI */
> > +		case 3:			/* EPPI */
> > +			break;
> > +		default:
> > +			return 0;
> > +		}
> > +
> > +		fw = of_node_to_fwnode(of_find_node_by_phandle(fwspec->param[3]));
> 
> of_node_to_fwnode() has a note that says it'll be removed in the merge window.
> It was enough of an oddity I wondered why it existed.

Cargo culted, obviously. And yet another sign that I've been sitting
on these patches for way too long...

> Of course it did say it would be removed in the previous merge window and wasn't...
> Probably want of_fwnode_handle()

Thanks for the hint, I'll add that to v3.

	M.

-- 
Without deviation from the norm, progress is not possible.