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


Groups > linux.kernel > #1685021

Re: [PATCH 2/2] mmc: sdhci-of-at91: set clocks and presets after resume from deepest PM

Path csiph.com!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod
From Ulf Hansson <ulf.hansson@linaro.org>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] mmc: sdhci-of-at91: set clocks and presets after resume from deepest PM
Date Tue, 11 Jul 2017 14:50:02 +0200
Message-ID <u22M2-2jf-19@gated-at.bofh.it> (permalink)
References <tSTRE-5pn-19@gated-at.bofh.it> <tSTRE-5pn-17@gated-at.bofh.it>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=EBa3SzQUVR8WWZSe0AZ9QGN9b2yQizDsGh30dvzUkVY=; b=LJZ372leWjsDpm96w+Msk+Tgd7WdmVJUX8ZnEX86gWZ2qtlf/PvgoFlSAUkstKnLfI 6tu8Nit2BtJCVxpkspD1ruG3aXt+jdHw2iEs6Gy0ab0H2Ut6HkMmJzRhnsJn1UbYeIWF c3+sAejXjxDxQXPLs/dJPsDXtdj/+kKWUM6Ag=
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=EBa3SzQUVR8WWZSe0AZ9QGN9b2yQizDsGh30dvzUkVY=; b=iKHim0IX/kDH9+juLbKQPVf7jYI290PpOtUNfAD6ONyTfLcaJhlxfwlmDqwtLT39XW sZ9M+hlEY4wUpH6lYF5rZdW2APu+nAt915Man85gYAizLi+hsKbqKqv7qimYivnZI8Ap BVE0aWsqzULNmdlVg7j4MSLpCxoVERNK37m0pIHVAX+pNYt9SPJuMQhbNLese2reOpdP wLmMjtR/tY/sPSB8qrrY8zE1XkjYpTwFzA25y+77Zt/MfQKFiSonvftyOgdXlTp6jv6i zzg/MuP9WL/+3JlW65UDhyFLb0Mv+Wb3rqzVyuMz8tiwurD6VTT1K/cW0SEYbaylNv7b iDEQ==
X-Gm-Message-State AIVw113Jo6295Y8dxKXCYSOMfyfSFxOKdxL4cjj1U0sLjMqBCMhb04Ai utK71t1nbtAiAyUscZ0G6nhUafaSsWAR
X-Received by 10.233.216.1 with SMTP id u1mr9832338qkf.10.1499776965394; Tue, 11 Jul 2017 05:42:45 -0700 (PDT)
MIME-Version 1.0
Content-Type text/plain; charset="UTF-8"
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 112
Organization linux.* mail to news gateway
X-Original-Cc Adrian Hunter <adrian.hunter@intel.com>, Ludovic Desroches <ludovic.desroches@microchip.com>, "linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Thomas Petazzoni <thomas.petazzoni@free-electrons.com>, Alexandre Belloni <alexandre.belloni@free-electrons.com>, nicolas.ferre@microchip.com
X-Original-Date Tue, 11 Jul 2017 14:42:44 +0200
X-Original-Message-ID <CAPDyKFp2M_t4nCRNyqTm3PEx7tq+hb3TjmGWmg2XkJwbDa4FuQ@mail.gmail.com>
X-Original-References <20170616072929.3266-1-quentin.schulz@free-electrons.com> <20170616072929.3266-2-quentin.schulz@free-electrons.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1685021

Show key headers only | View raw


On 16 June 2017 at 09:29, Quentin Schulz
<quentin.schulz@free-electrons.com> wrote:
> This adds deepest (Backup+Self-Refresh) PM support to the ATMEL SAMA5D2
> SoC's SDHCI controller.
>
> When resuming from deepest state, it is required to restore preset
> registers as the registers are lost since VDD core has been shut down
> when entering deepest state on the SAMA5D2. The clocks need to be
> reconfigured as well.

Right, so compared to runtime resume there is some additional
operations that is needed during system resume. Fair enough.

However by looking at the changes below, you also change the system
suspend operations, as it now calls sdhci_suspend_host(). Is that
change needed? Then why?

>
> The other registers and init process are taken care of by the SDHCI
> core.
>
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
>  drivers/mmc/host/sdhci-of-at91.c | 34 ++++++++++++++++++++++++++++++++--
>  1 file changed, 32 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
> index fb8c6011f13d..300513fc1068 100644
> --- a/drivers/mmc/host/sdhci-of-at91.c
> +++ b/drivers/mmc/host/sdhci-of-at91.c
> @@ -207,6 +207,37 @@ static int sdhci_at91_set_clks_presets(struct device *dev)
>  }
>
>  #ifdef CONFIG_PM
> +static int sdhci_at91_suspend(struct device *dev)
> +{
> +       struct sdhci_host *host = dev_get_drvdata(dev);
> +       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
> +       struct sdhci_at91_priv *priv = sdhci_pltfm_priv(pltfm_host);
> +       int ret;
> +
> +       ret = sdhci_suspend_host(host);
> +

This is wrong, you can't call sdhci_suspend_host() unless the device
is runtime resumed...

> +       if (host->runtime_suspended)
> +               return ret;

... and this is weird...

> +
> +       clk_disable_unprepare(priv->gck);
> +       clk_disable_unprepare(priv->hclock);
> +       clk_disable_unprepare(priv->mainck);
> +
> +       return ret;
> +}
> +
> +static int sdhci_at91_resume(struct device *dev)
> +{
> +       struct sdhci_host *host = dev_get_drvdata(dev);
> +       int ret;
> +
> +       ret = sdhci_at91_set_clks_presets(dev);
> +       if (ret)
> +               return ret;

Instead of doing it like this, I suggest you set a new flag to true
here, let's call it "restore_needed".

In the ->runtime_resume() callback, you check the restore_needed flag
and performs the extra operations in that case. When that's done, the
->runtime_resume() callback clears the flag, as to avoid the next
runtime resume from unnecessary doing the extra operations.

> +
> +       return sdhci_resume_host(host);

Remove this and call pm_runtime_force_resume().

> +}
> +
>  static int sdhci_at91_runtime_suspend(struct device *dev)
>  {
>         struct sdhci_host *host = dev_get_drvdata(dev);
> @@ -256,8 +287,7 @@ static int sdhci_at91_runtime_resume(struct device *dev)
>  #endif /* CONFIG_PM */
>
>  static const struct dev_pm_ops sdhci_at91_dev_pm_ops = {
> -       SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,

Leave the pm_runtime_force_suspend() here, unless you have other
reasons not being described in the change log, to change the system
suspend operations.

> -                               pm_runtime_force_resume)
> +       SET_SYSTEM_SLEEP_PM_OPS(sdhci_at91_suspend, sdhci_at91_resume)
>         SET_RUNTIME_PM_OPS(sdhci_at91_runtime_suspend,
>                            sdhci_at91_runtime_resume,
>                            NULL)
> --
> 2.11.0
>

Adopting my changes should simplify the code, avoid unnecessary
resuming the device but instead deferring that until really needed via
runtime PM.

Kind regards
Uffe

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH 2/2] mmc: sdhci-of-at91: set clocks and presets after  resume from deepest PM Ulf Hansson <ulf.hansson@linaro.org> - 2017-07-11 14:50 +0200
  Re: [PATCH 2/2] mmc: sdhci-of-at91: set clocks and presets after  resume from deepest PM Ludovic Desroches <ludovic.desroches@microchip.com> - 2017-07-11 15:40 +0200
    Re: [PATCH 2/2] mmc: sdhci-of-at91: set clocks and presets after  resume from deepest PM Ulf Hansson <ulf.hansson@linaro.org> - 2017-07-11 16:00 +0200
      Re: [PATCH 2/2] mmc: sdhci-of-at91: set clocks and presets after  resume from deepest PM Ludovic Desroches <ludovic.desroches@microchip.com> - 2017-07-11 16:40 +0200

csiph-web