[tip: irq/drivers] irqchip/al-fic: Switch to shared parent interrupt

From: tip-bot2 for Eliav Farber

Date: Thu Oct 15 2026 - 08:39:12 EST


The following commit has been merged into the irq/drivers branch of tip:

Commit-ID: 8db4c1dede9b7adb53e2ff3e448718d5e924ec35
Gitweb: https://git.kernel.org/tip/8db4c1dede9b7adb53e2ff3e448718d5e924ec35
Author: Eliav Farber <farbere@xxxxxxxxxx>
AuthorDate: Sun, 11 Oct 2026 05:04:44
Committer: Thomas Gleixner <tglx@xxxxxxxxxx>
CommitterDate: Thu, 15 Oct 2026 14:25:06 +02:00

irqchip/al-fic: Switch to shared parent interrupt

Until now the driver requested its parent interrupt using the chained IRQ
API (irq_set_chained_handler_and_data()), which only works when each
parent interrupt is wired to a single FIC instance.

A FIC controller is built from groups, each described by its own DT node,
and the groups of one controller share that controller's output line
toward the parent. So a real devicetree has several FIC nodes on one
parent GIC SPI, and a chained handler can only be installed once per
parent. Cascading compounds this: an aggregating group collects several
peripherals' outputs onto the line above it.

To support that, request the parent interrupt as a shared interrupt
(IRQF_SHARED) instead of installing a chained handler. The handler now has
the standard irqreturn_t prototype and reports whether this instance had
anything pending, so the shared-IRQ core can tell which instance on the
line raised the interrupt. IRQF_NO_THREAD is set because the handler only
demultiplexes to the child domain and must not be forced-threaded; all
instances sharing a parent line agree on this flag, as the shared-IRQ core
requires.

The handler reads the group's cause register and returns IRQ_HANDLED when
any unmasked cause bit is set, IRQ_NONE otherwise. That is the signal the
shared-IRQ core needs - "did this instance's hardware raise the line" -
rather than the result of dispatching to the child domain.

For that filter to be right, gc->mask_cache must be valid before the parent
is requested. IRQ_GC_INIT_MASK_CACHE seeds it from the mask register only
on the first child mapping, and never at all for a group with no consumer
in the devicetree; until then the cache reads 0 and every latched cause bit
passes the filter. Seed it from the value al_fic_wire_init() programmed and
drop the flag; nothing can change the register in between, so the read
could only have returned that same value.

request_irq() can fail, unlike irq_set_chained_handler_and_data(), so add
an error path for it. Set IRQ_DOMAIN_FLAG_DESTROY_GC on the domain after
creating it, so irq_domain_remove() tears the generic chips down too and
the single call suffices for both the chip-allocation and request_irq()
failure paths.

Co-developed-by: Talel Shenhar <talel@xxxxxxxxxx>
Signed-off-by: Talel Shenhar <talel@xxxxxxxxxx>
Signed-off-by: Eliav Farber <farbere@xxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxx>
Reviewed-by: Radu Rendec <radu@xxxxxxxxxx>
Link: https://patch.msgid.link/20261011050449.41903-6-farbere@xxxxxxxxxx
---
drivers/irqchip/irq-al-fic.c | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/drivers/irqchip/irq-al-fic.c b/drivers/irqchip/irq-al-fic.c
index 30740d7..e664c33 100644
--- a/drivers/irqchip/irq-al-fic.c
+++ b/drivers/irqchip/irq-al-fic.c
@@ -4,9 +4,9 @@
*/

#include <linux/bitfield.h>
+#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/irqchip.h>
-#include <linux/irqchip/chained_irq.h>
#include <linux/irqdomain.h>
#include <linux/module.h>
#include <linux/of.h>
@@ -94,24 +94,21 @@ static int al_fic_irq_set_type(struct irq_data *data, unsigned int flow_type)
return 0;
}

-static void al_fic_irq_handler(struct irq_desc *desc)
+static irqreturn_t al_fic_irq_handler(int irq, void *data)
{
- struct al_fic *fic = irq_desc_get_handler_data(desc);
- struct irq_chip *irqchip = irq_desc_get_chip(desc);
+ struct al_fic *fic = data;
struct irq_domain *domain = fic->domain;
struct irq_chip_generic *gc = irq_get_domain_generic_chip(domain, 0);
unsigned long pending;
u32 hwirq;

- chained_irq_enter(irqchip, desc);
-
pending = readl_relaxed(fic->base + AL_FIC_CAUSE);
pending &= ~gc->mask_cache;

for_each_set_bit(hwirq, &pending, NR_FIC_IRQS)
generic_handle_domain_irq(domain, hwirq);

- chained_irq_exit(irqchip, desc);
+ return pending ? IRQ_HANDLED : IRQ_NONE;
}

static int al_fic_irq_retrigger(struct irq_data *data)
@@ -136,9 +133,15 @@ static int al_fic_register(struct device_node *node, struct al_fic *fic)
return -ENOMEM;
}

+ /*
+ * Let irq_domain_remove() free the generic chips on either error path
+ * below, instead of calling irq_domain_remove_generic_chips() by hand.
+ */
+ fic->domain->flags |= IRQ_DOMAIN_FLAG_DESTROY_GC;
+
ret = irq_alloc_domain_generic_chips(fic->domain, NR_FIC_IRQS,
1, of_node_full_name(fic->node), handle_level_irq,
- 0, 0, IRQ_GC_INIT_MASK_CACHE);
+ 0, 0, 0);
if (ret) {
pr_err("fail to allocate generic chip (%d)\n", ret);
goto err_domain_remove;
@@ -156,7 +159,21 @@ static int al_fic_register(struct device_node *node, struct al_fic *fic)
gc->chip_types->chip.flags = IRQCHIP_SKIP_SET_WAKE;
gc->private = fic;

- irq_set_chained_handler_and_data(fic->parent_irq, al_fic_irq_handler, fic);
+ /*
+ * Seed the mask cache with the value al_fic_wire_init() programmed,
+ * rather than having the generic chip read the register back on the
+ * first child mapping: that is later than the parent is requested, and
+ * never happens at all for a group with no consumer in the devicetree.
+ */
+ gc->mask_cache = ~0U;
+
+ ret = request_irq(fic->parent_irq, al_fic_irq_handler, IRQF_NO_THREAD | IRQF_SHARED,
+ of_node_full_name(fic->node), fic);
+ if (ret) {
+ pr_err("fail to request irq (%d)\n", ret);
+ goto err_domain_remove;
+ }
+
return 0;

err_domain_remove: