public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC/RFT 4/6] mmc: sdhci-msm: convert driver to use runtime PM apis
       [not found] <1429778744-13352-1-git-send-email-rnayak@codeaurora.org>
@ 2015-04-23  8:45 ` Rajendra Nayak
  2015-04-23 13:21   ` Ulf Hansson
  0 siblings, 1 reply; 6+ messages in thread
From: Rajendra Nayak @ 2015-04-23  8:45 UTC (permalink / raw)
  To: linux-arm-msm, linux-arm-kernel, linux-pm; +Cc: Rajendra Nayak, linux-mmc

With platform support now in place to manage clocks from within runtime PM
callbacks, get rid of all clock handling from the driver and convert the
driver to use runtime PM apis.

Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
Cc: <linux-mmc@vger.kernel.org>
---
 drivers/mmc/host/sdhci-msm.c | 46 +++++++++++---------------------------------
 1 file changed, 11 insertions(+), 35 deletions(-)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 4a09f76..3c62a77 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -19,6 +19,7 @@
 #include <linux/delay.h>
 #include <linux/mmc/mmc.h>
 #include <linux/slab.h>
+#include <linux/pm_runtime.h>
 
 #include "sdhci-pltfm.h"
 
@@ -56,8 +57,6 @@
 struct sdhci_msm_host {
 	struct platform_device *pdev;
 	void __iomem *core_mem;	/* MSM SDCC mapped address */
-	struct clk *clk;	/* main SD/MMC bus clock */
-	struct clk *pclk;	/* SDHC peripheral bus clock */
 	struct clk *bus_clk;	/* SDHC bus voter clock */
 	struct mmc_host *mmc;
 	struct sdhci_pltfm_data sdhci_msm_pdata;
@@ -469,29 +468,8 @@ static int sdhci_msm_probe(struct platform_device *pdev)
 			goto pltfm_free;
 	}
 
-	/* Setup main peripheral bus clock */
-	msm_host->pclk = devm_clk_get(&pdev->dev, "iface");
-	if (IS_ERR(msm_host->pclk)) {
-		ret = PTR_ERR(msm_host->pclk);
-		dev_err(&pdev->dev, "Perpheral clk setup failed (%d)\n", ret);
-		goto bus_clk_disable;
-	}
-
-	ret = clk_prepare_enable(msm_host->pclk);
-	if (ret)
-		goto bus_clk_disable;
-
-	/* Setup SDC MMC clock */
-	msm_host->clk = devm_clk_get(&pdev->dev, "core");
-	if (IS_ERR(msm_host->clk)) {
-		ret = PTR_ERR(msm_host->clk);
-		dev_err(&pdev->dev, "SDC MMC clk setup failed (%d)\n", ret);
-		goto pclk_disable;
-	}
-
-	ret = clk_prepare_enable(msm_host->clk);
-	if (ret)
-		goto pclk_disable;
+	pm_runtime_enable(&pdev->dev);
+	pm_runtime_get_sync(&pdev->dev);
 
 	core_memres = platform_get_resource(pdev, IORESOURCE_MEM, 1);
 	msm_host->core_mem = devm_ioremap_resource(&pdev->dev, core_memres);
@@ -499,7 +477,7 @@ static int sdhci_msm_probe(struct platform_device *pdev)
 	if (IS_ERR(msm_host->core_mem)) {
 		dev_err(&pdev->dev, "Failed to remap registers\n");
 		ret = PTR_ERR(msm_host->core_mem);
-		goto clk_disable;
+		goto err;
 	}
 
 	/* Reset the core and Enable SDHC mode */
@@ -511,7 +489,7 @@ static int sdhci_msm_probe(struct platform_device *pdev)
 	if (readl(msm_host->core_mem + CORE_POWER) & CORE_SW_RST) {
 		dev_err(&pdev->dev, "Stuck in reset\n");
 		ret = -ETIMEDOUT;
-		goto clk_disable;
+		goto err;
 	}
 
 	/* Set HC_MODE_EN bit in HC_MODE register */
@@ -545,15 +523,13 @@ static int sdhci_msm_probe(struct platform_device *pdev)
 
 	ret = sdhci_add_host(host);
 	if (ret)
-		goto clk_disable;
+		goto err;
 
 	return 0;
 
-clk_disable:
-	clk_disable_unprepare(msm_host->clk);
-pclk_disable:
-	clk_disable_unprepare(msm_host->pclk);
-bus_clk_disable:
+err:
+	pm_runtime_put_sync(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
 	if (!IS_ERR(msm_host->bus_clk))
 		clk_disable_unprepare(msm_host->bus_clk);
 pltfm_free:
@@ -571,8 +547,8 @@ static int sdhci_msm_remove(struct platform_device *pdev)
 
 	sdhci_remove_host(host, dead);
 	sdhci_pltfm_free(pdev);
-	clk_disable_unprepare(msm_host->clk);
-	clk_disable_unprepare(msm_host->pclk);
+	pm_runtime_put_sync(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
 	if (!IS_ERR(msm_host->bus_clk))
 		clk_disable_unprepare(msm_host->bus_clk);
 	return 0;
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation


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

* Re: [RFC/RFT 4/6] mmc: sdhci-msm: convert driver to use runtime PM apis
  2015-04-23  8:45 ` [RFC/RFT 4/6] mmc: sdhci-msm: convert driver to use runtime PM apis Rajendra Nayak
@ 2015-04-23 13:21   ` Ulf Hansson
  2015-04-23 13:42     ` Rajendra Nayak
  2015-04-23 13:43     ` Rajendra Nayak
  0 siblings, 2 replies; 6+ messages in thread
From: Ulf Hansson @ 2015-04-23 13:21 UTC (permalink / raw)
  To: Rajendra Nayak
  Cc: linux-arm-msm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org,
	linux-mmc

On 23 April 2015 at 10:45, Rajendra Nayak <rnayak@codeaurora.org> wrote:
> With platform support now in place to manage clocks from within runtime PM
> callbacks, get rid of all clock handling from the driver and convert the
> driver to use runtime PM apis.
>
> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
> Cc: <linux-mmc@vger.kernel.org>
> ---
>  drivers/mmc/host/sdhci-msm.c | 46 +++++++++++---------------------------------
>  1 file changed, 11 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
> index 4a09f76..3c62a77 100644
> --- a/drivers/mmc/host/sdhci-msm.c
> +++ b/drivers/mmc/host/sdhci-msm.c
> @@ -19,6 +19,7 @@
>  #include <linux/delay.h>
>  #include <linux/mmc/mmc.h>
>  #include <linux/slab.h>
> +#include <linux/pm_runtime.h>
>
>  #include "sdhci-pltfm.h"
>
> @@ -56,8 +57,6 @@
>  struct sdhci_msm_host {
>         struct platform_device *pdev;
>         void __iomem *core_mem; /* MSM SDCC mapped address */
> -       struct clk *clk;        /* main SD/MMC bus clock */
> -       struct clk *pclk;       /* SDHC peripheral bus clock */
>         struct clk *bus_clk;    /* SDHC bus voter clock */
>         struct mmc_host *mmc;
>         struct sdhci_pltfm_data sdhci_msm_pdata;
> @@ -469,29 +468,8 @@ static int sdhci_msm_probe(struct platform_device *pdev)
>                         goto pltfm_free;
>         }
>
> -       /* Setup main peripheral bus clock */
> -       msm_host->pclk = devm_clk_get(&pdev->dev, "iface");
> -       if (IS_ERR(msm_host->pclk)) {
> -               ret = PTR_ERR(msm_host->pclk);
> -               dev_err(&pdev->dev, "Perpheral clk setup failed (%d)\n", ret);
> -               goto bus_clk_disable;
> -       }
> -
> -       ret = clk_prepare_enable(msm_host->pclk);
> -       if (ret)
> -               goto bus_clk_disable;
> -
> -       /* Setup SDC MMC clock */
> -       msm_host->clk = devm_clk_get(&pdev->dev, "core");
> -       if (IS_ERR(msm_host->clk)) {
> -               ret = PTR_ERR(msm_host->clk);
> -               dev_err(&pdev->dev, "SDC MMC clk setup failed (%d)\n", ret);
> -               goto pclk_disable;
> -       }
> -
> -       ret = clk_prepare_enable(msm_host->clk);
> -       if (ret)
> -               goto pclk_disable;
> +       pm_runtime_enable(&pdev->dev);
> +       pm_runtime_get_sync(&pdev->dev);
>
>         core_memres = platform_get_resource(pdev, IORESOURCE_MEM, 1);
>         msm_host->core_mem = devm_ioremap_resource(&pdev->dev, core_memres);
> @@ -499,7 +477,7 @@ static int sdhci_msm_probe(struct platform_device *pdev)
>         if (IS_ERR(msm_host->core_mem)) {
>                 dev_err(&pdev->dev, "Failed to remap registers\n");
>                 ret = PTR_ERR(msm_host->core_mem);
> -               goto clk_disable;
> +               goto err;
>         }
>
>         /* Reset the core and Enable SDHC mode */
> @@ -511,7 +489,7 @@ static int sdhci_msm_probe(struct platform_device *pdev)
>         if (readl(msm_host->core_mem + CORE_POWER) & CORE_SW_RST) {
>                 dev_err(&pdev->dev, "Stuck in reset\n");
>                 ret = -ETIMEDOUT;
> -               goto clk_disable;
> +               goto err;
>         }
>
>         /* Set HC_MODE_EN bit in HC_MODE register */
> @@ -545,15 +523,13 @@ static int sdhci_msm_probe(struct platform_device *pdev)
>
>         ret = sdhci_add_host(host);
>         if (ret)
> -               goto clk_disable;
> +               goto err;
>
>         return 0;
>
> -clk_disable:
> -       clk_disable_unprepare(msm_host->clk);
> -pclk_disable:
> -       clk_disable_unprepare(msm_host->pclk);
> -bus_clk_disable:
> +err:
> +       pm_runtime_put_sync(&pdev->dev);
> +       pm_runtime_disable(&pdev->dev);
>         if (!IS_ERR(msm_host->bus_clk))
>                 clk_disable_unprepare(msm_host->bus_clk);
>  pltfm_free:
> @@ -571,8 +547,8 @@ static int sdhci_msm_remove(struct platform_device *pdev)
>
>         sdhci_remove_host(host, dead);
>         sdhci_pltfm_free(pdev);
> -       clk_disable_unprepare(msm_host->clk);
> -       clk_disable_unprepare(msm_host->pclk);
> +       pm_runtime_put_sync(&pdev->dev);
> +       pm_runtime_disable(&pdev->dev);
>         if (!IS_ERR(msm_host->bus_clk))
>                 clk_disable_unprepare(msm_host->bus_clk);
>         return 0;
> --
> QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
> of Code Aurora Forum, hosted by The Linux Foundation
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

This all looks wrong. The driver will no longer work unless CONFIG_PM is set.

Kind regards
Uffe

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

* Re: [RFC/RFT 4/6] mmc: sdhci-msm: convert driver to use runtime PM apis
  2015-04-23 13:21   ` Ulf Hansson
@ 2015-04-23 13:42     ` Rajendra Nayak
  2015-04-23 21:15       ` Kevin Hilman
  2015-04-23 13:43     ` Rajendra Nayak
  1 sibling, 1 reply; 6+ messages in thread
From: Rajendra Nayak @ 2015-04-23 13:42 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Rajendra Nayak, linux-arm-msm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org,
	linux-mmc


> On 23 April 2015 at 10:45, Rajendra Nayak <rnayak@codeaurora.org> wrote:
>> With platform support now in place to manage clocks from within runtime
>> PM
>> callbacks, get rid of all clock handling from the driver and convert the
>> driver to use runtime PM apis.
>>
>> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
>> Cc: <linux-mmc@vger.kernel.org>
>> ---
>>  drivers/mmc/host/sdhci-msm.c | 46
>> +++++++++++---------------------------------
>>  1 file changed, 11 insertions(+), 35 deletions(-)
>>
>> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
>> index 4a09f76..3c62a77 100644
>> --- a/drivers/mmc/host/sdhci-msm.c
>> +++ b/drivers/mmc/host/sdhci-msm.c
>> @@ -19,6 +19,7 @@
>>  #include <linux/delay.h>
>>  #include <linux/mmc/mmc.h>
>>  #include <linux/slab.h>
>> +#include <linux/pm_runtime.h>
>>
>>  #include "sdhci-pltfm.h"
>>
>> @@ -56,8 +57,6 @@
>>  struct sdhci_msm_host {
>>         struct platform_device *pdev;
>>         void __iomem *core_mem; /* MSM SDCC mapped address */
>> -       struct clk *clk;        /* main SD/MMC bus clock */
>> -       struct clk *pclk;       /* SDHC peripheral bus clock */
>>         struct clk *bus_clk;    /* SDHC bus voter clock */
>>         struct mmc_host *mmc;
>>         struct sdhci_pltfm_data sdhci_msm_pdata;
>> @@ -469,29 +468,8 @@ static int sdhci_msm_probe(struct platform_device
>> *pdev)
>>                         goto pltfm_free;
>>         }
>>
>> -       /* Setup main peripheral bus clock */
>> -       msm_host->pclk = devm_clk_get(&pdev->dev, "iface");
>> -       if (IS_ERR(msm_host->pclk)) {
>> -               ret = PTR_ERR(msm_host->pclk);
>> -               dev_err(&pdev->dev, "Perpheral clk setup failed (%d)\n",
>> ret);
>> -               goto bus_clk_disable;
>> -       }
>> -
>> -       ret = clk_prepare_enable(msm_host->pclk);
>> -       if (ret)
>> -               goto bus_clk_disable;
>> -
>> -       /* Setup SDC MMC clock */
>> -       msm_host->clk = devm_clk_get(&pdev->dev, "core");
>> -       if (IS_ERR(msm_host->clk)) {
>> -               ret = PTR_ERR(msm_host->clk);
>> -               dev_err(&pdev->dev, "SDC MMC clk setup failed (%d)\n",
>> ret);
>> -               goto pclk_disable;
>> -       }
>> -
>> -       ret = clk_prepare_enable(msm_host->clk);
>> -       if (ret)
>> -               goto pclk_disable;
>> +       pm_runtime_enable(&pdev->dev);
>> +       pm_runtime_get_sync(&pdev->dev);
>>
>>         core_memres = platform_get_resource(pdev, IORESOURCE_MEM, 1);
>>         msm_host->core_mem = devm_ioremap_resource(&pdev->dev,
>> core_memres);
>> @@ -499,7 +477,7 @@ static int sdhci_msm_probe(struct platform_device
>> *pdev)
>>         if (IS_ERR(msm_host->core_mem)) {
>>                 dev_err(&pdev->dev, "Failed to remap registers\n");
>>                 ret = PTR_ERR(msm_host->core_mem);
>> -               goto clk_disable;
>> +               goto err;
>>         }
>>
>>         /* Reset the core and Enable SDHC mode */
>> @@ -511,7 +489,7 @@ static int sdhci_msm_probe(struct platform_device
>> *pdev)
>>         if (readl(msm_host->core_mem + CORE_POWER) & CORE_SW_RST) {
>>                 dev_err(&pdev->dev, "Stuck in reset\n");
>>                 ret = -ETIMEDOUT;
>> -               goto clk_disable;
>> +               goto err;
>>         }
>>
>>         /* Set HC_MODE_EN bit in HC_MODE register */
>> @@ -545,15 +523,13 @@ static int sdhci_msm_probe(struct platform_device
>> *pdev)
>>
>>         ret = sdhci_add_host(host);
>>         if (ret)
>> -               goto clk_disable;
>> +               goto err;
>>
>>         return 0;
>>
>> -clk_disable:
>> -       clk_disable_unprepare(msm_host->clk);
>> -pclk_disable:
>> -       clk_disable_unprepare(msm_host->pclk);
>> -bus_clk_disable:
>> +err:
>> +       pm_runtime_put_sync(&pdev->dev);
>> +       pm_runtime_disable(&pdev->dev);
>>         if (!IS_ERR(msm_host->bus_clk))
>>                 clk_disable_unprepare(msm_host->bus_clk);
>>  pltfm_free:
>> @@ -571,8 +547,8 @@ static int sdhci_msm_remove(struct platform_device
>> *pdev)
>>
>>         sdhci_remove_host(host, dead);
>>         sdhci_pltfm_free(pdev);
>> -       clk_disable_unprepare(msm_host->clk);
>> -       clk_disable_unprepare(msm_host->pclk);
>> +       pm_runtime_put_sync(&pdev->dev);
>> +       pm_runtime_disable(&pdev->dev);
>>         if (!IS_ERR(msm_host->bus_clk))
>>                 clk_disable_unprepare(msm_host->bus_clk);
>>         return 0;
>> --
>> QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
>> member
>> of Code Aurora Forum, hosted by The Linux Foundation
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> This all looks wrong. The driver will no longer work unless CONFIG_PM is
> set.

Right, I seem to have completely ignored the !CONFIG_PM case.
Will look at how to handle that.

>
> Kind regards
> Uffe
>


-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation


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

* Re: [RFC/RFT 4/6] mmc: sdhci-msm: convert driver to use runtime PM apis
  2015-04-23 13:21   ` Ulf Hansson
  2015-04-23 13:42     ` Rajendra Nayak
@ 2015-04-23 13:43     ` Rajendra Nayak
  1 sibling, 0 replies; 6+ messages in thread
From: Rajendra Nayak @ 2015-04-23 13:43 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Rajendra Nayak, linux-arm-msm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org,
	linux-mmc


> On 23 April 2015 at 10:45, Rajendra Nayak <rnayak@codeaurora.org> wrote:
>> With platform support now in place to manage clocks from within runtime
>> PM
>> callbacks, get rid of all clock handling from the driver and convert the
>> driver to use runtime PM apis.
>>
>> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
>> Cc: <linux-mmc@vger.kernel.org>
>> ---
>>  drivers/mmc/host/sdhci-msm.c | 46
>> +++++++++++---------------------------------
>>  1 file changed, 11 insertions(+), 35 deletions(-)
>>
>> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
>> index 4a09f76..3c62a77 100644
>> --- a/drivers/mmc/host/sdhci-msm.c
>> +++ b/drivers/mmc/host/sdhci-msm.c
>> @@ -19,6 +19,7 @@
>>  #include <linux/delay.h>
>>  #include <linux/mmc/mmc.h>
>>  #include <linux/slab.h>
>> +#include <linux/pm_runtime.h>
>>
>>  #include "sdhci-pltfm.h"
>>
>> @@ -56,8 +57,6 @@
>>  struct sdhci_msm_host {
>>         struct platform_device *pdev;
>>         void __iomem *core_mem; /* MSM SDCC mapped address */
>> -       struct clk *clk;        /* main SD/MMC bus clock */
>> -       struct clk *pclk;       /* SDHC peripheral bus clock */
>>         struct clk *bus_clk;    /* SDHC bus voter clock */
>>         struct mmc_host *mmc;
>>         struct sdhci_pltfm_data sdhci_msm_pdata;
>> @@ -469,29 +468,8 @@ static int sdhci_msm_probe(struct platform_device
>> *pdev)
>>                         goto pltfm_free;
>>         }
>>
>> -       /* Setup main peripheral bus clock */
>> -       msm_host->pclk = devm_clk_get(&pdev->dev, "iface");
>> -       if (IS_ERR(msm_host->pclk)) {
>> -               ret = PTR_ERR(msm_host->pclk);
>> -               dev_err(&pdev->dev, "Perpheral clk setup failed (%d)\n",
>> ret);
>> -               goto bus_clk_disable;
>> -       }
>> -
>> -       ret = clk_prepare_enable(msm_host->pclk);
>> -       if (ret)
>> -               goto bus_clk_disable;
>> -
>> -       /* Setup SDC MMC clock */
>> -       msm_host->clk = devm_clk_get(&pdev->dev, "core");
>> -       if (IS_ERR(msm_host->clk)) {
>> -               ret = PTR_ERR(msm_host->clk);
>> -               dev_err(&pdev->dev, "SDC MMC clk setup failed (%d)\n",
>> ret);
>> -               goto pclk_disable;
>> -       }
>> -
>> -       ret = clk_prepare_enable(msm_host->clk);
>> -       if (ret)
>> -               goto pclk_disable;
>> +       pm_runtime_enable(&pdev->dev);
>> +       pm_runtime_get_sync(&pdev->dev);
>>
>>         core_memres = platform_get_resource(pdev, IORESOURCE_MEM, 1);
>>         msm_host->core_mem = devm_ioremap_resource(&pdev->dev,
>> core_memres);
>> @@ -499,7 +477,7 @@ static int sdhci_msm_probe(struct platform_device
>> *pdev)
>>         if (IS_ERR(msm_host->core_mem)) {
>>                 dev_err(&pdev->dev, "Failed to remap registers\n");
>>                 ret = PTR_ERR(msm_host->core_mem);
>> -               goto clk_disable;
>> +               goto err;
>>         }
>>
>>         /* Reset the core and Enable SDHC mode */
>> @@ -511,7 +489,7 @@ static int sdhci_msm_probe(struct platform_device
>> *pdev)
>>         if (readl(msm_host->core_mem + CORE_POWER) & CORE_SW_RST) {
>>                 dev_err(&pdev->dev, "Stuck in reset\n");
>>                 ret = -ETIMEDOUT;
>> -               goto clk_disable;
>> +               goto err;
>>         }
>>
>>         /* Set HC_MODE_EN bit in HC_MODE register */
>> @@ -545,15 +523,13 @@ static int sdhci_msm_probe(struct platform_device
>> *pdev)
>>
>>         ret = sdhci_add_host(host);
>>         if (ret)
>> -               goto clk_disable;
>> +               goto err;
>>
>>         return 0;
>>
>> -clk_disable:
>> -       clk_disable_unprepare(msm_host->clk);
>> -pclk_disable:
>> -       clk_disable_unprepare(msm_host->pclk);
>> -bus_clk_disable:
>> +err:
>> +       pm_runtime_put_sync(&pdev->dev);
>> +       pm_runtime_disable(&pdev->dev);
>>         if (!IS_ERR(msm_host->bus_clk))
>>                 clk_disable_unprepare(msm_host->bus_clk);
>>  pltfm_free:
>> @@ -571,8 +547,8 @@ static int sdhci_msm_remove(struct platform_device
>> *pdev)
>>
>>         sdhci_remove_host(host, dead);
>>         sdhci_pltfm_free(pdev);
>> -       clk_disable_unprepare(msm_host->clk);
>> -       clk_disable_unprepare(msm_host->pclk);
>> +       pm_runtime_put_sync(&pdev->dev);
>> +       pm_runtime_disable(&pdev->dev);
>>         if (!IS_ERR(msm_host->bus_clk))
>>                 clk_disable_unprepare(msm_host->bus_clk);
>>         return 0;
>> --
>> QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
>> member
>> of Code Aurora Forum, hosted by The Linux Foundation
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> This all looks wrong. The driver will no longer work unless CONFIG_PM is
> set.

Right, I seem to have completely ignored the !CONFIG_PM case.
Will look at how to handle that.

>
> Kind regards
> Uffe
>


-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation


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

* Re: [RFC/RFT 4/6] mmc: sdhci-msm: convert driver to use runtime PM apis
  2015-04-23 13:42     ` Rajendra Nayak
@ 2015-04-23 21:15       ` Kevin Hilman
  2015-04-24  0:45         ` Rajendra Nayak
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Hilman @ 2015-04-23 21:15 UTC (permalink / raw)
  To: Rajendra Nayak
  Cc: Ulf Hansson, linux-arm-msm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org,
	linux-mmc

"Rajendra Nayak" <rnayak@codeaurora.org> writes:

>> On 23 April 2015 at 10:45, Rajendra Nayak <rnayak@codeaurora.org> wrote:
>>> With platform support now in place to manage clocks from within runtime
>>> PM
>>> callbacks, get rid of all clock handling from the driver and convert the
>>> driver to use runtime PM apis.
>>>
>>> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
>>> Cc: <linux-mmc@vger.kernel.org>
>>> ---
>>>  drivers/mmc/host/sdhci-msm.c | 46
>>> +++++++++++---------------------------------
>>>  1 file changed, 11 insertions(+), 35 deletions(-)
>>>
>>> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
>>> index 4a09f76..3c62a77 100644
>>> --- a/drivers/mmc/host/sdhci-msm.c
>>> +++ b/drivers/mmc/host/sdhci-msm.c
>>> @@ -19,6 +19,7 @@
>>>  #include <linux/delay.h>
>>>  #include <linux/mmc/mmc.h>
>>>  #include <linux/slab.h>
>>> +#include <linux/pm_runtime.h>
>>>
>>>  #include "sdhci-pltfm.h"
>>>
>>> @@ -56,8 +57,6 @@
>>>  struct sdhci_msm_host {
>>>         struct platform_device *pdev;
>>>         void __iomem *core_mem; /* MSM SDCC mapped address */
>>> -       struct clk *clk;        /* main SD/MMC bus clock */
>>> -       struct clk *pclk;       /* SDHC peripheral bus clock */
>>>         struct clk *bus_clk;    /* SDHC bus voter clock */
>>>         struct mmc_host *mmc;
>>>         struct sdhci_pltfm_data sdhci_msm_pdata;
>>> @@ -469,29 +468,8 @@ static int sdhci_msm_probe(struct platform_device
>>> *pdev)
>>>                         goto pltfm_free;
>>>         }
>>>
>>> -       /* Setup main peripheral bus clock */
>>> -       msm_host->pclk = devm_clk_get(&pdev->dev, "iface");
>>> -       if (IS_ERR(msm_host->pclk)) {
>>> -               ret = PTR_ERR(msm_host->pclk);
>>> -               dev_err(&pdev->dev, "Perpheral clk setup failed (%d)\n",
>>> ret);
>>> -               goto bus_clk_disable;
>>> -       }
>>> -
>>> -       ret = clk_prepare_enable(msm_host->pclk);
>>> -       if (ret)
>>> -               goto bus_clk_disable;
>>> -
>>> -       /* Setup SDC MMC clock */
>>> -       msm_host->clk = devm_clk_get(&pdev->dev, "core");
>>> -       if (IS_ERR(msm_host->clk)) {
>>> -               ret = PTR_ERR(msm_host->clk);
>>> -               dev_err(&pdev->dev, "SDC MMC clk setup failed (%d)\n",
>>> ret);
>>> -               goto pclk_disable;
>>> -       }
>>> -
>>> -       ret = clk_prepare_enable(msm_host->clk);
>>> -       if (ret)
>>> -               goto pclk_disable;
>>> +       pm_runtime_enable(&pdev->dev);
>>> +       pm_runtime_get_sync(&pdev->dev);
>>>
>>>         core_memres = platform_get_resource(pdev, IORESOURCE_MEM, 1);
>>>         msm_host->core_mem = devm_ioremap_resource(&pdev->dev,
>>> core_memres);
>>> @@ -499,7 +477,7 @@ static int sdhci_msm_probe(struct platform_device
>>> *pdev)
>>>         if (IS_ERR(msm_host->core_mem)) {
>>>                 dev_err(&pdev->dev, "Failed to remap registers\n");
>>>                 ret = PTR_ERR(msm_host->core_mem);
>>> -               goto clk_disable;
>>> +               goto err;
>>>         }
>>>
>>>         /* Reset the core and Enable SDHC mode */
>>> @@ -511,7 +489,7 @@ static int sdhci_msm_probe(struct platform_device
>>> *pdev)
>>>         if (readl(msm_host->core_mem + CORE_POWER) & CORE_SW_RST) {
>>>                 dev_err(&pdev->dev, "Stuck in reset\n");
>>>                 ret = -ETIMEDOUT;
>>> -               goto clk_disable;
>>> +               goto err;
>>>         }
>>>
>>>         /* Set HC_MODE_EN bit in HC_MODE register */
>>> @@ -545,15 +523,13 @@ static int sdhci_msm_probe(struct platform_device
>>> *pdev)
>>>
>>>         ret = sdhci_add_host(host);
>>>         if (ret)
>>> -               goto clk_disable;
>>> +               goto err;
>>>
>>>         return 0;
>>>
>>> -clk_disable:
>>> -       clk_disable_unprepare(msm_host->clk);
>>> -pclk_disable:
>>> -       clk_disable_unprepare(msm_host->pclk);
>>> -bus_clk_disable:
>>> +err:
>>> +       pm_runtime_put_sync(&pdev->dev);
>>> +       pm_runtime_disable(&pdev->dev);
>>>         if (!IS_ERR(msm_host->bus_clk))
>>>                 clk_disable_unprepare(msm_host->bus_clk);
>>>  pltfm_free:
>>> @@ -571,8 +547,8 @@ static int sdhci_msm_remove(struct platform_device
>>> *pdev)
>>>
>>>         sdhci_remove_host(host, dead);
>>>         sdhci_pltfm_free(pdev);
>>> -       clk_disable_unprepare(msm_host->clk);
>>> -       clk_disable_unprepare(msm_host->pclk);
>>> +       pm_runtime_put_sync(&pdev->dev);
>>> +       pm_runtime_disable(&pdev->dev);
>>>         if (!IS_ERR(msm_host->bus_clk))
>>>                 clk_disable_unprepare(msm_host->bus_clk);
>>>         return 0;
>>> --
>>> QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
>>> member
>>> of Code Aurora Forum, hosted by The Linux Foundation
>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>> This all looks wrong. The driver will no longer work unless CONFIG_PM is
>> set.
>
> Right, I seem to have completely ignored the !CONFIG_PM case.
> Will look at how to handle that.

IMO, don't complicate the driver with that.  Just enable (or leave
enabled) all the clocks in the clock driver in the !CONFIG_PM case.

Kevin

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

* Re: [RFC/RFT 4/6] mmc: sdhci-msm: convert driver to use runtime PM apis
  2015-04-23 21:15       ` Kevin Hilman
@ 2015-04-24  0:45         ` Rajendra Nayak
  0 siblings, 0 replies; 6+ messages in thread
From: Rajendra Nayak @ 2015-04-24  0:45 UTC (permalink / raw)
  To: Kevin Hilman
  Cc: Rajendra Nayak, Ulf Hansson, linux-arm-msm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org,
	linux-mmc


> "Rajendra Nayak" <rnayak@codeaurora.org> writes:
>
>>> On 23 April 2015 at 10:45, Rajendra Nayak <rnayak@codeaurora.org>
>>> wrote:
>>>> With platform support now in place to manage clocks from within
>>>> runtime
>>>> PM
>>>> callbacks, get rid of all clock handling from the driver and convert
>>>> the
>>>> driver to use runtime PM apis.
>>>>
>>>> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
>>>> Cc: <linux-mmc@vger.kernel.org>
>>>> ---
>>>>  drivers/mmc/host/sdhci-msm.c | 46
>>>> +++++++++++---------------------------------
>>>>  1 file changed, 11 insertions(+), 35 deletions(-)
>>>>
>>>> diff --git a/drivers/mmc/host/sdhci-msm.c
>>>> b/drivers/mmc/host/sdhci-msm.c
>>>> index 4a09f76..3c62a77 100644
>>>> --- a/drivers/mmc/host/sdhci-msm.c
>>>> +++ b/drivers/mmc/host/sdhci-msm.c
>>>> @@ -19,6 +19,7 @@
>>>>  #include <linux/delay.h>
>>>>  #include <linux/mmc/mmc.h>
>>>>  #include <linux/slab.h>
>>>> +#include <linux/pm_runtime.h>
>>>>
>>>>  #include "sdhci-pltfm.h"
>>>>
>>>> @@ -56,8 +57,6 @@
>>>>  struct sdhci_msm_host {
>>>>         struct platform_device *pdev;
>>>>         void __iomem *core_mem; /* MSM SDCC mapped address */
>>>> -       struct clk *clk;        /* main SD/MMC bus clock */
>>>> -       struct clk *pclk;       /* SDHC peripheral bus clock */
>>>>         struct clk *bus_clk;    /* SDHC bus voter clock */
>>>>         struct mmc_host *mmc;
>>>>         struct sdhci_pltfm_data sdhci_msm_pdata;
>>>> @@ -469,29 +468,8 @@ static int sdhci_msm_probe(struct platform_device
>>>> *pdev)
>>>>                         goto pltfm_free;
>>>>         }
>>>>
>>>> -       /* Setup main peripheral bus clock */
>>>> -       msm_host->pclk = devm_clk_get(&pdev->dev, "iface");
>>>> -       if (IS_ERR(msm_host->pclk)) {
>>>> -               ret = PTR_ERR(msm_host->pclk);
>>>> -               dev_err(&pdev->dev, "Perpheral clk setup failed
>>>> (%d)\n",
>>>> ret);
>>>> -               goto bus_clk_disable;
>>>> -       }
>>>> -
>>>> -       ret = clk_prepare_enable(msm_host->pclk);
>>>> -       if (ret)
>>>> -               goto bus_clk_disable;
>>>> -
>>>> -       /* Setup SDC MMC clock */
>>>> -       msm_host->clk = devm_clk_get(&pdev->dev, "core");
>>>> -       if (IS_ERR(msm_host->clk)) {
>>>> -               ret = PTR_ERR(msm_host->clk);
>>>> -               dev_err(&pdev->dev, "SDC MMC clk setup failed (%d)\n",
>>>> ret);
>>>> -               goto pclk_disable;
>>>> -       }
>>>> -
>>>> -       ret = clk_prepare_enable(msm_host->clk);
>>>> -       if (ret)
>>>> -               goto pclk_disable;
>>>> +       pm_runtime_enable(&pdev->dev);
>>>> +       pm_runtime_get_sync(&pdev->dev);
>>>>
>>>>         core_memres = platform_get_resource(pdev, IORESOURCE_MEM, 1);
>>>>         msm_host->core_mem = devm_ioremap_resource(&pdev->dev,
>>>> core_memres);
>>>> @@ -499,7 +477,7 @@ static int sdhci_msm_probe(struct platform_device
>>>> *pdev)
>>>>         if (IS_ERR(msm_host->core_mem)) {
>>>>                 dev_err(&pdev->dev, "Failed to remap registers\n");
>>>>                 ret = PTR_ERR(msm_host->core_mem);
>>>> -               goto clk_disable;
>>>> +               goto err;
>>>>         }
>>>>
>>>>         /* Reset the core and Enable SDHC mode */
>>>> @@ -511,7 +489,7 @@ static int sdhci_msm_probe(struct platform_device
>>>> *pdev)
>>>>         if (readl(msm_host->core_mem + CORE_POWER) & CORE_SW_RST) {
>>>>                 dev_err(&pdev->dev, "Stuck in reset\n");
>>>>                 ret = -ETIMEDOUT;
>>>> -               goto clk_disable;
>>>> +               goto err;
>>>>         }
>>>>
>>>>         /* Set HC_MODE_EN bit in HC_MODE register */
>>>> @@ -545,15 +523,13 @@ static int sdhci_msm_probe(struct
>>>> platform_device
>>>> *pdev)
>>>>
>>>>         ret = sdhci_add_host(host);
>>>>         if (ret)
>>>> -               goto clk_disable;
>>>> +               goto err;
>>>>
>>>>         return 0;
>>>>
>>>> -clk_disable:
>>>> -       clk_disable_unprepare(msm_host->clk);
>>>> -pclk_disable:
>>>> -       clk_disable_unprepare(msm_host->pclk);
>>>> -bus_clk_disable:
>>>> +err:
>>>> +       pm_runtime_put_sync(&pdev->dev);
>>>> +       pm_runtime_disable(&pdev->dev);
>>>>         if (!IS_ERR(msm_host->bus_clk))
>>>>                 clk_disable_unprepare(msm_host->bus_clk);
>>>>  pltfm_free:
>>>> @@ -571,8 +547,8 @@ static int sdhci_msm_remove(struct platform_device
>>>> *pdev)
>>>>
>>>>         sdhci_remove_host(host, dead);
>>>>         sdhci_pltfm_free(pdev);
>>>> -       clk_disable_unprepare(msm_host->clk);
>>>> -       clk_disable_unprepare(msm_host->pclk);
>>>> +       pm_runtime_put_sync(&pdev->dev);
>>>> +       pm_runtime_disable(&pdev->dev);
>>>>         if (!IS_ERR(msm_host->bus_clk))
>>>>                 clk_disable_unprepare(msm_host->bus_clk);
>>>>         return 0;
[]..
>>>
>>> This all looks wrong. The driver will no longer work unless CONFIG_PM
>>> is
>>> set.
>>
>> Right, I seem to have completely ignored the !CONFIG_PM case.
>> Will look at how to handle that.
>
> IMO, don't complicate the driver with that.  Just enable (or leave
> enabled) all the clocks in the clock driver in the !CONFIG_PM case.

so I just looked at what pm_clk_notify() does in !CONFIG_PM case and it
seems to do just that, leaves all the clocks enabled on
BUS_NOTIFY_BIND_DRIVER case and disables them for BUS_NOTIFY_UNBOUND_DRIVER
case. So looks like things are already in place to handle this :)

Ulf, does that address your concern or did I miss anything?

-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation


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

end of thread, other threads:[~2015-04-24  0:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1429778744-13352-1-git-send-email-rnayak@codeaurora.org>
2015-04-23  8:45 ` [RFC/RFT 4/6] mmc: sdhci-msm: convert driver to use runtime PM apis Rajendra Nayak
2015-04-23 13:21   ` Ulf Hansson
2015-04-23 13:42     ` Rajendra Nayak
2015-04-23 21:15       ` Kevin Hilman
2015-04-24  0:45         ` Rajendra Nayak
2015-04-23 13:43     ` Rajendra Nayak

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