linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] crypto: sun8i-ce: undo runtime PM changes during driver removal
@ 2025-05-01 19:06 Ovidiu Panait
  2025-05-01 19:06 ` [PATCH 2/2] crypto: sun8i-ce-hash - use pm_runtime_resume_and_get() Ovidiu Panait
  2025-05-05 12:28 ` [PATCH 1/2] crypto: sun8i-ce: undo runtime PM changes during driver removal Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Ovidiu Panait @ 2025-05-01 19:06 UTC (permalink / raw)
  To: clabbe.montjoie, herbert, davem, linux-crypto
  Cc: wens, jernej.skrabec, samuel, linux-arm-kernel, linux-sunxi,
	linux-kernel, Ovidiu Panait

The pm_runtime_use_autosuspend() call must be undone with
pm_runtime_dont_use_autosuspend() at driver exit, but this is not
currently handled in the driver.

To fix this issue and at the same time simplify error handling, switch
to devm_pm_runtime_enable(). It will call both pm_runtime_disable() and
pm_runtime_dont_use_autosuspend() during driver removal.

Fixes: 06f751b61329 ("crypto: allwinner - Add sun8i-ce Crypto Engine")
Signed-off-by: Ovidiu Panait <ovidiu.panait.oss@gmail.com>
---
 .../crypto/allwinner/sun8i-ce/sun8i-ce-core.c   | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c
index ec1ffda9ea32..658f520cee0c 100644
--- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c
+++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c
@@ -832,13 +832,12 @@ static int sun8i_ce_pm_init(struct sun8i_ce_dev *ce)
 	err = pm_runtime_set_suspended(ce->dev);
 	if (err)
 		return err;
-	pm_runtime_enable(ce->dev);
-	return err;
-}
 
-static void sun8i_ce_pm_exit(struct sun8i_ce_dev *ce)
-{
-	pm_runtime_disable(ce->dev);
+	err = devm_pm_runtime_enable(ce->dev);
+	if (err)
+		return err;
+
+	return 0;
 }
 
 static int sun8i_ce_get_clks(struct sun8i_ce_dev *ce)
@@ -1041,7 +1040,7 @@ static int sun8i_ce_probe(struct platform_device *pdev)
 			       "sun8i-ce-ns", ce);
 	if (err) {
 		dev_err(ce->dev, "Cannot request CryptoEngine Non-secure IRQ (err=%d)\n", err);
-		goto error_irq;
+		goto error_pm;
 	}
 
 	err = sun8i_ce_register_algs(ce);
@@ -1082,8 +1081,6 @@ static int sun8i_ce_probe(struct platform_device *pdev)
 	return 0;
 error_alg:
 	sun8i_ce_unregister_algs(ce);
-error_irq:
-	sun8i_ce_pm_exit(ce);
 error_pm:
 	sun8i_ce_free_chanlist(ce, MAXFLOW - 1);
 	return err;
@@ -1104,8 +1101,6 @@ static void sun8i_ce_remove(struct platform_device *pdev)
 #endif
 
 	sun8i_ce_free_chanlist(ce, MAXFLOW - 1);
-
-	sun8i_ce_pm_exit(ce);
 }
 
 static const struct of_device_id sun8i_ce_crypto_of_match_table[] = {
-- 
2.48.1



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

* [PATCH 2/2] crypto: sun8i-ce-hash - use pm_runtime_resume_and_get()
  2025-05-01 19:06 [PATCH 1/2] crypto: sun8i-ce: undo runtime PM changes during driver removal Ovidiu Panait
@ 2025-05-01 19:06 ` Ovidiu Panait
  2025-05-05 12:28 ` [PATCH 1/2] crypto: sun8i-ce: undo runtime PM changes during driver removal Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Ovidiu Panait @ 2025-05-01 19:06 UTC (permalink / raw)
  To: clabbe.montjoie, herbert, davem, linux-crypto
  Cc: wens, jernej.skrabec, samuel, linux-arm-kernel, linux-sunxi,
	linux-kernel, Ovidiu Panait

Replace pm_runtime_get_sync() usage with pm_runtime_resume_and_get() to
simplify error handling.

This is recommended in the documentation of pm_runtime_get_sync().

Signed-off-by: Ovidiu Panait <ovidiu.panait.oss@gmail.com>
---
 drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c
index ba13fb75c05d..bef44f350167 100644
--- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c
+++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c
@@ -65,12 +65,11 @@ int sun8i_ce_hash_init_tfm(struct crypto_ahash *tfm)
 		       crypto_ahash_driver_name(op->fallback_tfm),
 		       CRYPTO_MAX_ALG_NAME);
 
-	err = pm_runtime_get_sync(op->ce->dev);
+	err = pm_runtime_resume_and_get(op->ce->dev);
 	if (err < 0)
 		goto error_pm;
 	return 0;
 error_pm:
-	pm_runtime_put_noidle(op->ce->dev);
 	crypto_free_ahash(op->fallback_tfm);
 	return err;
 }
-- 
2.48.1



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

* Re: [PATCH 1/2] crypto: sun8i-ce: undo runtime PM changes during driver removal
  2025-05-01 19:06 [PATCH 1/2] crypto: sun8i-ce: undo runtime PM changes during driver removal Ovidiu Panait
  2025-05-01 19:06 ` [PATCH 2/2] crypto: sun8i-ce-hash - use pm_runtime_resume_and_get() Ovidiu Panait
@ 2025-05-05 12:28 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2025-05-05 12:28 UTC (permalink / raw)
  To: Ovidiu Panait
  Cc: clabbe.montjoie, davem, linux-crypto, wens, jernej.skrabec,
	samuel, linux-arm-kernel, linux-sunxi, linux-kernel

On Thu, May 01, 2025 at 10:06:50PM +0300, Ovidiu Panait wrote:
> The pm_runtime_use_autosuspend() call must be undone with
> pm_runtime_dont_use_autosuspend() at driver exit, but this is not
> currently handled in the driver.
> 
> To fix this issue and at the same time simplify error handling, switch
> to devm_pm_runtime_enable(). It will call both pm_runtime_disable() and
> pm_runtime_dont_use_autosuspend() during driver removal.
> 
> Fixes: 06f751b61329 ("crypto: allwinner - Add sun8i-ce Crypto Engine")
> Signed-off-by: Ovidiu Panait <ovidiu.panait.oss@gmail.com>
> ---
>  .../crypto/allwinner/sun8i-ce/sun8i-ce-core.c   | 17 ++++++-----------
>  1 file changed, 6 insertions(+), 11 deletions(-)

All applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


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

end of thread, other threads:[~2025-05-05 12:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-01 19:06 [PATCH 1/2] crypto: sun8i-ce: undo runtime PM changes during driver removal Ovidiu Panait
2025-05-01 19:06 ` [PATCH 2/2] crypto: sun8i-ce-hash - use pm_runtime_resume_and_get() Ovidiu Panait
2025-05-05 12:28 ` [PATCH 1/2] crypto: sun8i-ce: undo runtime PM changes during driver removal Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).