Skip to contentSkip to conversation

irqchip/stm32: Do not call stm32_gpio_get() for edge triggered IRQs in EOI

PATCH In review Marek Vasut 2 participants 2 messages Apr 15, 2022 – Apr 21, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 irqchip/stm32: Do not call stm32_gpio_get() for edge triggered IRQs in EOI

The stm32_gpio_get() should only be called for LEVEL triggered interrupts, skip calling it for EDGE triggered interrupts altogether to avoid wasting CPU cycles in EOI handler. On this platform, EDGE triggered interrupts are the majority and LEVEL triggered interrupts are the exception no less, and the CPU cycles are not abundant.

Fixes 47beed513a85b ("pinctrl: stm32: Add level interrupt support to gpio irq chip")
Cc Alexandre Torgue <[email protected]>
Cc Fabien Dessenne <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Marc Zyngier <[email protected]>

To: [email protected]

---
 drivers/pinctrl/stm32/pinctrl-stm32.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/pinctrl/stm32/pinctrl-stm32.c +4 -0
index 09952c463f67d..242d1c37c6e4b 100644
@@ -312,6 +312,10 @@ static void stm32_gpio_irq_trigger(struct irq_data *d)
 	struct stm32_gpio_bank *bank = d->domain->host_data;
 	int level;
 
+	/* Do not access the GPIO if this is not LEVEL triggered IRQ. */
+	if (!(bank->irq_type[d->hwirq] & IRQ_TYPE_LEVEL_MASK))
+		return;
+
 	/* If level interrupt type then retrig */
 	level = stm32_gpio_get(&bank->gpio_chip, d->hwirq);
 	if ((level == 0 && bank->irq_type[d->hwirq] == IRQ_TYPE_LEVEL_LOW) ||
Signature · 1 line
2.35.1
#1 lore raw
Quoted 14 lines · Marek Vasut

The stm32_gpio_get() should only be called for LEVEL triggered interrupts, skip calling it for EDGE triggered interrupts altogether to avoid wasting CPU cycles in EOI handler. On this platform, EDGE triggered interrupts are the majority and LEVEL triggered interrupts are the exception no less, and the CPU cycles are not abundant.

Fixes 47beed513a85b ("pinctrl: stm32: Add level interrupt support to gpio irq chip")
Cc Alexandre Torgue <[email protected]>
Cc Fabien Dessenne <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Marc Zyngier <[email protected]>
Quoted 1 line

To: [email protected]

Patch applied!

But I changed the subject to pinctrl: stm32:

Yours,
Linus Walleij