mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] gpio: Wakeup gpio controller when it is used as IRQ controller
@ 2017-09-20  7:14 Michal Simek
  2017-09-20 20:07 ` Grygorii Strashko
  2017-09-22  0:08 ` kbuild test robot
  0 siblings, 2 replies; 5+ messages in thread
From: Michal Simek @ 2017-09-20  7:14 UTC (permalink / raw)
  To: linux-kernel, monstr; +Cc: Borsodi Petr, Linus Walleij, linux-gpio

From: Borsodi Petr <Petr.Borsodi@i.cz>

There is a problem with GPIO driver when used as IRQ controller.
It is not working because the module is sleeping (clock is disabled).
The patch enables clocks when IP is used as IRQ controller.

Signed-off-by: Borsodi Petr <Petr.Borsodi@i.cz>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Based on discussion with Linus here https://lkml.org/lkml/2017/8/22/400
---
 drivers/gpio/gpiolib.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index eb80dac4e26a..17258ad1fadb 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1676,14 +1676,22 @@ static void gpiochip_irq_unmap(struct irq_domain *d, unsigned int irq)
 static int gpiochip_irq_reqres(struct irq_data *d)
 {
 	struct gpio_chip *chip = irq_data_get_irq_chip_data(d);
+	int ret;
 
 	if (!try_module_get(chip->gpiodev->owner))
 		return -ENODEV;
 
+	ret = pm_runtime_get_sync(chip->parent);
+	if (ret < 0) {
+		module_put(chip->gpiodev->owner);
+		return ret;
+	}
+
 	if (gpiochip_lock_as_irq(chip, d->hwirq)) {
 		chip_err(chip,
 			"unable to lock HW IRQ %lu for IRQ\n",
 			d->hwirq);
+		pm_runtime_put(chip->parent);
 		module_put(chip->gpiodev->owner);
 		return -EINVAL;
 	}
@@ -1695,6 +1703,7 @@ static void gpiochip_irq_relres(struct irq_data *d)
 	struct gpio_chip *chip = irq_data_get_irq_chip_data(d);
 
 	gpiochip_unlock_as_irq(chip, d->hwirq);
+	pm_runtime_put(chip->parent);
 	module_put(chip->gpiodev->owner);
 }
 
-- 
1.9.1

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

end of thread, other threads:[~2017-10-16 13:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-20  7:14 [PATCH] gpio: Wakeup gpio controller when it is used as IRQ controller Michal Simek
2017-09-20 20:07 ` Grygorii Strashko
2017-09-21 12:19   ` Linus Walleij
2017-10-16 13:40     ` Michal Simek
2017-09-22  0:08 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®