Re: [PATCH 2/2] mmc: sdhci-s3c: Enable runtime power management

2012-03-09 Thread Mark Brown
On Fri, Mar 09, 2012 at 12:08:58AM -0500, Chris Ball wrote:

> The reworked patch is below, please let me know if it looks incorrect:

That looks about right, I'll find out soon enough if it doesn't work in
-next as my main development system has the rootfs on this device :)


signature.asc
Description: Digital signature


Re: [PATCH 2/2] mmc: sdhci-s3c: Enable runtime power management

2012-03-08 Thread Chris Ball
Hi,

On Fri, Mar 02 2012, Mark Brown wrote:
> Since most of the work is already done by the core we just need to add
> runtime suspend methods and tell the PM core that runtime PM is enabled
> for this device.
>
> Signed-off-by: Mark Brown 
> ---
>  drivers/mmc/host/sdhci-s3c.c |   28 
>  1 files changed, 28 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
> index 46152d6..6926ac9 100644
> --- a/drivers/mmc/host/sdhci-s3c.c
> +++ b/drivers/mmc/host/sdhci-s3c.c
> @@ -23,6 +23,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  
> @@ -721,6 +722,11 @@ static int __devinit sdhci_s3c_probe(struct 
> platform_device *pdev)
>   if (pdata->host_caps2)
>   host->mmc->caps2 |= pdata->host_caps2;
>  
> + pm_runtime_enable(&pdev->dev);
> + pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
> + pm_runtime_use_autosuspend(&pdev->dev);
> + pm_suspend_ignore_children(&pdev->dev, 1);
> +
>   ret = sdhci_add_host(host);
>   if (ret) {
>   dev_err(dev, "sdhci_add_host() failed\n");
> @@ -740,6 +746,8 @@ static int __devinit sdhci_s3c_probe(struct 
> platform_device *pdev)
>  
>   err_add_host:
>   release_resource(sc->ioarea);
> + pm_runtime_forbid(&pdev->dev);
> + pm_runtime_get_noresume(&pdev->dev);
>   kfree(sc->ioarea);
>  
>   err_req_regs:
> @@ -784,6 +792,8 @@ static int __devexit sdhci_s3c_remove(struct 
> platform_device *pdev)
>  
>   sdhci_remove_host(host, 1);
>  
> + pm_runtime_disable(&pdev->dev);
> +
>   for (ptr = 0; ptr < 3; ptr++) {
>   if (sc->clk_bus[ptr]) {
>   clk_disable(sc->clk_bus[ptr]);
> @@ -824,9 +834,27 @@ static int sdhci_s3c_resume(struct device *dev)
>  }
>  #endif
>  
> +#ifdef CONFIG_PM_RUNTIME
> +static int sdhci_s3c_runtime_suspend(struct device *dev)
> +{
> + struct sdhci_host *host = dev_get_drvdata(dev);
> +
> + return sdhci_runtime_suspend_host(host);
> +}
> +
> +static int sdhci_s3c_runtime_resume(struct device *dev)
> +{
> + struct sdhci_host *host = dev_get_drvdata(dev);
> +
> + return sdhci_runtime_resume_host(host);
> +}
> +#endif
> +
>  #ifdef CONFIG_PM
>  static const struct dev_pm_ops sdhci_s3c_pmops = {
>   SET_SYSTEM_SLEEP_PM_OPS(sdhci_s3c_suspend, sdhci_s3c_resume)
> + SET_RUNTIME_PM_OPS(sdhci_s3c_runtime_suspend, sdhci_s3c_runtime_resume,
> +NULL)
>  };
>  
>  #define SDHCI_S3C_PMOPS (&sdhci_s3c_pmops)

I had to rework this patch to avoid a conflict with Julia Lawall's patch
"mmc: sdhci-s3c: use devm_ functions": https://lkml.org/lkml/2012/2/18/76

The reworked patch is below, please let me know if it looks incorrect:

From: Mark Brown 
Subject: [PATCH] mmc: sdhci-s3c: Enable runtime power management

Since most of the work is already done by the core we just need to add
runtime suspend methods and tell the PM core that runtime PM is enabled
for this device.

Signed-off-by: Mark Brown 
Acked-by: Jaehoon Chung 
Signed-off-by: Chris Ball 
---
 drivers/mmc/host/sdhci-s3c.c |   28 
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index 9683322..312aaf4 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -705,9 +706,16 @@ static int __devinit sdhci_s3c_probe(struct 
platform_device *pdev)
if (pdata->host_caps)
host->mmc->caps |= pdata->host_caps;
 
+   pm_runtime_enable(&pdev->dev);
+   pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
+   pm_runtime_use_autosuspend(&pdev->dev);
+   pm_suspend_ignore_children(&pdev->dev, 1);
+
ret = sdhci_add_host(host);
if (ret) {
dev_err(dev, "sdhci_add_host() failed\n");
+   pm_runtime_forbid(&pdev->dev);
+   pm_runtime_get_noresume(&pdev->dev);
goto err_req_regs;
}
 
@@ -764,6 +772,8 @@ static int __devexit sdhci_s3c_remove(struct 
platform_device *pdev)
 
sdhci_remove_host(host, 1);
 
+   pm_runtime_disable(&pdev->dev);
+
for (ptr = 0; ptr < 3; ptr++) {
if (sc->clk_bus[ptr]) {
clk_disable(sc->clk_bus[ptr]);
@@ -800,9 +810,27 @@ static int sdhci_s3c_resume(struct device *dev)
 }
 #endif
 
+#ifdef CONFIG_PM_RUNTIME
+static int sdhci_s3c_runtime_suspend(struct device *dev)
+{
+   struct sdhci_host *host = dev_get_drvdata(dev);
+
+   return sdhci_runtime_suspend_host(host);
+}
+
+static int sdhci_s3c_runtime_resume(struct device *dev)
+{
+   struct sdhci_host *host = dev_get_drvdata(dev);
+
+   return sdhci_runtime_resume_host(host);
+}
+#endif
+
 #ifdef CONFIG_PM
 static const struct dev_pm_ops sdhci_s3c_pmops = {
SET_SYSTEM_SLEEP_PM_OPS(sdhci_s3c_suspend, sdhci_s3c_resume

Re: [PATCH 2/2] mmc: sdhci-s3c: Enable runtime power management

2012-03-08 Thread Chris Ball
Hi Mark,

On Fri, Mar 02 2012, Mark Brown wrote:
> Since most of the work is already done by the core we just need to add
> runtime suspend methods and tell the PM core that runtime PM is enabled
> for this device.
>
> Signed-off-by: Mark Brown 
> ---
>  drivers/mmc/host/sdhci-s3c.c |   28 
>  1 files changed, 28 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
> index 46152d6..6926ac9 100644
> --- a/drivers/mmc/host/sdhci-s3c.c
> +++ b/drivers/mmc/host/sdhci-s3c.c
> @@ -23,6 +23,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  
> @@ -721,6 +722,11 @@ static int __devinit sdhci_s3c_probe(struct 
> platform_device *pdev)
>   if (pdata->host_caps2)
>   host->mmc->caps2 |= pdata->host_caps2;
>  
> + pm_runtime_enable(&pdev->dev);
> + pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
> + pm_runtime_use_autosuspend(&pdev->dev);
> + pm_suspend_ignore_children(&pdev->dev, 1);
> +
>   ret = sdhci_add_host(host);
>   if (ret) {
>   dev_err(dev, "sdhci_add_host() failed\n");
> @@ -740,6 +746,8 @@ static int __devinit sdhci_s3c_probe(struct 
> platform_device *pdev)
>  
>   err_add_host:
>   release_resource(sc->ioarea);
> + pm_runtime_forbid(&pdev->dev);
> + pm_runtime_get_noresume(&pdev->dev);
>   kfree(sc->ioarea);
>  
>   err_req_regs:
> @@ -784,6 +792,8 @@ static int __devexit sdhci_s3c_remove(struct 
> platform_device *pdev)
>  
>   sdhci_remove_host(host, 1);
>  
> + pm_runtime_disable(&pdev->dev);
> +
>   for (ptr = 0; ptr < 3; ptr++) {
>   if (sc->clk_bus[ptr]) {
>   clk_disable(sc->clk_bus[ptr]);
> @@ -824,9 +834,27 @@ static int sdhci_s3c_resume(struct device *dev)
>  }
>  #endif
>  
> +#ifdef CONFIG_PM_RUNTIME
> +static int sdhci_s3c_runtime_suspend(struct device *dev)
> +{
> + struct sdhci_host *host = dev_get_drvdata(dev);
> +
> + return sdhci_runtime_suspend_host(host);
> +}
> +
> +static int sdhci_s3c_runtime_resume(struct device *dev)
> +{
> + struct sdhci_host *host = dev_get_drvdata(dev);
> +
> + return sdhci_runtime_resume_host(host);
> +}
> +#endif
> +
>  #ifdef CONFIG_PM
>  static const struct dev_pm_ops sdhci_s3c_pmops = {
>   SET_SYSTEM_SLEEP_PM_OPS(sdhci_s3c_suspend, sdhci_s3c_resume)
> + SET_RUNTIME_PM_OPS(sdhci_s3c_runtime_suspend, sdhci_s3c_runtime_resume,
> +NULL)
>  };
>  
>  #define SDHCI_S3C_PMOPS (&sdhci_s3c_pmops)

Thanks, pushed to mmc-next for 3.4 with Jaehoon's ACK.

- Chris.
-- 
Chris Ball  
One Laptop Per Child
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] mmc: sdhci-s3c: Enable runtime power management

2012-03-05 Thread Jaehoon Chung
Acked-by: Jaehoon Chung 
 
On 03/05/2012 08:52 PM, Mark Brown wrote:

> On Mon, Mar 05, 2012 at 07:48:42PM +0900, Jaehoon Chung wrote:
>> On 03/03/2012 09:46 AM, Mark Brown wrote:
> 
>>> +   pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
> 
>> Could you explain why use 50ms? 
> 
> It's essentially a random number, some other devices use the same one.
> We're just trying to avoid suspending between back to back requests.
> 
>>> +   pm_runtime_use_autosuspend(&pdev->dev);
>>> +   pm_suspend_ignore_children(&pdev->dev, 1);
> 
>> Is there reason that ignore_children use to set the true?
> 
> So that we can suspend the host without having to have the MMC card
> suspended (the host suspend is not visible to the card).
> 
> 
> 
> ___
> linux-arm-kernel mailing list
> linux-arm-ker...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel


--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] mmc: sdhci-s3c: Enable runtime power management

2012-03-05 Thread Mark Brown
On Mon, Mar 05, 2012 at 07:48:42PM +0900, Jaehoon Chung wrote:
> On 03/03/2012 09:46 AM, Mark Brown wrote:

> > +   pm_runtime_set_autosuspend_delay(&pdev->dev, 50);

> Could you explain why use 50ms? 

It's essentially a random number, some other devices use the same one.
We're just trying to avoid suspending between back to back requests.

> > +   pm_runtime_use_autosuspend(&pdev->dev);
> > +   pm_suspend_ignore_children(&pdev->dev, 1);

> Is there reason that ignore_children use to set the true?

So that we can suspend the host without having to have the MMC card
suspended (the host suspend is not visible to the card).


signature.asc
Description: Digital signature


Re: [PATCH 2/2] mmc: sdhci-s3c: Enable runtime power management

2012-03-05 Thread Jaehoon Chung
Hi Mark,

On 03/03/2012 09:46 AM, Mark Brown wrote:

> Since most of the work is already done by the core we just need to add
> runtime suspend methods and tell the PM core that runtime PM is enabled
> for this device.
> 
> Signed-off-by: Mark Brown 
> ---
>  drivers/mmc/host/sdhci-s3c.c |   28 
>  1 files changed, 28 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
> index 46152d6..6926ac9 100644
> --- a/drivers/mmc/host/sdhci-s3c.c
> +++ b/drivers/mmc/host/sdhci-s3c.c
> @@ -23,6 +23,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  
> @@ -721,6 +722,11 @@ static int __devinit sdhci_s3c_probe(struct 
> platform_device *pdev)
>   if (pdata->host_caps2)
>   host->mmc->caps2 |= pdata->host_caps2;
>  
> + pm_runtime_enable(&pdev->dev);
> + pm_runtime_set_autosuspend_delay(&pdev->dev, 50);

Could you explain why use 50ms? 

> + pm_runtime_use_autosuspend(&pdev->dev);
> + pm_suspend_ignore_children(&pdev->dev, 1);

Is there reason that ignore_children use to set the true?

> +
>   ret = sdhci_add_host(host);
>   if (ret) {
>   dev_err(dev, "sdhci_add_host() failed\n");
> @@ -740,6 +746,8 @@ static int __devinit sdhci_s3c_probe(struct 
> platform_device *pdev)
>  
>   err_add_host:
>   release_resource(sc->ioarea);
> + pm_runtime_forbid(&pdev->dev);
> + pm_runtime_get_noresume(&pdev->dev);
>   kfree(sc->ioarea);
>  
>   err_req_regs:
> @@ -784,6 +792,8 @@ static int __devexit sdhci_s3c_remove(struct 
> platform_device *pdev)
>  
>   sdhci_remove_host(host, 1);
>  
> + pm_runtime_disable(&pdev->dev);
> +
>   for (ptr = 0; ptr < 3; ptr++) {
>   if (sc->clk_bus[ptr]) {
>   clk_disable(sc->clk_bus[ptr]);
> @@ -824,9 +834,27 @@ static int sdhci_s3c_resume(struct device *dev)
>  }
>  #endif
>  
> +#ifdef CONFIG_PM_RUNTIME
> +static int sdhci_s3c_runtime_suspend(struct device *dev)
> +{
> + struct sdhci_host *host = dev_get_drvdata(dev);
> +
> + return sdhci_runtime_suspend_host(host);
> +}
> +
> +static int sdhci_s3c_runtime_resume(struct device *dev)
> +{
> + struct sdhci_host *host = dev_get_drvdata(dev);
> +
> + return sdhci_runtime_resume_host(host);
> +}
> +#endif
> +
>  #ifdef CONFIG_PM
>  static const struct dev_pm_ops sdhci_s3c_pmops = {
>   SET_SYSTEM_SLEEP_PM_OPS(sdhci_s3c_suspend, sdhci_s3c_resume)
> + SET_RUNTIME_PM_OPS(sdhci_s3c_runtime_suspend, sdhci_s3c_runtime_resume,
> +NULL)
>  };
>  
>  #define SDHCI_S3C_PMOPS (&sdhci_s3c_pmops)


--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] mmc: sdhci-s3c: Enable runtime power management

2012-03-02 Thread Mark Brown
Since most of the work is already done by the core we just need to add
runtime suspend methods and tell the PM core that runtime PM is enabled
for this device.

Signed-off-by: Mark Brown 
---
 drivers/mmc/host/sdhci-s3c.c |   28 
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index 46152d6..6926ac9 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -721,6 +722,11 @@ static int __devinit sdhci_s3c_probe(struct 
platform_device *pdev)
if (pdata->host_caps2)
host->mmc->caps2 |= pdata->host_caps2;
 
+   pm_runtime_enable(&pdev->dev);
+   pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
+   pm_runtime_use_autosuspend(&pdev->dev);
+   pm_suspend_ignore_children(&pdev->dev, 1);
+
ret = sdhci_add_host(host);
if (ret) {
dev_err(dev, "sdhci_add_host() failed\n");
@@ -740,6 +746,8 @@ static int __devinit sdhci_s3c_probe(struct platform_device 
*pdev)
 
  err_add_host:
release_resource(sc->ioarea);
+   pm_runtime_forbid(&pdev->dev);
+   pm_runtime_get_noresume(&pdev->dev);
kfree(sc->ioarea);
 
  err_req_regs:
@@ -784,6 +792,8 @@ static int __devexit sdhci_s3c_remove(struct 
platform_device *pdev)
 
sdhci_remove_host(host, 1);
 
+   pm_runtime_disable(&pdev->dev);
+
for (ptr = 0; ptr < 3; ptr++) {
if (sc->clk_bus[ptr]) {
clk_disable(sc->clk_bus[ptr]);
@@ -824,9 +834,27 @@ static int sdhci_s3c_resume(struct device *dev)
 }
 #endif
 
+#ifdef CONFIG_PM_RUNTIME
+static int sdhci_s3c_runtime_suspend(struct device *dev)
+{
+   struct sdhci_host *host = dev_get_drvdata(dev);
+
+   return sdhci_runtime_suspend_host(host);
+}
+
+static int sdhci_s3c_runtime_resume(struct device *dev)
+{
+   struct sdhci_host *host = dev_get_drvdata(dev);
+
+   return sdhci_runtime_resume_host(host);
+}
+#endif
+
 #ifdef CONFIG_PM
 static const struct dev_pm_ops sdhci_s3c_pmops = {
SET_SYSTEM_SLEEP_PM_OPS(sdhci_s3c_suspend, sdhci_s3c_resume)
+   SET_RUNTIME_PM_OPS(sdhci_s3c_runtime_suspend, sdhci_s3c_runtime_resume,
+  NULL)
 };
 
 #define SDHCI_S3C_PMOPS (&sdhci_s3c_pmops)
-- 
1.7.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html