gpio-mt7621 unroutable IRQs to bank0

From: Vicente Bergas

Date: Sat May 02 2026 - 17:52:21 EST


Hi,
Grant Likely noticed a potential issue and
documented it as a comment in kernel/irq/irqdomain.c:
* We might want to match the legacy controller last since
* it might potentially be set to match all interrupts in
* the absence of a device node. This isn't a problem so far
* yet though...

There is a bug that is affecting me and
it is triggered by the forseen potential issue.

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.

--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -538,7 +538,6 @@ irq_find_matching_fwspec

if (rc) {
found = h;
- break;
}
}
mutex_unlock(&irq_domain_mutex);

For a bit more context, the platform used is an mt7628an.
The problematic device is:
&i2c {
pinctrl-names = "default";
pinctrl-0 = <&i2c_pins>;
status = "okay";
ft6336u: touchscreen@38 {
compatible = "focaltech,ft6236";
reg = <0x38>;
interrupt-parent = <&gpio>;
interrupts = <0 IRQ_TYPE_EDGE_FALLING>;
reset-gpios = <&gpio 2 GPIO_ACTIVE_LOW>;
};
};

Please, can you fix this bug?

I'll will be able to test, but because my platform is only supported
after applying openwrt patches, i can only test on v6.18.y.

Regards,
Vicente.