Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/2] crypto: sun4i-ss: Enable power management
@ 2019-09-11 11:46 Corentin Labbe
  2019-09-11 11:46 ` [PATCH 1/2] crypto: sun4i-ss: simplify enable/disable of the device Corentin Labbe
  2019-09-11 11:46 ` [PATCH 2/2] crypto: sun4i-ss: enable pm_runtime Corentin Labbe
  0 siblings, 2 replies; 6+ messages in thread
From: Corentin Labbe @ 2019-09-11 11:46 UTC (permalink / raw)
  To: davem, herbert, mripard, wens
  Cc: linux-sunxi, Corentin Labbe, linux-crypto, linux-arm-kernel,
	linux-kernel

Hello

This serie enables power management in the sun4i-ss driver.

Regards

Corentin Labbe (2):
  crypto: sun4i-ss: simplify enable/disable of the device
  crypto: sun4i-ss: enable pm_runtime

 drivers/crypto/sunxi-ss/sun4i-ss-cipher.c |   5 +
 drivers/crypto/sunxi-ss/sun4i-ss-core.c   | 115 ++++++++++++++++------
 2 files changed, 88 insertions(+), 32 deletions(-)

-- 
2.21.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 1/2] crypto: sun4i-ss: simplify enable/disable of the device
  2019-09-11 11:46 [PATCH 0/2] crypto: sun4i-ss: Enable power management Corentin Labbe
@ 2019-09-11 11:46 ` Corentin Labbe
  2019-09-12  6:32   ` Maxime Ripard
  2019-09-11 11:46 ` [PATCH 2/2] crypto: sun4i-ss: enable pm_runtime Corentin Labbe
  1 sibling, 1 reply; 6+ messages in thread
From: Corentin Labbe @ 2019-09-11 11:46 UTC (permalink / raw)
  To: davem, herbert, mripard, wens
  Cc: linux-sunxi, Corentin Labbe, linux-crypto, linux-arm-kernel,
	linux-kernel

This patch regroups resource enabling/disabling in dedicated function.
This simplify error handling and will permit to support power
management.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/crypto/sunxi-ss/sun4i-ss-core.c | 73 ++++++++++++++-----------
 1 file changed, 42 insertions(+), 31 deletions(-)

diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-core.c b/drivers/crypto/sunxi-ss/sun4i-ss-core.c
index 9aa6fe081a27..2c9ff01dddfc 100644
--- a/drivers/crypto/sunxi-ss/sun4i-ss-core.c
+++ b/drivers/crypto/sunxi-ss/sun4i-ss-core.c
@@ -223,6 +223,41 @@ static struct sun4i_ss_alg_template ss_algs[] = {
 #endif
 };
 
+static void sun4i_ss_disable(struct sun4i_ss_ctx *ss)
+{
+	if (ss->reset)
+		reset_control_assert(ss->reset);
+	clk_disable_unprepare(ss->ssclk);
+	clk_disable_unprepare(ss->busclk);
+}
+
+static int sun4i_ss_enable(struct sun4i_ss_ctx *ss)
+{
+	int err;
+
+	err = clk_prepare_enable(ss->busclk);
+	if (err) {
+		dev_err(ss->dev, "Cannot prepare_enable busclk\n");
+		goto err_enable;
+	}
+	err = clk_prepare_enable(ss->ssclk);
+	if (err) {
+		dev_err(ss->dev, "Cannot prepare_enable ssclk\n");
+		goto err_enable;
+	}
+	if (ss->reset) {
+		err = reset_control_deassert(ss->reset);
+		if (err) {
+			dev_err(ss->dev, "Cannot deassert reset control\n");
+			goto err_enable;
+		}
+	}
+	return err;
+err_enable:
+	sun4i_ss_disable(ss);
+	return err;
+}
+
 static int sun4i_ss_probe(struct platform_device *pdev)
 {
 	u32 v;
@@ -269,17 +304,9 @@ static int sun4i_ss_probe(struct platform_device *pdev)
 		ss->reset = NULL;
 	}
 
-	/* Enable both clocks */
-	err = clk_prepare_enable(ss->busclk);
-	if (err) {
-		dev_err(&pdev->dev, "Cannot prepare_enable busclk\n");
-		return err;
-	}
-	err = clk_prepare_enable(ss->ssclk);
-	if (err) {
-		dev_err(&pdev->dev, "Cannot prepare_enable ssclk\n");
-		goto error_ssclk;
-	}
+	err = sun4i_ss_enable(ss);
+	if (err)
+		goto error_enable;
 
 	/*
 	 * Check that clock have the correct rates given in the datasheet
@@ -288,16 +315,7 @@ static int sun4i_ss_probe(struct platform_device *pdev)
 	err = clk_set_rate(ss->ssclk, cr_mod);
 	if (err) {
 		dev_err(&pdev->dev, "Cannot set clock rate to ssclk\n");
-		goto error_clk;
-	}
-
-	/* Deassert reset if we have a reset control */
-	if (ss->reset) {
-		err = reset_control_deassert(ss->reset);
-		if (err) {
-			dev_err(&pdev->dev, "Cannot deassert reset control\n");
-			goto error_clk;
-		}
+		goto error_enable;
 	}
 
 	/*
@@ -387,12 +405,8 @@ static int sun4i_ss_probe(struct platform_device *pdev)
 			break;
 		}
 	}
-	if (ss->reset)
-		reset_control_assert(ss->reset);
-error_clk:
-	clk_disable_unprepare(ss->ssclk);
-error_ssclk:
-	clk_disable_unprepare(ss->busclk);
+error_enable:
+	sun4i_ss_disable(ss);
 	return err;
 }
 
@@ -416,10 +430,7 @@ static int sun4i_ss_remove(struct platform_device *pdev)
 	}
 
 	writel(0, ss->base + SS_CTL);
-	if (ss->reset)
-		reset_control_assert(ss->reset);
-	clk_disable_unprepare(ss->busclk);
-	clk_disable_unprepare(ss->ssclk);
+	sun4i_ss_disable(ss);
 	return 0;
 }
 
-- 
2.21.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/2] crypto: sun4i-ss: enable pm_runtime
  2019-09-11 11:46 [PATCH 0/2] crypto: sun4i-ss: Enable power management Corentin Labbe
  2019-09-11 11:46 ` [PATCH 1/2] crypto: sun4i-ss: simplify enable/disable of the device Corentin Labbe
@ 2019-09-11 11:46 ` Corentin Labbe
  2019-09-12  6:35   ` Maxime Ripard
  1 sibling, 1 reply; 6+ messages in thread
From: Corentin Labbe @ 2019-09-11 11:46 UTC (permalink / raw)
  To: davem, herbert, mripard, wens
  Cc: linux-sunxi, Corentin Labbe, linux-crypto, linux-arm-kernel,
	linux-kernel

This patch enables power management on the Security System.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/crypto/sunxi-ss/sun4i-ss-cipher.c |  5 +++
 drivers/crypto/sunxi-ss/sun4i-ss-core.c   | 42 ++++++++++++++++++++++-
 2 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
index fa4b1b47822e..1fedec9e83b0 100644
--- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
+++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
@@ -10,6 +10,8 @@
  *
  * You could find the datasheet in Documentation/arm/sunxi.rst
  */
+
+#include <linux/pm_runtime.h>
 #include "sun4i-ss.h"
 
 static int noinline_for_stack sun4i_ss_opti_poll(struct skcipher_request *areq)
@@ -497,13 +499,16 @@ int sun4i_ss_cipher_init(struct crypto_tfm *tfm)
 		return PTR_ERR(op->fallback_tfm);
 	}
 
+	pm_runtime_get_sync(op->ss->dev);
 	return 0;
 }
 
 void sun4i_ss_cipher_exit(struct crypto_tfm *tfm)
 {
 	struct sun4i_tfm_ctx *op = crypto_tfm_ctx(tfm);
+
 	crypto_free_sync_skcipher(op->fallback_tfm);
+	pm_runtime_put_sync(op->ss->dev);
 }
 
 /* check and set the AES key, prepare the mode to be used */
diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-core.c b/drivers/crypto/sunxi-ss/sun4i-ss-core.c
index 2c9ff01dddfc..5e6e1a308f60 100644
--- a/drivers/crypto/sunxi-ss/sun4i-ss-core.c
+++ b/drivers/crypto/sunxi-ss/sun4i-ss-core.c
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <crypto/scatterwalk.h>
 #include <linux/scatterlist.h>
 #include <linux/interrupt.h>
@@ -258,6 +259,37 @@ static int sun4i_ss_enable(struct sun4i_ss_ctx *ss)
 	return err;
 }
 
+#ifdef CONFIG_PM
+static int sun4i_ss_pm_suspend(struct device *dev)
+{
+	struct sun4i_ss_ctx *ss = dev_get_drvdata(dev);
+
+	sun4i_ss_disable(ss);
+	return 0;
+}
+
+static int sun4i_ss_pm_resume(struct device *dev)
+{
+	struct sun4i_ss_ctx *ss = dev_get_drvdata(dev);
+
+	return sun4i_ss_enable(ss);
+}
+#endif
+
+const struct dev_pm_ops sun4i_ss_pm_ops = {
+	SET_RUNTIME_PM_OPS(sun4i_ss_pm_suspend, sun4i_ss_pm_resume, NULL)
+};
+
+static void sun4i_ss_pm_init(struct sun4i_ss_ctx *ss)
+{
+	pm_runtime_use_autosuspend(ss->dev);
+	pm_runtime_set_autosuspend_delay(ss->dev, 1000);
+
+	pm_runtime_get_noresume(ss->dev);
+	pm_runtime_set_active(ss->dev);
+	pm_runtime_enable(ss->dev);
+}
+
 static int sun4i_ss_probe(struct platform_device *pdev)
 {
 	u32 v;
@@ -357,9 +389,12 @@ static int sun4i_ss_probe(struct platform_device *pdev)
 	writel(0, ss->base + SS_CTL);
 
 	ss->dev = &pdev->dev;
+	platform_set_drvdata(pdev, ss);
 
 	spin_lock_init(&ss->slock);
 
+	sun4i_ss_pm_init(ss);
+
 	for (i = 0; i < ARRAY_SIZE(ss_algs); i++) {
 		ss_algs[i].ss = ss;
 		switch (ss_algs[i].type) {
@@ -388,7 +423,8 @@ static int sun4i_ss_probe(struct platform_device *pdev)
 			break;
 		}
 	}
-	platform_set_drvdata(pdev, ss);
+
+	pm_runtime_put_sync(ss->dev);
 	return 0;
 error_alg:
 	i--;
@@ -405,6 +441,7 @@ static int sun4i_ss_probe(struct platform_device *pdev)
 			break;
 		}
 	}
+	pm_runtime_disable(ss->dev);
 error_enable:
 	sun4i_ss_disable(ss);
 	return err;
@@ -429,6 +466,8 @@ static int sun4i_ss_remove(struct platform_device *pdev)
 		}
 	}
 
+	pm_runtime_disable(ss->dev);
+
 	writel(0, ss->base + SS_CTL);
 	sun4i_ss_disable(ss);
 	return 0;
@@ -445,6 +484,7 @@ static struct platform_driver sun4i_ss_driver = {
 	.remove         = sun4i_ss_remove,
 	.driver         = {
 		.name           = "sun4i-ss",
+		.pm		= &sun4i_ss_pm_ops,
 		.of_match_table	= a20ss_crypto_of_match_table,
 	},
 };
-- 
2.21.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/2] crypto: sun4i-ss: simplify enable/disable of the device
  2019-09-11 11:46 ` [PATCH 1/2] crypto: sun4i-ss: simplify enable/disable of the device Corentin Labbe
@ 2019-09-12  6:32   ` Maxime Ripard
  0 siblings, 0 replies; 6+ messages in thread
From: Maxime Ripard @ 2019-09-12  6:32 UTC (permalink / raw)
  To: Corentin Labbe
  Cc: herbert, linux-sunxi, linux-kernel, Maxime Ripard, Chen-Yu Tsai,
	linux-crypto, davem, linux-arm-kernel

Hi,

Le mer. 11 sept. 2019 à 13:46, Corentin Labbe
<clabbe.montjoie@gmail.com> a écrit :
>
> This patch regroups resource enabling/disabling in dedicated function.
> This simplify error handling and will permit to support power
> management.
>
> Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
> ---
>  drivers/crypto/sunxi-ss/sun4i-ss-core.c | 73 ++++++++++++++-----------
>  1 file changed, 42 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-core.c b/drivers/crypto/sunxi-ss/sun4i-ss-core.c
> index 9aa6fe081a27..2c9ff01dddfc 100644
> --- a/drivers/crypto/sunxi-ss/sun4i-ss-core.c
> +++ b/drivers/crypto/sunxi-ss/sun4i-ss-core.c
> @@ -223,6 +223,41 @@ static struct sun4i_ss_alg_template ss_algs[] = {
>  #endif
>  };
>
> +static void sun4i_ss_disable(struct sun4i_ss_ctx *ss)
> +{
> +       if (ss->reset)
> +               reset_control_assert(ss->reset);
> +       clk_disable_unprepare(ss->ssclk);
> +       clk_disable_unprepare(ss->busclk);
> +}

While you're at it, can you add a new line after the reset_control_assert here?

> +static int sun4i_ss_enable(struct sun4i_ss_ctx *ss)
> +{
> +       int err;
> +
> +       err = clk_prepare_enable(ss->busclk);
> +       if (err) {
> +               dev_err(ss->dev, "Cannot prepare_enable busclk\n");
> +               goto err_enable;
> +       }
> +       err = clk_prepare_enable(ss->ssclk);
> +       if (err) {
> +               dev_err(ss->dev, "Cannot prepare_enable ssclk\n");
> +               goto err_enable;
> +       }
> +       if (ss->reset) {
> +               err = reset_control_deassert(ss->reset);
> +               if (err) {
> +                       dev_err(ss->dev, "Cannot deassert reset control\n");
> +                       goto err_enable;
> +               }
> +       }
> +       return err;

And after each block here?

With that fixed:
Acked-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/2] crypto: sun4i-ss: enable pm_runtime
  2019-09-11 11:46 ` [PATCH 2/2] crypto: sun4i-ss: enable pm_runtime Corentin Labbe
@ 2019-09-12  6:35   ` Maxime Ripard
  2019-09-12  8:49     ` Corentin Labbe
  0 siblings, 1 reply; 6+ messages in thread
From: Maxime Ripard @ 2019-09-12  6:35 UTC (permalink / raw)
  To: Corentin Labbe
  Cc: herbert, linux-sunxi, linux-kernel, Maxime Ripard, Chen-Yu Tsai,
	linux-crypto, davem, linux-arm-kernel

Hi,

Le mer. 11 sept. 2019 à 13:46, Corentin Labbe
<clabbe.montjoie@gmail.com> a écrit :
>
> This patch enables power management on the Security System.
>
> Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
> ---
>  drivers/crypto/sunxi-ss/sun4i-ss-cipher.c |  5 +++
>  drivers/crypto/sunxi-ss/sun4i-ss-core.c   | 42 ++++++++++++++++++++++-
>  2 files changed, 46 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
> index fa4b1b47822e..1fedec9e83b0 100644
> --- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
> +++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
> @@ -10,6 +10,8 @@
>   *
>   * You could find the datasheet in Documentation/arm/sunxi.rst
>   */
> +
> +#include <linux/pm_runtime.h>
>  #include "sun4i-ss.h"
>
>  static int noinline_for_stack sun4i_ss_opti_poll(struct skcipher_request *areq)
> @@ -497,13 +499,16 @@ int sun4i_ss_cipher_init(struct crypto_tfm *tfm)
>                 return PTR_ERR(op->fallback_tfm);
>         }
>
> +       pm_runtime_get_sync(op->ss->dev);
>         return 0;
>  }
>
>  void sun4i_ss_cipher_exit(struct crypto_tfm *tfm)
>  {
>         struct sun4i_tfm_ctx *op = crypto_tfm_ctx(tfm);
> +
>         crypto_free_sync_skcipher(op->fallback_tfm);
> +       pm_runtime_put_sync(op->ss->dev);
>  }
>
>  /* check and set the AES key, prepare the mode to be used */
> diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-core.c b/drivers/crypto/sunxi-ss/sun4i-ss-core.c
> index 2c9ff01dddfc..5e6e1a308f60 100644
> --- a/drivers/crypto/sunxi-ss/sun4i-ss-core.c
> +++ b/drivers/crypto/sunxi-ss/sun4i-ss-core.c
> @@ -14,6 +14,7 @@
>  #include <linux/module.h>
>  #include <linux/of.h>
>  #include <linux/platform_device.h>
> +#include <linux/pm_runtime.h>
>  #include <crypto/scatterwalk.h>
>  #include <linux/scatterlist.h>
>  #include <linux/interrupt.h>
> @@ -258,6 +259,37 @@ static int sun4i_ss_enable(struct sun4i_ss_ctx *ss)
>         return err;
>  }
>
> +#ifdef CONFIG_PM
> +static int sun4i_ss_pm_suspend(struct device *dev)
> +{
> +       struct sun4i_ss_ctx *ss = dev_get_drvdata(dev);
> +
> +       sun4i_ss_disable(ss);
> +       return 0;
> +}
> +
> +static int sun4i_ss_pm_resume(struct device *dev)
> +{
> +       struct sun4i_ss_ctx *ss = dev_get_drvdata(dev);
> +
> +       return sun4i_ss_enable(ss);
> +}
> +#endif
> +
> +const struct dev_pm_ops sun4i_ss_pm_ops = {
> +       SET_RUNTIME_PM_OPS(sun4i_ss_pm_suspend, sun4i_ss_pm_resume, NULL)
> +};
> +
> +static void sun4i_ss_pm_init(struct sun4i_ss_ctx *ss)
> +{
> +       pm_runtime_use_autosuspend(ss->dev);
> +       pm_runtime_set_autosuspend_delay(ss->dev, 1000);
> +
> +       pm_runtime_get_noresume(ss->dev);
> +       pm_runtime_set_active(ss->dev);
> +       pm_runtime_enable(ss->dev);
> +}

It's not really clear to me what you're doing here? Can you explain?

The rest looks fine.

Maxime

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/2] crypto: sun4i-ss: enable pm_runtime
  2019-09-12  6:35   ` Maxime Ripard
@ 2019-09-12  8:49     ` Corentin Labbe
  0 siblings, 0 replies; 6+ messages in thread
From: Corentin Labbe @ 2019-09-12  8:49 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: herbert, linux-sunxi, linux-kernel, Maxime Ripard, Chen-Yu Tsai,
	linux-crypto, davem, linux-arm-kernel

On Thu, Sep 12, 2019 at 08:35:51AM +0200, Maxime Ripard wrote:
> Hi,
> 
> Le mer. 11 sept. 2019 à 13:46, Corentin Labbe
> <clabbe.montjoie@gmail.com> a écrit :
> >
> > This patch enables power management on the Security System.
> >
> > Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
> > ---
> >  drivers/crypto/sunxi-ss/sun4i-ss-cipher.c |  5 +++
> >  drivers/crypto/sunxi-ss/sun4i-ss-core.c   | 42 ++++++++++++++++++++++-
> >  2 files changed, 46 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
> > index fa4b1b47822e..1fedec9e83b0 100644
> > --- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
> > +++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
> > @@ -10,6 +10,8 @@
> >   *
> >   * You could find the datasheet in Documentation/arm/sunxi.rst
> >   */
> > +
> > +#include <linux/pm_runtime.h>
> >  #include "sun4i-ss.h"
> >
> >  static int noinline_for_stack sun4i_ss_opti_poll(struct skcipher_request *areq)
> > @@ -497,13 +499,16 @@ int sun4i_ss_cipher_init(struct crypto_tfm *tfm)
> >                 return PTR_ERR(op->fallback_tfm);
> >         }
> >
> > +       pm_runtime_get_sync(op->ss->dev);
> >         return 0;
> >  }
> >
> >  void sun4i_ss_cipher_exit(struct crypto_tfm *tfm)
> >  {
> >         struct sun4i_tfm_ctx *op = crypto_tfm_ctx(tfm);
> > +
> >         crypto_free_sync_skcipher(op->fallback_tfm);
> > +       pm_runtime_put_sync(op->ss->dev);
> >  }
> >
> >  /* check and set the AES key, prepare the mode to be used */
> > diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-core.c b/drivers/crypto/sunxi-ss/sun4i-ss-core.c
> > index 2c9ff01dddfc..5e6e1a308f60 100644
> > --- a/drivers/crypto/sunxi-ss/sun4i-ss-core.c
> > +++ b/drivers/crypto/sunxi-ss/sun4i-ss-core.c
> > @@ -14,6 +14,7 @@
> >  #include <linux/module.h>
> >  #include <linux/of.h>
> >  #include <linux/platform_device.h>
> > +#include <linux/pm_runtime.h>
> >  #include <crypto/scatterwalk.h>
> >  #include <linux/scatterlist.h>
> >  #include <linux/interrupt.h>
> > @@ -258,6 +259,37 @@ static int sun4i_ss_enable(struct sun4i_ss_ctx *ss)
> >         return err;
> >  }
> >
> > +#ifdef CONFIG_PM
> > +static int sun4i_ss_pm_suspend(struct device *dev)
> > +{
> > +       struct sun4i_ss_ctx *ss = dev_get_drvdata(dev);
> > +
> > +       sun4i_ss_disable(ss);
> > +       return 0;
> > +}
> > +
> > +static int sun4i_ss_pm_resume(struct device *dev)
> > +{
> > +       struct sun4i_ss_ctx *ss = dev_get_drvdata(dev);
> > +
> > +       return sun4i_ss_enable(ss);
> > +}
> > +#endif
> > +
> > +const struct dev_pm_ops sun4i_ss_pm_ops = {
> > +       SET_RUNTIME_PM_OPS(sun4i_ss_pm_suspend, sun4i_ss_pm_resume, NULL)
> > +};
> > +
> > +static void sun4i_ss_pm_init(struct sun4i_ss_ctx *ss)
> > +{
> > +       pm_runtime_use_autosuspend(ss->dev);
> > +       pm_runtime_set_autosuspend_delay(ss->dev, 1000);
> > +
> > +       pm_runtime_get_noresume(ss->dev);
> > +       pm_runtime_set_active(ss->dev);
> > +       pm_runtime_enable(ss->dev);
> > +}
> 
> It's not really clear to me what you're doing here? Can you explain?
> 

I set the autosuspend state and delay.

I say that the device is active and so I "get" it.
Then I enable PM.

I do like that since I use the device later in probe(), so I need to keep it up.
At the end of probe() I put the device which go in suspend automaticaly after.

Regards

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-11 11:46 [PATCH 0/2] crypto: sun4i-ss: Enable power management Corentin Labbe
2019-09-11 11:46 ` [PATCH 1/2] crypto: sun4i-ss: simplify enable/disable of the device Corentin Labbe
2019-09-12  6:32   ` Maxime Ripard
2019-09-11 11:46 ` [PATCH 2/2] crypto: sun4i-ss: enable pm_runtime Corentin Labbe
2019-09-12  6:35   ` Maxime Ripard
2019-09-12  8:49     ` Corentin Labbe

Linux-ARM-Kernel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \
		linux-arm-kernel@lists.infradead.org infradead-linux-arm-kernel@archiver.kernel.org
	public-inbox-index linux-arm-kernel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox