linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	linux-gpio@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	Jon Hunter <jonathanh@nvidia.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>
Subject: Re: [PATCH 2/2] gpio: rcar: Fine-grained Runtime PM support
Date: Thu, 08 Dec 2016 23:40:42 +0200	[thread overview]
Message-ID: <1984659.qgJsdhyW2B@avalon> (raw)
In-Reply-To: <20161208173228.16835-3-niklas.soderlund+renesas@ragnatech.se>

Hi Niklas,

Thank you for the patch.

On Thursday 08 Dec 2016 18:32:28 Niklas Söderlund wrote:
> From: Geert Uytterhoeven <geert+renesas@glider.be>
> 
> Currently gpio modules are runtime-resumed at probe time. This means the
> gpio module will be active all the time (except during system suspend,
> if not configured as a wake-up source).
> 
> While an R-Car Gen2 gpio module retains pins configured for output at
> the requested level while put in standby mode, gpio register cannot be
> accessed while suspended.  Unfortunately pm_runtime_get_sync() cannot be
> called from all contexts where gpio register access is needed. Hence
> move the Runtime PM handling from probe/remove time to gpio request/free
> time, which is probably the best we can do.
> 
> On r8a7791/koelsch, gpio modules 0, 1, 3, and 4 are now suspended during
> normal use (gpio2 is used for LEDs and regulators, gpio5 for keys, gpio6
> for SD-Card CD & WP, gpio7 for keys and regulators).
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> [Niklas: s/gpio_to_priv(chip)/gpiochip_get_data(chip)/]

Just curious, what's the rationale for this ?

> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpio/gpio-rcar.c | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
> index 3b77c10..31ad288 100644
> --- a/drivers/gpio/gpio-rcar.c
> +++ b/drivers/gpio/gpio-rcar.c
> @@ -242,11 +242,24 @@ static void
> gpio_rcar_config_general_input_output_mode(struct gpio_chip *chip,
> 
>  static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset)
>  {
> -	return pinctrl_request_gpio(chip->base + offset);
> +	struct gpio_rcar_priv *p = gpiochip_get_data(chip);
> +	int error;
> +
> +	error = pm_runtime_get_sync(&p->pdev->dev);
> +	if (error < 0)
> +		return error;
> +
> +	error = pinctrl_request_gpio(chip->base + offset);
> +	if (error)
> +		pm_runtime_put(&p->pdev->dev);
> +
> +	return error;
>  }
> 
>  static void gpio_rcar_free(struct gpio_chip *chip, unsigned offset)
>  {
> +	struct gpio_rcar_priv *p = gpiochip_get_data(chip);
> +
>  	pinctrl_free_gpio(chip->base + offset);
> 
>  	/*
> @@ -254,6 +267,8 @@ static void gpio_rcar_free(struct gpio_chip *chip,
> unsigned offset) * drive the GPIO pin as an output.
>  	 */
>  	gpio_rcar_config_general_input_output_mode(chip, offset, false);
> +
> +	pm_runtime_put(&p->pdev->dev);
>  }
> 
>  static int gpio_rcar_direction_input(struct gpio_chip *chip, unsigned
> offset) @@ -426,7 +441,6 @@ static int gpio_rcar_probe(struct
> platform_device *pdev) }
> 
>  	pm_runtime_enable(dev);
> -	pm_runtime_get_sync(dev);
> 
>  	io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> @@ -495,7 +509,6 @@ static int gpio_rcar_probe(struct platform_device *pdev)
> err1:
>  	gpiochip_remove(gpio_chip);
>  err0:
> -	pm_runtime_put(dev);
>  	pm_runtime_disable(dev);
>  	return ret;
>  }
> @@ -506,7 +519,6 @@ static int gpio_rcar_remove(struct platform_device
> *pdev)
> 
>  	gpiochip_remove(&p->gpio_chip);
> 
> -	pm_runtime_put(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
>  	return 0;
>  }

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2016-12-08 21:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-08 17:32 [PATCH 0/2] gpio: rcar: (re)add Runtime PM support Niklas Söderlund
2016-12-08 17:32 ` [PATCH 1/2] gpio: rcar: set IRQ chip parent_device Niklas Söderlund
2016-12-08 21:36   ` Laurent Pinchart
2016-12-09 10:43   ` Geert Uytterhoeven
2016-12-28  0:31   ` Linus Walleij
2016-12-08 17:32 ` [PATCH 2/2] gpio: rcar: Fine-grained Runtime PM support Niklas Söderlund
2016-12-08 21:40   ` Laurent Pinchart [this message]
2016-12-08 23:15     ` Niklas Söderlund
2016-12-08 23:21       ` Laurent Pinchart
2016-12-15 23:12         ` Linus Walleij
2016-12-09 10:26   ` Geert Uytterhoeven
2016-12-28  0:33   ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1984659.qgJsdhyW2B@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=geert+renesas@glider.be \
    --cc=geert@linux-m68k.org \
    --cc=jonathanh@nvidia.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).