Re: gpio-mt7621 unroutable IRQs to bank0

From: Linus Walleij

Date: Tue May 05 2026 - 08:01:49 EST


Hi Vicente,

On Sat, May 2, 2026 at 11:52 PM Vicente Bergas <vicencb@xxxxxxxxx> wrote:

> drivers/gpio/gpio-mt7621.c is registering 96 GPIOs,
> all of them capable of generating IRQs.
> But the `struct irq_chip` can only handle 32 IRQs,
> so, 3 banks are instantiated.
>
> The DTS file specifies the interrupt for one device as
> interrupt-parent = <&gpio>;
> interrupts = <0 IRQ_TYPE_EDGE_FALLING>;
> which should be routed to Bank0 GPIO0 but
> it is instead routed to Bank2. This is the bug.
>
> The call trace that leads to the problem is:
> drivers/i2c/i2c-core-base.c:i2c_device_probe
> drivers/base/property.c:fwnode_irq_get
> drivers/of/irq.c:of_irq_get
> include/linux/irqdomain.h:irq_find_host
> include/linux/irqdomain.h:irq_find_matching_host
> include/linux/irqdomain.h:irq_find_matching_fwnode
> kernel/irq/irqdomain.c:irq_find_matching_fwspec
>
> As a way to prove that this is indeed the problem,
> the following workaround makes it work.
> It just inverts the sorting order of all matches,
> so it picks Bank0 instead of Bank2.

That's a tricksy bug, I can't exactly see where the issue
is.

I think to solve this you might need to allocate an external
irqdomain that deal with the three different gpiochip
instances when translating the irqs.

There is gpiochip_irqchip_add_domain() which is currently
only used in drivers/gpio/gpio-regmap.c, but it should do
the trick I think.

Yours,
Linus Walleij