All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] ata: sata_rcar: Add rudimentary Runtime PM support
@ 2018-07-20 12:27 Geert Uytterhoeven
  2018-07-20 12:27 ` [PATCH 1/2] ata: sata_rcar: Provide a short-hand for &pdev->dev Geert Uytterhoeven
  2018-07-20 12:27 ` [PATCH 2/2] ata: sata_rcar: Add rudimentary Runtime PM support Geert Uytterhoeven
  0 siblings, 2 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2018-07-20 12:27 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Wolfram Sang, linux-ide, linux-renesas-soc, Geert Uytterhoeven

	Hi Tejun,

This patch series replaces the explicit clock handling in the Reneas
R-Car SATA driver by proper Runtime PM calls.

Besides making the driver more generic and independent of actual SoC
clock/power hierarchies, this is also needed to support virtualization,
where the guest cannot be in full control of power management due to
isolation.

For now the device is just powered at probe time, like before.
Further PM optimizations can be done later.

Thanks!

Geert Uytterhoeven (2):
  ata: sata_rcar: Provide a short-hand for &pdev->dev
  ata: sata_rcar: Add rudimentary Runtime PM support

 drivers/ata/sata_rcar.c | 52 +++++++++++++++++++----------------------
 1 file changed, 24 insertions(+), 28 deletions(-)

-- 
2.17.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

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

* [PATCH 1/2] ata: sata_rcar: Provide a short-hand for &pdev->dev
  2018-07-20 12:27 [PATCH 0/2] ata: sata_rcar: Add rudimentary Runtime PM support Geert Uytterhoeven
@ 2018-07-20 12:27 ` Geert Uytterhoeven
  2018-07-20 15:29   ` Sergei Shtylyov
                     ` (2 more replies)
  2018-07-20 12:27 ` [PATCH 2/2] ata: sata_rcar: Add rudimentary Runtime PM support Geert Uytterhoeven
  1 sibling, 3 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2018-07-20 12:27 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Wolfram Sang, linux-ide, linux-renesas-soc, Geert Uytterhoeven

No functional changes.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/ata/sata_rcar.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c
index 6456e07db72a7ea4..f972c2c5ebd34aff 100644
--- a/drivers/ata/sata_rcar.c
+++ b/drivers/ata/sata_rcar.c
@@ -881,6 +881,7 @@ MODULE_DEVICE_TABLE(of, sata_rcar_match);
 
 static int sata_rcar_probe(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	struct ata_host *host;
 	struct sata_rcar_priv *priv;
 	struct resource *mem;
@@ -891,15 +892,14 @@ static int sata_rcar_probe(struct platform_device *pdev)
 	if (irq <= 0)
 		return -EINVAL;
 
-	priv = devm_kzalloc(&pdev->dev, sizeof(struct sata_rcar_priv),
-			   GFP_KERNEL);
+	priv = devm_kzalloc(dev, sizeof(struct sata_rcar_priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
-	priv->type = (enum sata_rcar_type)of_device_get_match_data(&pdev->dev);
-	priv->clk = devm_clk_get(&pdev->dev, NULL);
+	priv->type = (enum sata_rcar_type)of_device_get_match_data(dev);
+	priv->clk = devm_clk_get(dev, NULL);
 	if (IS_ERR(priv->clk)) {
-		dev_err(&pdev->dev, "failed to get access to sata clock\n");
+		dev_err(dev, "failed to get access to sata clock\n");
 		return PTR_ERR(priv->clk);
 	}
 
@@ -907,9 +907,9 @@ static int sata_rcar_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	host = ata_host_alloc(&pdev->dev, 1);
+	host = ata_host_alloc(dev, 1);
 	if (!host) {
-		dev_err(&pdev->dev, "ata_host_alloc failed\n");
+		dev_err(dev, "ata_host_alloc failed\n");
 		ret = -ENOMEM;
 		goto cleanup;
 	}
@@ -917,7 +917,7 @@ static int sata_rcar_probe(struct platform_device *pdev)
 	host->private_data = priv;
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	priv->base = devm_ioremap_resource(&pdev->dev, mem);
+	priv->base = devm_ioremap_resource(dev, mem);
 	if (IS_ERR(priv->base)) {
 		ret = PTR_ERR(priv->base);
 		goto cleanup;
-- 
2.17.1

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

* [PATCH 2/2] ata: sata_rcar: Add rudimentary Runtime PM support
  2018-07-20 12:27 [PATCH 0/2] ata: sata_rcar: Add rudimentary Runtime PM support Geert Uytterhoeven
  2018-07-20 12:27 ` [PATCH 1/2] ata: sata_rcar: Provide a short-hand for &pdev->dev Geert Uytterhoeven
@ 2018-07-20 12:27 ` Geert Uytterhoeven
  2018-07-20 15:37   ` Sergei Shtylyov
  2018-07-25 19:11   ` Wolfram Sang
  1 sibling, 2 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2018-07-20 12:27 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Wolfram Sang, linux-ide, linux-renesas-soc, Geert Uytterhoeven

Replace the explicit clock handling to enable/disable the SATA module by
calls to Runtime PM.

This makes the driver independent of actual SoC clock/power hierarchies,
and is needed to support virtualization, where the guest is not in full
control of power management.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/ata/sata_rcar.c | 40 ++++++++++++++++++----------------------
 1 file changed, 18 insertions(+), 22 deletions(-)

diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c
index f972c2c5ebd34aff..3b8ed10bfb8f2861 100644
--- a/drivers/ata/sata_rcar.c
+++ b/drivers/ata/sata_rcar.c
@@ -17,7 +17,7 @@
 #include <linux/libata.h>
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
-#include <linux/clk.h>
+#include <linux/pm_runtime.h>
 #include <linux/err.h>
 
 #define DRV_NAME "sata_rcar"
@@ -152,7 +152,6 @@ enum sata_rcar_type {
 
 struct sata_rcar_priv {
 	void __iomem *base;
-	struct clk *clk;
 	enum sata_rcar_type type;
 };
 
@@ -897,21 +896,17 @@ static int sata_rcar_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	priv->type = (enum sata_rcar_type)of_device_get_match_data(dev);
-	priv->clk = devm_clk_get(dev, NULL);
-	if (IS_ERR(priv->clk)) {
-		dev_err(dev, "failed to get access to sata clock\n");
-		return PTR_ERR(priv->clk);
-	}
 
-	ret = clk_prepare_enable(priv->clk);
-	if (ret)
-		return ret;
+	pm_runtime_enable(dev);
+	ret = pm_runtime_get_sync(dev);
+	if (ret < 0)
+		goto err_pm_disable;
 
 	host = ata_host_alloc(dev, 1);
 	if (!host) {
 		dev_err(dev, "ata_host_alloc failed\n");
 		ret = -ENOMEM;
-		goto cleanup;
+		goto err_pm_put;
 	}
 
 	host->private_data = priv;
@@ -920,7 +915,7 @@ static int sata_rcar_probe(struct platform_device *pdev)
 	priv->base = devm_ioremap_resource(dev, mem);
 	if (IS_ERR(priv->base)) {
 		ret = PTR_ERR(priv->base);
-		goto cleanup;
+		goto err_pm_put;
 	}
 
 	/* setup port */
@@ -934,9 +929,10 @@ static int sata_rcar_probe(struct platform_device *pdev)
 	if (!ret)
 		return 0;
 
-cleanup:
-	clk_disable_unprepare(priv->clk);
-
+err_pm_put:
+	pm_runtime_put(dev);
+err_pm_disable:
+	pm_runtime_disable(dev);
 	return ret;
 }
 
@@ -954,7 +950,8 @@ static int sata_rcar_remove(struct platform_device *pdev)
 	iowrite32(0, base + SATAINTSTAT_REG);
 	iowrite32(0x7ff, base + SATAINTMASK_REG);
 
-	clk_disable_unprepare(priv->clk);
+	pm_runtime_put(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
 
 	return 0;
 }
@@ -974,7 +971,7 @@ static int sata_rcar_suspend(struct device *dev)
 		/* mask */
 		iowrite32(0x7ff, base + SATAINTMASK_REG);
 
-		clk_disable_unprepare(priv->clk);
+		pm_runtime_put(dev);
 	}
 
 	return ret;
@@ -987,8 +984,8 @@ static int sata_rcar_resume(struct device *dev)
 	void __iomem *base = priv->base;
 	int ret;
 
-	ret = clk_prepare_enable(priv->clk);
-	if (ret)
+	ret = pm_runtime_get_sync(dev);
+	if (ret < 0)
 		return ret;
 
 	if (priv->type == RCAR_GEN3_SATA) {
@@ -1012,11 +1009,10 @@ static int sata_rcar_resume(struct device *dev)
 static int sata_rcar_restore(struct device *dev)
 {
 	struct ata_host *host = dev_get_drvdata(dev);
-	struct sata_rcar_priv *priv = host->private_data;
 	int ret;
 
-	ret = clk_prepare_enable(priv->clk);
-	if (ret)
+	ret = pm_runtime_get_sync(dev);
+	if (ret < 0)
 		return ret;
 
 	sata_rcar_setup_port(host);
-- 
2.17.1

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

* Re: [PATCH 1/2] ata: sata_rcar: Provide a short-hand for &pdev->dev
  2018-07-20 12:27 ` [PATCH 1/2] ata: sata_rcar: Provide a short-hand for &pdev->dev Geert Uytterhoeven
@ 2018-07-20 15:29   ` Sergei Shtylyov
  2018-07-23 15:19   ` Tejun Heo
  2018-07-25 19:10   ` Wolfram Sang
  2 siblings, 0 replies; 8+ messages in thread
From: Sergei Shtylyov @ 2018-07-20 15:29 UTC (permalink / raw)
  To: Geert Uytterhoeven, Tejun Heo; +Cc: Wolfram Sang, linux-ide, linux-renesas-soc

Hello!

On 07/20/2018 03:27 PM, Geert Uytterhoeven wrote:

> No functional changes.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
[...]

Reviewed-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

MBR, Sergei

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

* Re: [PATCH 2/2] ata: sata_rcar: Add rudimentary Runtime PM support
  2018-07-20 12:27 ` [PATCH 2/2] ata: sata_rcar: Add rudimentary Runtime PM support Geert Uytterhoeven
@ 2018-07-20 15:37   ` Sergei Shtylyov
  2018-07-25 19:11   ` Wolfram Sang
  1 sibling, 0 replies; 8+ messages in thread
From: Sergei Shtylyov @ 2018-07-20 15:37 UTC (permalink / raw)
  To: Geert Uytterhoeven, Tejun Heo; +Cc: Wolfram Sang, linux-ide, linux-renesas-soc

On 07/20/2018 03:27 PM, Geert Uytterhoeven wrote:

> Replace the explicit clock handling to enable/disable the SATA module by
> calls to Runtime PM.
> 
> This makes the driver independent of actual SoC clock/power hierarchies,
> and is needed to support virtualization, where the guest is not in full
> control of power management.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
[...]

Reviewed-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

MBR, Sergei

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

* Re: [PATCH 1/2] ata: sata_rcar: Provide a short-hand for &pdev->dev
  2018-07-20 12:27 ` [PATCH 1/2] ata: sata_rcar: Provide a short-hand for &pdev->dev Geert Uytterhoeven
  2018-07-20 15:29   ` Sergei Shtylyov
@ 2018-07-23 15:19   ` Tejun Heo
  2018-07-25 19:10   ` Wolfram Sang
  2 siblings, 0 replies; 8+ messages in thread
From: Tejun Heo @ 2018-07-23 15:19 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Wolfram Sang, linux-ide, linux-renesas-soc

On Fri, Jul 20, 2018 at 02:27:38PM +0200, Geert Uytterhoeven wrote:
> No functional changes.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Applied 1-2 to libata/for-4.19.

Thanks.

-- 
tejun

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

* Re: [PATCH 1/2] ata: sata_rcar: Provide a short-hand for &pdev->dev
  2018-07-20 12:27 ` [PATCH 1/2] ata: sata_rcar: Provide a short-hand for &pdev->dev Geert Uytterhoeven
  2018-07-20 15:29   ` Sergei Shtylyov
  2018-07-23 15:19   ` Tejun Heo
@ 2018-07-25 19:10   ` Wolfram Sang
  2 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2018-07-25 19:10 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Tejun Heo, Wolfram Sang, linux-ide, linux-renesas-soc

[-- Attachment #1: Type: text/plain, Size: 362 bytes --]

On Fri, Jul 20, 2018 at 02:27:38PM +0200, Geert Uytterhoeven wrote:
> No functional changes.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

For the record, works fine with the newly added SATA support for M3-N:

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 2/2] ata: sata_rcar: Add rudimentary Runtime PM support
  2018-07-20 12:27 ` [PATCH 2/2] ata: sata_rcar: Add rudimentary Runtime PM support Geert Uytterhoeven
  2018-07-20 15:37   ` Sergei Shtylyov
@ 2018-07-25 19:11   ` Wolfram Sang
  1 sibling, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2018-07-25 19:11 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Tejun Heo, Wolfram Sang, linux-ide, linux-renesas-soc

[-- Attachment #1: Type: text/plain, Size: 623 bytes --]

On Fri, Jul 20, 2018 at 02:27:39PM +0200, Geert Uytterhoeven wrote:
> Replace the explicit clock handling to enable/disable the SATA module by
> calls to Runtime PM.
> 
> This makes the driver independent of actual SoC clock/power hierarchies,
> and is needed to support virtualization, where the guest is not in full
> control of power management.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

For the record, works fine with the newly added SATA support for M3-N:

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2018-07-25 20:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-20 12:27 [PATCH 0/2] ata: sata_rcar: Add rudimentary Runtime PM support Geert Uytterhoeven
2018-07-20 12:27 ` [PATCH 1/2] ata: sata_rcar: Provide a short-hand for &pdev->dev Geert Uytterhoeven
2018-07-20 15:29   ` Sergei Shtylyov
2018-07-23 15:19   ` Tejun Heo
2018-07-25 19:10   ` Wolfram Sang
2018-07-20 12:27 ` [PATCH 2/2] ata: sata_rcar: Add rudimentary Runtime PM support Geert Uytterhoeven
2018-07-20 15:37   ` Sergei Shtylyov
2018-07-25 19:11   ` Wolfram Sang

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.