Skip to contentSkip to conversation

gpio: tegra: Fix wake interrupt

PATCH Applied Dmitry Osipenko 3 participants 6 messages Jan 12, 2021 – Jan 19, 2021

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

PATCH 1/2 gpio: tegra: Fix wake interrupt

The GPIO bank wake interrupt setting was erroneously removed after conversion to gpio_irq_chip, thus the wake interrupt programming is broken now. Secondly, the wake_enb of the GPIO driver should be changed only after the successful toggling of the IRQ wake-state. Restore the wake interrupt setting and the programming order.

Fixes efcdca286eef ("gpio: tegra: Convert to gpio_irq_chip")
---
 drivers/gpio/gpio-tegra.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/gpio/gpio-tegra.c +13 -3
index b8a4fd07c559..6c79e9d2f932 100644
@@ -541,6 +541,7 @@ static int tegra_gpio_irq_set_wake(struct irq_data *d, unsigned int enable)
 	struct tegra_gpio_bank *bank;
 	unsigned int gpio = d->hwirq;
 	u32 port, bit, mask;
+	int err;
 
 	bank = &tgi->bank_info[GPIO_BANK(d->hwirq)];
 
@@ -548,14 +549,23 @@ static int tegra_gpio_irq_set_wake(struct irq_data *d, unsigned int enable)
 	bit = GPIO_BIT(gpio);
 	mask = BIT(bit);
 
+	err = irq_set_irq_wake(tgi->irqs[bank->bank], enable);
+	if (err)
+		return err;
+
+	if (d->parent_data) {
+		err = irq_chip_set_wake_parent(d, enable);
+		if (err) {
+			irq_set_irq_wake(tgi->irqs[bank->bank], !enable);
+			return err;
+		}
+	}
+
 	if (enable)
 		bank->wake_enb[port] |= mask;
 	else
 		bank->wake_enb[port] &= ~mask;
 
-	if (d->parent_data)
-		return irq_chip_set_wake_parent(d, enable);
-
 	return 0;
 }
 #endif
Signature · 1 line
2.29.2
#1 lore raw

PATCH 2/2 gpio: tegra: Add dependency on GPIOLIB_IRQCHIP

Add dependency on GPIOLIB_IRQCHIP in order to fix driver compilation.

Fixes efcdca286eef ("gpio: tegra: Convert to gpio_irq_chip")
---
 drivers/gpio/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/gpio/Kconfig +1 -0
index 75f6c37620ea..0cd1f91e4a19 100644
@@ -597,6 +597,7 @@ config GPIO_TEGRA
 	default ARCH_TEGRA
 	depends on ARCH_TEGRA || COMPILE_TEST
 	depends on OF_GPIO
+	select GPIOLIB_IRQCHIP
 	help
 	  Say yes here to support GPIO pins on NVIDIA Tegra SoCs.
 
Signature · 1 line
2.29.2
#3 lore raw

Re: [PATCH v1 2/2] gpio: tegra: Add dependency on GPIOLIB_IRQCHIP

In reply to Dmitry Osipenko
Quoted 23 lines · Dmitry Osipenko

Add dependency on GPIOLIB_IRQCHIP in order to fix driver compilation.

Fixes efcdca286eef ("gpio: tegra: Convert to gpio_irq_chip")
---
 drivers/gpio/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/gpio/Kconfig +1 -1
index 75f6c37620ea..0cd1f91e4a19 100644
@@ -597,6 +597,7 @@ config GPIO_TEGRA
        default ARCH_TEGRA
        depends on ARCH_TEGRA || COMPILE_TEST
        depends on OF_GPIO
+       select GPIOLIB_IRQCHIP
        help
          Say yes here to support GPIO pins on NVIDIA Tegra SoCs.
 
--
Quoted 2 lines

2.29.2

Applied, thanks!

Bartosz

Acked-by on v1 1/2
#4 lore raw
In reply to Dmitry Osipenko
Quoted 8 lines · Dmitry Osipenko

The GPIO bank wake interrupt setting was erroneously removed after conversion to gpio_irq_chip, thus the wake interrupt programming is broken now. Secondly, the wake_enb of the GPIO driver should be changed only after the successful toggling of the IRQ wake-state. Restore the wake interrupt setting and the programming order.

Fixes efcdca286eef ("gpio: tegra: Convert to gpio_irq_chip")

Yours,
Linus Walleij

#5 lore raw
In reply to Dmitry Osipenko
Quoted 53 lines · Dmitry Osipenko

The GPIO bank wake interrupt setting was erroneously removed after conversion to gpio_irq_chip, thus the wake interrupt programming is broken now. Secondly, the wake_enb of the GPIO driver should be changed only after the successful toggling of the IRQ wake-state. Restore the wake interrupt setting and the programming order.

Fixes efcdca286eef ("gpio: tegra: Convert to gpio_irq_chip")
---
 drivers/gpio/gpio-tegra.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/gpio/gpio-tegra.c +13 -4
index b8a4fd07c559..6c79e9d2f932 100644
@@ -541,6 +541,7 @@ static int tegra_gpio_irq_set_wake(struct irq_data *d, unsigned int enable)
        struct tegra_gpio_bank *bank;
        unsigned int gpio = d->hwirq;
        u32 port, bit, mask;
+       int err;
 
        bank = &tgi->bank_info[GPIO_BANK(d->hwirq)];
 
@@ -548,14 +549,23 @@ static int tegra_gpio_irq_set_wake(struct irq_data *d, unsigned int enable)
        bit = GPIO_BIT(gpio);
        mask = BIT(bit);
 
+       err = irq_set_irq_wake(tgi->irqs[bank->bank], enable);
+       if (err)
+               return err;
+
+       if (d->parent_data) {
+               err = irq_chip_set_wake_parent(d, enable);
+               if (err) {
+                       irq_set_irq_wake(tgi->irqs[bank->bank], !enable);
+                       return err;
+               }
+       }
+
        if (enable)
                bank->wake_enb[port] |= mask;
        else
                bank->wake_enb[port] &= ~mask;
 
-       if (d->parent_data)
-               return irq_chip_set_wake_parent(d, enable);
-
        return 0;
 }
 #endif
--
Quoted 2 lines

2.29.2

Applied, thanks!

Bartosz