linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] irqchip/stm32: Do not call stm32_gpio_get() for edge triggered IRQs in EOI
@ 2022-04-15 21:54 Marek Vasut
  2022-04-21 14:31 ` Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: Marek Vasut @ 2022-04-15 21:54 UTC (permalink / raw)
  To: linux-gpio
  Cc: Marek Vasut, Alexandre Torgue, Fabien Dessenne, Linus Walleij,
	Marc Zyngier, linux-stm32, linux-arm-kernel

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")
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Fabien Dessenne <fabien.dessenne@foss.st.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Marc Zyngier <maz@kernel.org>
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-arm-kernel@lists.infradead.org
To: linux-gpio@vger.kernel.org
---
 drivers/pinctrl/stm32/pinctrl-stm32.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
index 09952c463f67d..242d1c37c6e4b 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
@@ -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) ||
-- 
2.35.1


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

* Re: [PATCH] irqchip/stm32: Do not call stm32_gpio_get() for edge triggered IRQs in EOI
  2022-04-15 21:54 [PATCH] irqchip/stm32: Do not call stm32_gpio_get() for edge triggered IRQs in EOI Marek Vasut
@ 2022-04-21 14:31 ` Linus Walleij
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2022-04-21 14:31 UTC (permalink / raw)
  To: Marek Vasut
  Cc: linux-gpio, Alexandre Torgue, Fabien Dessenne, Marc Zyngier,
	linux-stm32, linux-arm-kernel

On Fri, Apr 15, 2022 at 11:54 PM Marek Vasut <marex@denx.de> wrote:

> 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")
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
> Cc: Fabien Dessenne <fabien.dessenne@foss.st.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Marc Zyngier <maz@kernel.org>
> Cc: linux-stm32@st-md-mailman.stormreply.com
> Cc: linux-arm-kernel@lists.infradead.org
> To: linux-gpio@vger.kernel.org

Patch applied!

But I changed the subject to pinctrl: stm32:

Yours,
Linus Walleij

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

end of thread, other threads:[~2022-04-21 14:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-15 21:54 [PATCH] irqchip/stm32: Do not call stm32_gpio_get() for edge triggered IRQs in EOI Marek Vasut
2022-04-21 14:31 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).