Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1735588 > unrolled thread

[PATCH] gpio: Wakeup gpio controller when it is used as IRQ controller

Started byMichal Simek <michal.simek@xilinx.com>
First post2017-09-20 09:20 +0200
Last post2017-09-21 14:20 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] gpio: Wakeup gpio controller when it is used as IRQ controller Michal Simek <michal.simek@xilinx.com> - 2017-09-20 09:20 +0200
    Re: [PATCH] gpio: Wakeup gpio controller when it is used as IRQ  controller Grygorii Strashko <grygorii.strashko@ti.com> - 2017-09-20 22:10 +0200
      Re: [PATCH] gpio: Wakeup gpio controller when it is used as IRQ controller Linus Walleij <linus.walleij@linaro.org> - 2017-09-21 14:20 +0200

#1735588 — [PATCH] gpio: Wakeup gpio controller when it is used as IRQ controller

FromMichal Simek <michal.simek@xilinx.com>
Date2017-09-20 09:20 +0200
Subject[PATCH] gpio: Wakeup gpio controller when it is used as IRQ controller
Message-ID<urHsC-8f3-25@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1736064 — Re: [PATCH] gpio: Wakeup gpio controller when it is used as IRQ controller

FromGrygorii Strashko <grygorii.strashko@ti.com>
Date2017-09-20 22:10 +0200
SubjectRe: [PATCH] gpio: Wakeup gpio controller when it is used as IRQ controller
Message-ID<urTtL-7M2-13@gated-at.bofh.it>
In reply to#1735588

On 09/20/2017 02:14 AM, Michal Simek wrote:
> 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.

I think, it should be solved already in genirq core.
commit be45beb "genirq: Add runtime power management support for IRQ chips"


> 
> 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);
>   }
>   
> 

-- 
regards,
-grygorii

[toc] | [prev] | [next] | [standalone]


#1736617

FromLinus Walleij <linus.walleij@linaro.org>
Date2017-09-21 14:20 +0200
Message-ID<us8Cu-Sx-19@gated-at.bofh.it>
In reply to#1736064
On Wed, Sep 20, 2017 at 10:07 PM, Grygorii Strashko
<grygorii.strashko@ti.com> wrote:
> On 09/20/2017 02:14 AM, Michal Simek wrote:
>> 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.
>
> I think, it should be solved already in genirq core.
> commit be45beb "genirq: Add runtime power management support for IRQ chips"

Michal, can you verify?

Yours,
Linus Walleij

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web