All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH 0/9] Init runtime PM support for dw_mmc
@ 2016-10-09 13:58 ` Shawn Lin
  2016-10-09 13:58   ` [RESEND PATCH 1/9] mmc: dw_mmc: add runtime PM callback Shawn Lin
                     ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Shawn Lin @ 2016-10-09 13:58 UTC (permalink / raw)
  To: Jaehoon Chung, Ulf Hansson
  Cc: linux-mmc, Doug Anderson, linux-rockchip, Shawn Lin


Hi Jaehoon and Ulf,

   This patch is gonna support runtime PM for dw_mmc.
It could support to disable ciu_clk by default and disable
biu_clk if the devices are non-removeable, or removeable
with gpio-base card detect.

   Then I remove the system PM since the runtime PM actually
does the same thing as it. So I help migrate the dw_mmc variant
drivers to use runtime PM pairs and pm_runtime_force_*. Note
that I only enable runtime PM for dw_mmc-rockchip as I will
leave the decision to the owners of the corresponding drivers.
I just tested it on my RK3288 platform with linux-next to make
the runtime PM and system PM work fine for my emmc, sd card and
sdio. But I don't have hardware to help test other variant drivers.
But in theory it should work fine as I mentioned that the runtime
PM does the same thing as system PM except for disabling ciu_clk
aggressively which should not be related to the variant hosts.

   As you could see that I just extend the slot-gpio a bit, so the
ideal way is Ulf could pick them up with Jaehoon's ack. :)



Shawn Lin (9):
  mmc: dw_mmc: add runtime PM callback
  mmc: dw_mmc-rockchip: add runtime PM support
  mmc: core: expose the capability of gpio card detect
  mmc: dw_mmc-rockchip: disable biu clk if possible
  mmc: dw_mmc-k3: deploay runtime PM facilities
  mmc: dw_mmc-exynos: deploay runtime PM facilities
  mmc: dw_mmc-pci: deploay runtime PM facilities
  mmc: dw_mmc-pltfm: deploay runtime PM facilities
  mmc: dw_mmc: remove system PM callback

 drivers/mmc/core/slot-gpio.c       |  8 +++++
 drivers/mmc/host/dw_mmc-exynos.c   | 21 ++++++-----
 drivers/mmc/host/dw_mmc-k3.c       | 37 +++++++++----------
 drivers/mmc/host/dw_mmc-pci.c      | 25 ++++++++-----
 drivers/mmc/host/dw_mmc-pltfm.c    | 26 ++++++++------
 drivers/mmc/host/dw_mmc-rockchip.c | 73 ++++++++++++++++++++++++++++++++++++--
 drivers/mmc/host/dw_mmc.c          | 24 ++++++-------
 drivers/mmc/host/dw_mmc.h          |  6 ++--
 include/linux/mmc/slot-gpio.h      |  1 +
 9 files changed, 152 insertions(+), 69 deletions(-)

-- 
2.3.7



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

* [RESEND PATCH 1/9] mmc: dw_mmc: add runtime PM callback
  2016-10-09 13:58 ` [RESEND PATCH 0/9] Init runtime PM support for dw_mmc Shawn Lin
@ 2016-10-09 13:58   ` Shawn Lin
  2016-10-09 13:58   ` [RESEND PATCH 2/9] mmc: dw_mmc-rockchip: add runtime PM support Shawn Lin
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Shawn Lin @ 2016-10-09 13:58 UTC (permalink / raw)
  To: Jaehoon Chung, Ulf Hansson
  Cc: linux-mmc, Doug Anderson, linux-rockchip, Shawn Lin

This patch add dw_mci_runtime_suspend/resume interfaces
and expose it to dw_mci variant driver to support runtime
PM.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>

---

 drivers/mmc/host/dw_mmc.c | 30 ++++++++++++++++++++++++++++--
 drivers/mmc/host/dw_mmc.h |  4 +++-
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 4fcbc40..c5ef263 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -3266,7 +3266,7 @@ EXPORT_SYMBOL(dw_mci_remove);
 
 
 
-#ifdef CONFIG_PM_SLEEP
+#ifdef CONFIG_PM
 /*
  * TODO: we should probably disable the clock to the card in the suspend path.
  */
@@ -3324,7 +3324,33 @@ int dw_mci_resume(struct dw_mci *host)
 	return 0;
 }
 EXPORT_SYMBOL(dw_mci_resume);
-#endif /* CONFIG_PM_SLEEP */
+
+int dw_mci_runtime_suspend(struct dw_mci *host)
+{
+	int err = 0;
+
+	err = dw_mci_suspend(host);
+	if (err)
+		return err;
+
+	clk_disable_unprepare(host->ciu_clk);
+
+	return err;
+}
+EXPORT_SYMBOL(dw_mci_runtime_suspend);
+
+int dw_mci_runtime_resume(struct dw_mci *host)
+{
+	int ret = 0;
+
+	ret = clk_prepare_enable(host->ciu_clk);
+	if (ret)
+		return ret;
+
+	return dw_mci_resume(host);
+}
+EXPORT_SYMBOL(dw_mci_runtime_resume);
+#endif /* CONFIG_PM */
 
 static int __init dw_mci_init(void)
 {
diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
index e8cd2de..baa7261 100644
--- a/drivers/mmc/host/dw_mmc.h
+++ b/drivers/mmc/host/dw_mmc.h
@@ -234,9 +234,11 @@
 
 extern int dw_mci_probe(struct dw_mci *host);
 extern void dw_mci_remove(struct dw_mci *host);
-#ifdef CONFIG_PM_SLEEP
+#ifdef CONFIG_PM
 extern int dw_mci_suspend(struct dw_mci *host);
 extern int dw_mci_resume(struct dw_mci *host);
+extern int dw_mci_runtime_suspend(struct dw_mci *host);
+extern int dw_mci_runtime_resume(struct dw_mci *host);
 #endif
 
 /**
-- 
2.3.7



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

* [RESEND PATCH 2/9] mmc: dw_mmc-rockchip: add runtime PM support
  2016-10-09 13:58 ` [RESEND PATCH 0/9] Init runtime PM support for dw_mmc Shawn Lin
  2016-10-09 13:58   ` [RESEND PATCH 1/9] mmc: dw_mmc: add runtime PM callback Shawn Lin
@ 2016-10-09 13:58   ` Shawn Lin
  2016-10-09 13:58   ` [RESEND PATCH 3/9] mmc: core: expose the capability of gpio card detect Shawn Lin
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Shawn Lin @ 2016-10-09 13:58 UTC (permalink / raw)
  To: Jaehoon Chung, Ulf Hansson
  Cc: linux-mmc, Doug Anderson, linux-rockchip, Shawn Lin

This patch adds runtime PM support for dw_mmc-rockchip.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/mmc/host/dw_mmc-rockchip.c | 57 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 54 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/dw_mmc-rockchip.c b/drivers/mmc/host/dw_mmc-rockchip.c
index 25eae35..28e0220 100644
--- a/drivers/mmc/host/dw_mmc-rockchip.c
+++ b/drivers/mmc/host/dw_mmc-rockchip.c
@@ -13,6 +13,7 @@
 #include <linux/mmc/host.h>
 #include <linux/mmc/dw_mmc.h>
 #include <linux/of_address.h>
+#include <linux/pm_runtime.h>
 #include <linux/slab.h>
 
 #include "dw_mmc.h"
@@ -325,6 +326,7 @@ static int dw_mci_rockchip_probe(struct platform_device *pdev)
 {
 	const struct dw_mci_drv_data *drv_data;
 	const struct of_device_id *match;
+	int ret;
 
 	if (!pdev->dev.of_node)
 		return -ENODEV;
@@ -332,16 +334,65 @@ static int dw_mci_rockchip_probe(struct platform_device *pdev)
 	match = of_match_node(dw_mci_rockchip_match, pdev->dev.of_node);
 	drv_data = match->data;
 
-	return dw_mci_pltfm_register(pdev, drv_data);
+	pm_runtime_get_noresume(&pdev->dev);
+	pm_runtime_set_active(&pdev->dev);
+	pm_runtime_enable(&pdev->dev);
+	pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
+	pm_runtime_use_autosuspend(&pdev->dev);
+
+	ret = dw_mci_pltfm_register(pdev, drv_data);
+	if (ret) {
+		pm_runtime_disable(&pdev->dev);
+		pm_runtime_set_suspended(&pdev->dev);
+		pm_runtime_put_noidle(&pdev->dev);
+		return ret;
+	}
+
+	pm_runtime_put_autosuspend(&pdev->dev);
+
+	return 0;
+}
+
+static int dw_mci_rockchip_remove(struct platform_device *pdev)
+{
+	pm_runtime_get_sync(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
+	pm_runtime_put_noidle(&pdev->dev);
+
+	return dw_mci_pltfm_remove(pdev);
 }
 
+#ifdef CONFIG_PM
+static int dw_mci_rockchip_runtime_suspend(struct device *dev)
+{
+	struct dw_mci *host = dev_get_drvdata(dev);
+
+	return dw_mci_runtime_suspend(host);
+}
+
+static int dw_mci_rockchip_runtime_resume(struct device *dev)
+{
+	struct dw_mci *host = dev_get_drvdata(dev);
+
+	return dw_mci_runtime_resume(host);
+}
+#endif /* CONFIG_PM */
+
+static const struct dev_pm_ops dw_mci_rockchip_dev_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
+				pm_runtime_force_resume)
+	SET_RUNTIME_PM_OPS(dw_mci_rockchip_runtime_suspend,
+			   dw_mci_rockchip_runtime_resume,
+			   NULL)
+};
+
 static struct platform_driver dw_mci_rockchip_pltfm_driver = {
 	.probe		= dw_mci_rockchip_probe,
-	.remove		= dw_mci_pltfm_remove,
+	.remove		= dw_mci_rockchip_remove,
 	.driver		= {
 		.name		= "dwmmc_rockchip",
 		.of_match_table	= dw_mci_rockchip_match,
-		.pm		= &dw_mci_pltfm_pmops,
+		.pm		= &dw_mci_rockchip_dev_pm_ops,
 	},
 };
 
-- 
2.3.7



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

* [RESEND PATCH 3/9] mmc: core: expose the capability of gpio card detect
  2016-10-09 13:58 ` [RESEND PATCH 0/9] Init runtime PM support for dw_mmc Shawn Lin
  2016-10-09 13:58   ` [RESEND PATCH 1/9] mmc: dw_mmc: add runtime PM callback Shawn Lin
  2016-10-09 13:58   ` [RESEND PATCH 2/9] mmc: dw_mmc-rockchip: add runtime PM support Shawn Lin
@ 2016-10-09 13:58   ` Shawn Lin
  2016-10-09 13:58   ` [RESEND PATCH 4/9] mmc: dw_mmc-rockchip: disable biu clk if possible Shawn Lin
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Shawn Lin @ 2016-10-09 13:58 UTC (permalink / raw)
  To: Jaehoon Chung, Ulf Hansson
  Cc: linux-mmc, Doug Anderson, linux-rockchip, Shawn Lin

Add new helper API mmc_can_gpio_cd for slot-gpio to make
host drivers know whether it supports gpio card detect.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/mmc/core/slot-gpio.c  | 8 ++++++++
 include/linux/mmc/slot-gpio.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
index 27117ba..babe591 100644
--- a/drivers/mmc/core/slot-gpio.c
+++ b/drivers/mmc/core/slot-gpio.c
@@ -258,6 +258,14 @@ int mmc_gpiod_request_cd(struct mmc_host *host, const char *con_id,
 }
 EXPORT_SYMBOL(mmc_gpiod_request_cd);
 
+bool mmc_can_gpio_cd(struct mmc_host *host)
+{
+	struct mmc_gpio *ctx = host->slot.handler_priv;
+
+	return ctx->cd_gpio ? true : false;
+}
+EXPORT_SYMBOL(mmc_can_gpio_cd);
+
 /**
  * mmc_gpiod_request_ro - request a gpio descriptor for write protection
  * @host: mmc host
diff --git a/include/linux/mmc/slot-gpio.h b/include/linux/mmc/slot-gpio.h
index 3945a8c..a7972cd 100644
--- a/include/linux/mmc/slot-gpio.h
+++ b/include/linux/mmc/slot-gpio.h
@@ -29,5 +29,6 @@ int mmc_gpiod_request_ro(struct mmc_host *host, const char *con_id,
 void mmc_gpio_set_cd_isr(struct mmc_host *host,
 			 irqreturn_t (*isr)(int irq, void *dev_id));
 void mmc_gpiod_request_cd_irq(struct mmc_host *host);
+bool mmc_can_gpio_cd(struct mmc_host *host);
 
 #endif
-- 
2.3.7



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

* [RESEND PATCH 4/9] mmc: dw_mmc-rockchip: disable biu clk if possible
  2016-10-09 13:58 ` [RESEND PATCH 0/9] Init runtime PM support for dw_mmc Shawn Lin
                     ` (2 preceding siblings ...)
  2016-10-09 13:58   ` [RESEND PATCH 3/9] mmc: core: expose the capability of gpio card detect Shawn Lin
@ 2016-10-09 13:58   ` Shawn Lin
  2016-10-09 14:01   ` [RESEND PATCH 5/9] mmc: dw_mmc-k3: deploay runtime PM facilities Shawn Lin
  2016-10-10  2:10   ` [RESEND PATCH 0/9] Init runtime PM support for dw_mmc Jaehoon Chung
  5 siblings, 0 replies; 12+ messages in thread
From: Shawn Lin @ 2016-10-09 13:58 UTC (permalink / raw)
  To: Jaehoon Chung, Ulf Hansson
  Cc: linux-mmc, Doug Anderson, linux-rockchip, Shawn Lin

We could disable biu clk and power-off genpd if gpio
card detect available.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/mmc/host/dw_mmc-rockchip.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/dw_mmc-rockchip.c b/drivers/mmc/host/dw_mmc-rockchip.c
index 28e0220..7528720 100644
--- a/drivers/mmc/host/dw_mmc-rockchip.c
+++ b/drivers/mmc/host/dw_mmc-rockchip.c
@@ -13,6 +13,7 @@
 #include <linux/mmc/host.h>
 #include <linux/mmc/dw_mmc.h>
 #include <linux/of_address.h>
+#include <linux/mmc/slot-gpio.h>
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
 
@@ -366,14 +367,29 @@ static int dw_mci_rockchip_remove(struct platform_device *pdev)
 static int dw_mci_rockchip_runtime_suspend(struct device *dev)
 {
 	struct dw_mci *host = dev_get_drvdata(dev);
+	int ret;
+
+	ret = dw_mci_runtime_suspend(host);
+	if (ret)
+		return ret;
 
-	return dw_mci_runtime_suspend(host);
+	if (host->cur_slot &&
+	    (mmc_can_gpio_cd(host->cur_slot->mmc) ||
+	     !mmc_card_is_removable(host->cur_slot->mmc)))
+		clk_disable_unprepare(host->biu_clk);
+
+	return 0;
 }
 
 static int dw_mci_rockchip_runtime_resume(struct device *dev)
 {
 	struct dw_mci *host = dev_get_drvdata(dev);
 
+	if (host->cur_slot &&
+	    (mmc_can_gpio_cd(host->cur_slot->mmc) ||
+	     !mmc_card_is_removable(host->cur_slot->mmc)))
+		clk_prepare_enable(host->biu_clk);
+
 	return dw_mci_runtime_resume(host);
 }
 #endif /* CONFIG_PM */
-- 
2.3.7



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

* [RESEND PATCH 5/9] mmc: dw_mmc-k3: deploay runtime PM facilities
  2016-10-09 13:58 ` [RESEND PATCH 0/9] Init runtime PM support for dw_mmc Shawn Lin
                     ` (3 preceding siblings ...)
  2016-10-09 13:58   ` [RESEND PATCH 4/9] mmc: dw_mmc-rockchip: disable biu clk if possible Shawn Lin
@ 2016-10-09 14:01   ` Shawn Lin
  2016-10-09 14:01     ` [RESEND PATCH 6/9] mmc: dw_mmc-exynos: " Shawn Lin
                       ` (3 more replies)
  2016-10-10  2:10   ` [RESEND PATCH 0/9] Init runtime PM support for dw_mmc Jaehoon Chung
  5 siblings, 4 replies; 12+ messages in thread
From: Shawn Lin @ 2016-10-09 14:01 UTC (permalink / raw)
  To: Jaehoon Chung, Ulf Hansson
  Cc: linux-mmc, Doug Anderson, linux-rockchip, Shawn Lin

Let's migrate it to use runtime PM and remove the system
PM callback from this driver. With this patch, it could
handle system PM properly and could also use runtime PM
if we enable it.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/mmc/host/dw_mmc-k3.c | 37 ++++++++++++++++---------------------
 1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/drivers/mmc/host/dw_mmc-k3.c b/drivers/mmc/host/dw_mmc-k3.c
index 6247894..99b859d 100644
--- a/drivers/mmc/host/dw_mmc-k3.c
+++ b/drivers/mmc/host/dw_mmc-k3.c
@@ -15,6 +15,7 @@
 #include <linux/module.h>
 #include <linux/of_address.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
 
@@ -162,35 +163,29 @@ static int dw_mci_k3_probe(struct platform_device *pdev)
 	return dw_mci_pltfm_register(pdev, drv_data);
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int dw_mci_k3_suspend(struct device *dev)
+#ifdef CONFIG_PM
+static int dw_mci_k3_runtime_suspend(struct device *dev)
 {
 	struct dw_mci *host = dev_get_drvdata(dev);
-	int ret;
-
-	ret = dw_mci_suspend(host);
-	if (!ret)
-		clk_disable_unprepare(host->ciu_clk);
 
-	return ret;
+	return dw_mci_runtime_suspend(host);
 }
 
-static int dw_mci_k3_resume(struct device *dev)
+static int dw_mci_k3_runtime_resume(struct device *dev)
 {
 	struct dw_mci *host = dev_get_drvdata(dev);
-	int ret;
 
-	ret = clk_prepare_enable(host->ciu_clk);
-	if (ret) {
-		dev_err(host->dev, "failed to enable ciu clock\n");
-		return ret;
-	}
-
-	return dw_mci_resume(host);
+	return dw_mci_runtime_resume(host);
 }
-#endif /* CONFIG_PM_SLEEP */
-
-static SIMPLE_DEV_PM_OPS(dw_mci_k3_pmops, dw_mci_k3_suspend, dw_mci_k3_resume);
+#endif /* CONFIG_PM */
+
+static const struct dev_pm_ops dw_mci_k3_dev_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
+				pm_runtime_force_resume)
+	SET_RUNTIME_PM_OPS(dw_mci_k3_runtime_suspend,
+			   dw_mci_k3_runtime_resume,
+			   NULL)
+};
 
 static struct platform_driver dw_mci_k3_pltfm_driver = {
 	.probe		= dw_mci_k3_probe,
@@ -198,7 +193,7 @@ static struct platform_driver dw_mci_k3_pltfm_driver = {
 	.driver		= {
 		.name		= "dwmmc_k3",
 		.of_match_table	= dw_mci_k3_match,
-		.pm		= &dw_mci_k3_pmops,
+		.pm		= &dw_mci_k3_dev_pm_ops,
 	},
 };
 
-- 
2.3.7



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

* [RESEND PATCH 6/9] mmc: dw_mmc-exynos: deploay runtime PM facilities
  2016-10-09 14:01   ` [RESEND PATCH 5/9] mmc: dw_mmc-k3: deploay runtime PM facilities Shawn Lin
@ 2016-10-09 14:01     ` Shawn Lin
  2016-10-09 14:01     ` [RESEND PATCH 7/9] mmc: dw_mmc-pci: " Shawn Lin
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 12+ messages in thread
From: Shawn Lin @ 2016-10-09 14:01 UTC (permalink / raw)
  To: Jaehoon Chung, Ulf Hansson
  Cc: linux-mmc, Doug Anderson, linux-rockchip, Shawn Lin

Let's migrate it to use runtime PM and remove the system
PM callback from this driver. With this patch, it could
handle system PM properly and could also use runtime PM
if we enable it.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/mmc/host/dw_mmc-exynos.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/mmc/host/dw_mmc-exynos.c b/drivers/mmc/host/dw_mmc-exynos.c
index 7ab3d74..189fd38 100644
--- a/drivers/mmc/host/dw_mmc-exynos.c
+++ b/drivers/mmc/host/dw_mmc-exynos.c
@@ -17,6 +17,7 @@
 #include <linux/mmc/mmc.h>
 #include <linux/of.h>
 #include <linux/of_gpio.h>
+#include <linux/pm_runtime.h>
 #include <linux/slab.h>
 
 #include "dw_mmc.h"
@@ -161,20 +162,20 @@ static void dw_mci_exynos_set_clksel_timing(struct dw_mci *host, u32 timing)
 		set_bit(DW_MMC_CARD_NO_USE_HOLD, &host->cur_slot->flags);
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int dw_mci_exynos_suspend(struct device *dev)
+#ifdef CONFIG_PM
+static int dw_mci_exynos_runtime_suspend(struct device *dev)
 {
 	struct dw_mci *host = dev_get_drvdata(dev);
 
-	return dw_mci_suspend(host);
+	return dw_mci_runtime_suspend(host);
 }
 
-static int dw_mci_exynos_resume(struct device *dev)
+static int dw_mci_exynos_runtime_resume(struct device *dev)
 {
 	struct dw_mci *host = dev_get_drvdata(dev);
 
 	dw_mci_exynos_config_smu(host);
-	return dw_mci_resume(host);
+	return dw_mci_runtime_resume(host);
 }
 
 /**
@@ -211,10 +212,8 @@ static int dw_mci_exynos_resume_noirq(struct device *dev)
 	return 0;
 }
 #else
-#define dw_mci_exynos_suspend		NULL
-#define dw_mci_exynos_resume		NULL
 #define dw_mci_exynos_resume_noirq	NULL
-#endif /* CONFIG_PM_SLEEP */
+#endif /* CONFIG_PM */
 
 static void dw_mci_exynos_config_hs400(struct dw_mci *host, u32 timing)
 {
@@ -531,7 +530,11 @@ static int dw_mci_exynos_probe(struct platform_device *pdev)
 }
 
 static const struct dev_pm_ops dw_mci_exynos_pmops = {
-	SET_SYSTEM_SLEEP_PM_OPS(dw_mci_exynos_suspend, dw_mci_exynos_resume)
+	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
+				pm_runtime_force_resume)
+	SET_RUNTIME_PM_OPS(dw_mci_exynos_runtime_suspend,
+			   dw_mci_exynos_runtime_resume,
+			   NULL)
 	.resume_noirq = dw_mci_exynos_resume_noirq,
 	.thaw_noirq = dw_mci_exynos_resume_noirq,
 	.restore_noirq = dw_mci_exynos_resume_noirq,
-- 
2.3.7



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

* [RESEND PATCH 7/9] mmc: dw_mmc-pci: deploay runtime PM facilities
  2016-10-09 14:01   ` [RESEND PATCH 5/9] mmc: dw_mmc-k3: deploay runtime PM facilities Shawn Lin
  2016-10-09 14:01     ` [RESEND PATCH 6/9] mmc: dw_mmc-exynos: " Shawn Lin
@ 2016-10-09 14:01     ` Shawn Lin
       [not found]     ` <1476021721-923-1-git-send-email-shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
  2016-10-09 14:02     ` [RESEND PATCH 9/9] mmc: dw_mmc: remove system PM callback Shawn Lin
  3 siblings, 0 replies; 12+ messages in thread
From: Shawn Lin @ 2016-10-09 14:01 UTC (permalink / raw)
  To: Jaehoon Chung, Ulf Hansson
  Cc: linux-mmc, Doug Anderson, linux-rockchip, Shawn Lin

Let's migrate it to use runtime PM and remove the system
PM callback from this driver. With this patch, it could
handle system PM properly and could also use runtime PM
if we enable it.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/mmc/host/dw_mmc-pci.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/mmc/host/dw_mmc-pci.c b/drivers/mmc/host/dw_mmc-pci.c
index 4c69fbd..61789b1 100644
--- a/drivers/mmc/host/dw_mmc-pci.c
+++ b/drivers/mmc/host/dw_mmc-pci.c
@@ -14,6 +14,7 @@
 #include <linux/io.h>
 #include <linux/irq.h>
 #include <linux/pci.h>
+#include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/mmc.h>
@@ -79,25 +80,31 @@ static void dw_mci_pci_remove(struct pci_dev *pdev)
 	dw_mci_remove(host);
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int dw_mci_pci_suspend(struct device *dev)
+#ifdef CONFIG_PM
+static int dw_mci_pci_runtime_suspend(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct dw_mci *host = pci_get_drvdata(pdev);
 
-	return dw_mci_suspend(host);
+	return dw_mci_runtime_suspend(host);
 }
 
-static int dw_mci_pci_resume(struct device *dev)
+static int dw_mci_pci_runtime_resume(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct dw_mci *host = pci_get_drvdata(pdev);
 
-	return dw_mci_resume(host);
+	return dw_mci_runtime_resume(host);
 }
-#endif /* CONFIG_PM_SLEEP */
-
-static SIMPLE_DEV_PM_OPS(dw_mci_pci_pmops, dw_mci_pci_suspend, dw_mci_pci_resume);
+#endif /* CONFIG_PM */
+
+static const struct dev_pm_ops dw_mci_pci_dev_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
+				pm_runtime_force_resume)
+	SET_RUNTIME_PM_OPS(dw_mci_pci_runtime_suspend,
+			   dw_mci_pci_runtime_resume,
+			   NULL)
+};
 
 static const struct pci_device_id dw_mci_pci_id[] = {
 	{ PCI_DEVICE(SYNOPSYS_DW_MCI_VENDOR_ID, SYNOPSYS_DW_MCI_DEVICE_ID) },
@@ -111,7 +118,7 @@ static struct pci_driver dw_mci_pci_driver = {
 	.probe		= dw_mci_pci_probe,
 	.remove		= dw_mci_pci_remove,
 	.driver		=	{
-		.pm =   &dw_mci_pci_pmops
+		.pm =   &dw_mci_pci_dev_pm_ops,
 	},
 };
 
-- 
2.3.7



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

* [RESEND PATCH 8/9] mmc: dw_mmc-pltfm: deploay runtime PM facilities
       [not found]     ` <1476021721-923-1-git-send-email-shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
@ 2016-10-09 14:02       ` Shawn Lin
  0 siblings, 0 replies; 12+ messages in thread
From: Shawn Lin @ 2016-10-09 14:02 UTC (permalink / raw)
  To: Jaehoon Chung, Ulf Hansson
  Cc: linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Shawn Lin,
	linux-mmc-u79uwXL29TY76Z2rM5mHXA, Doug Anderson

Let's migrate it to use runtime PM and remove the system
PM callback from this driver. With this patch, it could
handle system PM properly and could also use runtime PM
if we enable it.

Signed-off-by: Shawn Lin <shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
---

 drivers/mmc/host/dw_mmc-pltfm.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c
index c0bb0c7..214e593 100644
--- a/drivers/mmc/host/dw_mmc-pltfm.c
+++ b/drivers/mmc/host/dw_mmc-pltfm.c
@@ -16,6 +16,7 @@
 #include <linux/io.h>
 #include <linux/irq.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/mmc.h>
@@ -57,26 +58,29 @@ int dw_mci_pltfm_register(struct platform_device *pdev,
 }
 EXPORT_SYMBOL_GPL(dw_mci_pltfm_register);
 
-#ifdef CONFIG_PM_SLEEP
-/*
- * TODO: we should probably disable the clock to the card in the suspend path.
- */
-static int dw_mci_pltfm_suspend(struct device *dev)
+#ifdef CONFIG_PM
+static int dw_mci_pltfm_runtime_suspend(struct device *dev)
 {
 	struct dw_mci *host = dev_get_drvdata(dev);
 
-	return dw_mci_suspend(host);
+	return dw_mci_runtime_suspend(host);
 }
 
-static int dw_mci_pltfm_resume(struct device *dev)
+static int dw_mci_pltfm_runtime_resume(struct device *dev)
 {
 	struct dw_mci *host = dev_get_drvdata(dev);
 
-	return dw_mci_resume(host);
+	return dw_mci_runtime_resume(host);
 }
-#endif /* CONFIG_PM_SLEEP */
-
-SIMPLE_DEV_PM_OPS(dw_mci_pltfm_pmops, dw_mci_pltfm_suspend, dw_mci_pltfm_resume);
+#endif /* CONFIG_PM */
+
+const struct dev_pm_ops dw_mci_pltfm_pmops = {
+	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
+				pm_runtime_force_resume)
+	SET_RUNTIME_PM_OPS(dw_mci_pltfm_runtime_suspend,
+			   dw_mci_pltfm_runtime_resume,
+			   NULL)
+};
 EXPORT_SYMBOL_GPL(dw_mci_pltfm_pmops);
 
 static const struct of_device_id dw_mci_pltfm_match[] = {
-- 
2.3.7

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

* [RESEND PATCH 9/9] mmc: dw_mmc: remove system PM callback
  2016-10-09 14:01   ` [RESEND PATCH 5/9] mmc: dw_mmc-k3: deploay runtime PM facilities Shawn Lin
                       ` (2 preceding siblings ...)
       [not found]     ` <1476021721-923-1-git-send-email-shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
@ 2016-10-09 14:02     ` Shawn Lin
  3 siblings, 0 replies; 12+ messages in thread
From: Shawn Lin @ 2016-10-09 14:02 UTC (permalink / raw)
  To: Jaehoon Chung, Ulf Hansson
  Cc: linux-mmc, Doug Anderson, linux-rockchip, Shawn Lin

Now there are no variant drivers using dw_mci_suspend
and dw_mci_resume, so let's remove it.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/mmc/host/dw_mmc.c | 44 ++++++++------------------------------------
 drivers/mmc/host/dw_mmc.h |  2 --
 2 files changed, 8 insertions(+), 38 deletions(-)

diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index c5ef263..46a14c5 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -3267,26 +3267,24 @@ EXPORT_SYMBOL(dw_mci_remove);
 
 
 #ifdef CONFIG_PM
-/*
- * TODO: we should probably disable the clock to the card in the suspend path.
- */
-int dw_mci_suspend(struct dw_mci *host)
+int dw_mci_runtime_suspend(struct dw_mci *host)
 {
 	if (host->use_dma && host->dma_ops->exit)
 		host->dma_ops->exit(host);
 
+	clk_disable_unprepare(host->ciu_clk);
+
 	return 0;
 }
-EXPORT_SYMBOL(dw_mci_suspend);
+EXPORT_SYMBOL(dw_mci_runtime_suspend);
 
-int dw_mci_resume(struct dw_mci *host)
+int dw_mci_runtime_resume(struct dw_mci *host)
 {
-	int i, ret;
+	int i, ret = 0;
 
-	if (!dw_mci_ctrl_reset(host, SDMMC_CTRL_ALL_RESET_FLAGS)) {
-		ret = -ENODEV;
+	ret = clk_prepare_enable(host->ciu_clk);
+	if (ret)
 		return ret;
-	}
 
 	if (host->use_dma && host->dma_ops->init)
 		host->dma_ops->init(host);
@@ -3323,32 +3321,6 @@ int dw_mci_resume(struct dw_mci *host)
 
 	return 0;
 }
-EXPORT_SYMBOL(dw_mci_resume);
-
-int dw_mci_runtime_suspend(struct dw_mci *host)
-{
-	int err = 0;
-
-	err = dw_mci_suspend(host);
-	if (err)
-		return err;
-
-	clk_disable_unprepare(host->ciu_clk);
-
-	return err;
-}
-EXPORT_SYMBOL(dw_mci_runtime_suspend);
-
-int dw_mci_runtime_resume(struct dw_mci *host)
-{
-	int ret = 0;
-
-	ret = clk_prepare_enable(host->ciu_clk);
-	if (ret)
-		return ret;
-
-	return dw_mci_resume(host);
-}
 EXPORT_SYMBOL(dw_mci_runtime_resume);
 #endif /* CONFIG_PM */
 
diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
index baa7261..b642dbb 100644
--- a/drivers/mmc/host/dw_mmc.h
+++ b/drivers/mmc/host/dw_mmc.h
@@ -235,8 +235,6 @@
 extern int dw_mci_probe(struct dw_mci *host);
 extern void dw_mci_remove(struct dw_mci *host);
 #ifdef CONFIG_PM
-extern int dw_mci_suspend(struct dw_mci *host);
-extern int dw_mci_resume(struct dw_mci *host);
 extern int dw_mci_runtime_suspend(struct dw_mci *host);
 extern int dw_mci_runtime_resume(struct dw_mci *host);
 #endif
-- 
2.3.7



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

* Re: [RESEND PATCH 0/9] Init runtime PM support for dw_mmc
  2016-10-09 13:58 ` [RESEND PATCH 0/9] Init runtime PM support for dw_mmc Shawn Lin
                     ` (4 preceding siblings ...)
  2016-10-09 14:01   ` [RESEND PATCH 5/9] mmc: dw_mmc-k3: deploay runtime PM facilities Shawn Lin
@ 2016-10-10  2:10   ` Jaehoon Chung
  2016-10-10  2:30     ` Shawn Lin
  5 siblings, 1 reply; 12+ messages in thread
From: Jaehoon Chung @ 2016-10-10  2:10 UTC (permalink / raw)
  To: Shawn Lin, Ulf Hansson; +Cc: linux-mmc, Doug Anderson, linux-rockchip

Hi Shawn,

On 10/09/2016 10:58 PM, Shawn Lin wrote:
> Hi Jaehoon and Ulf,
> 
>    This patch is gonna support runtime PM for dw_mmc.
> It could support to disable ciu_clk by default and disable
> biu_clk if the devices are non-removeable, or removeable
> with gpio-base card detect.
> 
>    Then I remove the system PM since the runtime PM actually
> does the same thing as it. So I help migrate the dw_mmc variant
> drivers to use runtime PM pairs and pm_runtime_force_*. Note
> that I only enable runtime PM for dw_mmc-rockchip as I will
> leave the decision to the owners of the corresponding drivers.
> I just tested it on my RK3288 platform with linux-next to make
> the runtime PM and system PM work fine for my emmc, sd card and
> sdio. But I don't have hardware to help test other variant drivers.
> But in theory it should work fine as I mentioned that the runtime
> PM does the same thing as system PM except for disabling ciu_clk
> aggressively which should not be related to the variant hosts.

I'm testing this patchset with exynos SoCs. If it's possible to use other SoCs,
then I think your patches will be changed more clear than now.
e.g) Not need to define the each driver's runtime_pm_suspend/resume function.

> 
>    As you could see that I just extend the slot-gpio a bit, so the
> ideal way is Ulf could pick them up with Jaehoon's ack. :)
> 
> 
> 
> Shawn Lin (9):
>   mmc: dw_mmc: add runtime PM callback
>   mmc: dw_mmc-rockchip: add runtime PM support
>   mmc: core: expose the capability of gpio card detect
>   mmc: dw_mmc-rockchip: disable biu clk if possible
>   mmc: dw_mmc-k3: deploay runtime PM facilities
>   mmc: dw_mmc-exynos: deploay runtime PM facilities
>   mmc: dw_mmc-pci: deploay runtime PM facilities
>   mmc: dw_mmc-pltfm: deploay runtime PM facilities

Maybe s/deploay/deploy

Best Regards,
Jaehoon Chung

>   mmc: dw_mmc: remove system PM callback
> 
>  drivers/mmc/core/slot-gpio.c       |  8 +++++
>  drivers/mmc/host/dw_mmc-exynos.c   | 21 ++++++-----
>  drivers/mmc/host/dw_mmc-k3.c       | 37 +++++++++----------
>  drivers/mmc/host/dw_mmc-pci.c      | 25 ++++++++-----
>  drivers/mmc/host/dw_mmc-pltfm.c    | 26 ++++++++------
>  drivers/mmc/host/dw_mmc-rockchip.c | 73 ++++++++++++++++++++++++++++++++++++--
>  drivers/mmc/host/dw_mmc.c          | 24 ++++++-------
>  drivers/mmc/host/dw_mmc.h          |  6 ++--
>  include/linux/mmc/slot-gpio.h      |  1 +
>  9 files changed, 152 insertions(+), 69 deletions(-)
> 


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

* Re: [RESEND PATCH 0/9] Init runtime PM support for dw_mmc
  2016-10-10  2:10   ` [RESEND PATCH 0/9] Init runtime PM support for dw_mmc Jaehoon Chung
@ 2016-10-10  2:30     ` Shawn Lin
  0 siblings, 0 replies; 12+ messages in thread
From: Shawn Lin @ 2016-10-10  2:30 UTC (permalink / raw)
  To: Jaehoon Chung, Ulf Hansson
  Cc: shawn.lin, linux-mmc, Doug Anderson, linux-rockchip

在 2016/10/10 10:10, Jaehoon Chung 写道:
> Hi Shawn,
>
> On 10/09/2016 10:58 PM, Shawn Lin wrote:
>> Hi Jaehoon and Ulf,
>>
>>    This patch is gonna support runtime PM for dw_mmc.
>> It could support to disable ciu_clk by default and disable
>> biu_clk if the devices are non-removeable, or removeable
>> with gpio-base card detect.
>>
>>    Then I remove the system PM since the runtime PM actually
>> does the same thing as it. So I help migrate the dw_mmc variant
>> drivers to use runtime PM pairs and pm_runtime_force_*. Note
>> that I only enable runtime PM for dw_mmc-rockchip as I will
>> leave the decision to the owners of the corresponding drivers.
>> I just tested it on my RK3288 platform with linux-next to make
>> the runtime PM and system PM work fine for my emmc, sd card and
>> sdio. But I don't have hardware to help test other variant drivers.
>> But in theory it should work fine as I mentioned that the runtime
>> PM does the same thing as system PM except for disabling ciu_clk
>> aggressively which should not be related to the variant hosts.
>
> I'm testing this patchset with exynos SoCs. If it's possible to use other SoCs,

Thanks for testing this patchset, I will respin v2 if there are no any
other nitpick from folkz and regression when you test it.

> then I think your patches will be changed more clear than now.
> e.g) Not need to define the each driver's runtime_pm_suspend/resume function.
>

Sure.

>>
>>    As you could see that I just extend the slot-gpio a bit, so the
>> ideal way is Ulf could pick them up with Jaehoon's ack. :)
>>
>>
>>
>> Shawn Lin (9):
>>   mmc: dw_mmc: add runtime PM callback
>>   mmc: dw_mmc-rockchip: add runtime PM support
>>   mmc: core: expose the capability of gpio card detect
>>   mmc: dw_mmc-rockchip: disable biu clk if possible
>>   mmc: dw_mmc-k3: deploay runtime PM facilities
>>   mmc: dw_mmc-exynos: deploay runtime PM facilities
>>   mmc: dw_mmc-pci: deploay runtime PM facilities
>>   mmc: dw_mmc-pltfm: deploay runtime PM facilities
>
> Maybe s/deploay/deploy

Will fix the copy-paste error, mea culpa, but it is quite
interesting that checkpatch.pl didn't yell at it. :)

>
> Best Regards,
> Jaehoon Chung
>
>>   mmc: dw_mmc: remove system PM callback
>>
>>  drivers/mmc/core/slot-gpio.c       |  8 +++++
>>  drivers/mmc/host/dw_mmc-exynos.c   | 21 ++++++-----
>>  drivers/mmc/host/dw_mmc-k3.c       | 37 +++++++++----------
>>  drivers/mmc/host/dw_mmc-pci.c      | 25 ++++++++-----
>>  drivers/mmc/host/dw_mmc-pltfm.c    | 26 ++++++++------
>>  drivers/mmc/host/dw_mmc-rockchip.c | 73 ++++++++++++++++++++++++++++++++++++--
>>  drivers/mmc/host/dw_mmc.c          | 24 ++++++-------
>>  drivers/mmc/host/dw_mmc.h          |  6 ++--
>>  include/linux/mmc/slot-gpio.h      |  1 +
>>  9 files changed, 152 insertions(+), 69 deletions(-)
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


-- 
Best Regards
Shawn Lin


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

end of thread, other threads:[~2016-10-10  2:31 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20161009135255epcas1p4d5a9db74bb1dea56f61fcb2a720a07f0@epcas1p4.samsung.com>
2016-10-09 13:58 ` [RESEND PATCH 0/9] Init runtime PM support for dw_mmc Shawn Lin
2016-10-09 13:58   ` [RESEND PATCH 1/9] mmc: dw_mmc: add runtime PM callback Shawn Lin
2016-10-09 13:58   ` [RESEND PATCH 2/9] mmc: dw_mmc-rockchip: add runtime PM support Shawn Lin
2016-10-09 13:58   ` [RESEND PATCH 3/9] mmc: core: expose the capability of gpio card detect Shawn Lin
2016-10-09 13:58   ` [RESEND PATCH 4/9] mmc: dw_mmc-rockchip: disable biu clk if possible Shawn Lin
2016-10-09 14:01   ` [RESEND PATCH 5/9] mmc: dw_mmc-k3: deploay runtime PM facilities Shawn Lin
2016-10-09 14:01     ` [RESEND PATCH 6/9] mmc: dw_mmc-exynos: " Shawn Lin
2016-10-09 14:01     ` [RESEND PATCH 7/9] mmc: dw_mmc-pci: " Shawn Lin
     [not found]     ` <1476021721-923-1-git-send-email-shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2016-10-09 14:02       ` [RESEND PATCH 8/9] mmc: dw_mmc-pltfm: " Shawn Lin
2016-10-09 14:02     ` [RESEND PATCH 9/9] mmc: dw_mmc: remove system PM callback Shawn Lin
2016-10-10  2:10   ` [RESEND PATCH 0/9] Init runtime PM support for dw_mmc Jaehoon Chung
2016-10-10  2:30     ` Shawn Lin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.