diff mbox series

[2/2] mmc: sdhci-esdhc-imx: use pm_runtime_force_suspend() to optimize remove callback

Message ID 20230518082035.335112-2-haibo.chen@nxp.com
State New
Headers show
Series [1/2] mmc: sdhci-esdhc-imx: enable IPG clock before register access during suspend/resume | expand

Commit Message

Bough Chen May 18, 2023, 8:20 a.m. UTC
From: Haibo Chen <haibo.chen@nxp.com>

Currently some code in sdhci_esdhc_imx_remove() duplicate with
sdhci_esdhc_runtime_suspend(), so use pm_runtime_force_suspend()
instead.

Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

Comments

Ulf Hansson June 8, 2023, 2:33 p.m. UTC | #1
On Thu, 18 May 2023 at 10:17, <haibo.chen@nxp.com> wrote:
>
> From: Haibo Chen <haibo.chen@nxp.com>
>
> Currently some code in sdhci_esdhc_imx_remove() duplicate with
> sdhci_esdhc_runtime_suspend(), so use pm_runtime_force_suspend()
> instead.

This is reasonable, but note that CONFIG_PM must always be set, as
that is needed to let pm_runtime_force_suspend() gate the clocks.

So, this boils down to whether there are cases when sdhci-esdhc-imx
can be built with CONFIG_PM unset?

Kind regards
Uffe

>
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> ---
>  drivers/mmc/host/sdhci-esdhc-imx.c | 17 +++++------------
>  1 file changed, 5 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 4cf42a028bb9..d7588faf52e0 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -1805,23 +1805,16 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
>  static int sdhci_esdhc_imx_remove(struct platform_device *pdev)
>  {
>         struct sdhci_host *host = platform_get_drvdata(pdev);
> -       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
> -       struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
>         int dead;
>
>         pm_runtime_get_sync(&pdev->dev);
>         dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff);
> -       pm_runtime_disable(&pdev->dev);
> -       pm_runtime_put_noidle(&pdev->dev);
> -
>         sdhci_remove_host(host, dead);
> -
> -       clk_disable_unprepare(imx_data->clk_per);
> -       clk_disable_unprepare(imx_data->clk_ipg);
> -       clk_disable_unprepare(imx_data->clk_ahb);
> -
> -       if (imx_data->socdata->flags & ESDHC_FLAG_PMQOS)
> -               cpu_latency_qos_remove_request(&imx_data->pm_qos_req);
> +       device_set_wakeup_capable(&pdev->dev, false);
> +       pm_runtime_dont_use_autosuspend(&pdev->dev);
> +       pm_runtime_put_sync(&pdev->dev);
> +       /* Ensure device disabled */
> +       pm_runtime_force_suspend(&pdev->dev);
>
>         sdhci_pltfm_free(pdev);
>
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 4cf42a028bb9..d7588faf52e0 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -1805,23 +1805,16 @@  static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 static int sdhci_esdhc_imx_remove(struct platform_device *pdev)
 {
 	struct sdhci_host *host = platform_get_drvdata(pdev);
-	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
-	struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
 	int dead;
 
 	pm_runtime_get_sync(&pdev->dev);
 	dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff);
-	pm_runtime_disable(&pdev->dev);
-	pm_runtime_put_noidle(&pdev->dev);
-
 	sdhci_remove_host(host, dead);
-
-	clk_disable_unprepare(imx_data->clk_per);
-	clk_disable_unprepare(imx_data->clk_ipg);
-	clk_disable_unprepare(imx_data->clk_ahb);
-
-	if (imx_data->socdata->flags & ESDHC_FLAG_PMQOS)
-		cpu_latency_qos_remove_request(&imx_data->pm_qos_req);
+	device_set_wakeup_capable(&pdev->dev, false);
+	pm_runtime_dont_use_autosuspend(&pdev->dev);
+	pm_runtime_put_sync(&pdev->dev);
+	/* Ensure device disabled */
+	pm_runtime_force_suspend(&pdev->dev);
 
 	sdhci_pltfm_free(pdev);