All of lore.kernel.org
 help / color / mirror / Atom feed
* gpio-mt7621 unroutable IRQs to bank0
@ 2026-05-02 21:52 Vicente Bergas
  2026-05-05 12:01 ` Linus Walleij
  0 siblings, 1 reply; 15+ messages in thread
From: Vicente Bergas @ 2026-05-02 21:52 UTC (permalink / raw)
  To: Linus Walleij, Sergio Paracuellos, Bartosz Golaszewski,
	Thomas Gleixner, Grant Likely, Anna-Maria Behnsen
  Cc: Linux Kernel Mailing List, linux-gpio

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.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2026-05-26 11:52 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-02 21:52 gpio-mt7621 unroutable IRQs to bank0 Vicente Bergas
2026-05-05 12:01 ` Linus Walleij
2026-05-05 14:21   ` Thomas Gleixner
2026-05-05 15:05     ` Sergio Paracuellos
2026-05-05 21:36       ` Vicente Bergas
2026-05-06 17:43         ` Sergio Paracuellos
2026-05-06 22:32           ` Vicente Bergas
2026-05-07  4:06             ` Sergio Paracuellos
2026-05-07  8:54               ` Linus Walleij
2026-05-07 10:52                 ` Sergio Paracuellos
2026-05-12  0:17                   ` Vicente Bergas
2026-05-14 12:00                     ` Sergio Paracuellos
2026-05-22  7:29                       ` [RFC PATCH] gpio: mt7621: fix interrupt banks mapping on gpio chips Sergio Paracuellos
2026-05-26 11:38                         ` Bartosz Golaszewski
2026-05-26 11:51                           ` Sergio Paracuellos

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.