linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwrng: mediatek - Force runtime pm ops for sleep ops
@ 2021-09-30 19:12 Markus Schneider-Pargmann
  2021-09-30 19:40 ` Markus Schneider-Pargmann
  2021-10-08 12:24 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Markus Schneider-Pargmann @ 2021-09-30 19:12 UTC (permalink / raw)
  To: Sean Wang, Herbert Xu, Matt Mackall
  Cc: linux-mediatek, linux-crypto, linux-arm-kernel,
	Markus Schneider-Pargmann

Currently mtk_rng_runtime_suspend/resume is called for both runtime pm
and system sleep operations.

This is wrong as these should only be runtime ops as the name already
suggests. Currently freezing the system will lead to a call to
mtk_rng_runtime_suspend even if the device currently isn't active. This
leads to a clock warning because it is disabled/unprepared although it
isn't enabled/prepared currently.

This patch fixes this by only setting the runtime pm ops and forces to
call the runtime pm ops from the system sleep ops as well if active but
not otherwise.

Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
---
 drivers/char/hw_random/mtk-rng.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/char/hw_random/mtk-rng.c b/drivers/char/hw_random/mtk-rng.c
index 8ad7b515a51b..6c00ea008555 100644
--- a/drivers/char/hw_random/mtk-rng.c
+++ b/drivers/char/hw_random/mtk-rng.c
@@ -166,8 +166,13 @@ static int mtk_rng_runtime_resume(struct device *dev)
 	return mtk_rng_init(&priv->rng);
 }
 
-static UNIVERSAL_DEV_PM_OPS(mtk_rng_pm_ops, mtk_rng_runtime_suspend,
-			    mtk_rng_runtime_resume, NULL);
+static const struct dev_pm_ops mtk_rng_pm_ops = {
+	SET_RUNTIME_PM_OPS(mtk_rng_runtime_suspend,
+			   mtk_rng_runtime_resume, NULL)
+	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
+				pm_runtime_force_resume)
+};
+
 #define MTK_RNG_PM_OPS (&mtk_rng_pm_ops)
 #else	/* CONFIG_PM */
 #define MTK_RNG_PM_OPS NULL
-- 
2.33.0


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

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

* Re: [PATCH] hwrng: mediatek - Force runtime pm ops for sleep ops
  2021-09-30 19:12 [PATCH] hwrng: mediatek - Force runtime pm ops for sleep ops Markus Schneider-Pargmann
@ 2021-09-30 19:40 ` Markus Schneider-Pargmann
  2021-10-08 12:24 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Schneider-Pargmann @ 2021-09-30 19:40 UTC (permalink / raw)
  To: Sean Wang, Herbert Xu, Matt Mackall
  Cc: linux-mediatek, linux-crypto, linux-arm-kernel

Hi,

On Thu, Sep 30, 2021 at 09:12:42PM +0200, Markus Schneider-Pargmann wrote:
> Currently mtk_rng_runtime_suspend/resume is called for both runtime pm
> and system sleep operations.
> 
> This is wrong as these should only be runtime ops as the name already
> suggests. Currently freezing the system will lead to a call to
> mtk_rng_runtime_suspend even if the device currently isn't active. This
> leads to a clock warning because it is disabled/unprepared although it
> isn't enabled/prepared currently.
> 
> This patch fixes this by only setting the runtime pm ops and forces to
> call the runtime pm ops from the system sleep ops as well if active but
> not otherwise.
> 
> Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>

Fixes: 81d2b34508c6 (hwrng: mtk - add runtime PM support)

Sorry, forgot to add this line in the commit message. I can add it for
the next version.

Best,
Markus

> ---
>  drivers/char/hw_random/mtk-rng.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/char/hw_random/mtk-rng.c b/drivers/char/hw_random/mtk-rng.c
> index 8ad7b515a51b..6c00ea008555 100644
> --- a/drivers/char/hw_random/mtk-rng.c
> +++ b/drivers/char/hw_random/mtk-rng.c
> @@ -166,8 +166,13 @@ static int mtk_rng_runtime_resume(struct device *dev)
>  	return mtk_rng_init(&priv->rng);
>  }
>  
> -static UNIVERSAL_DEV_PM_OPS(mtk_rng_pm_ops, mtk_rng_runtime_suspend,
> -			    mtk_rng_runtime_resume, NULL);
> +static const struct dev_pm_ops mtk_rng_pm_ops = {
> +	SET_RUNTIME_PM_OPS(mtk_rng_runtime_suspend,
> +			   mtk_rng_runtime_resume, NULL)
> +	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
> +				pm_runtime_force_resume)
> +};
> +
>  #define MTK_RNG_PM_OPS (&mtk_rng_pm_ops)
>  #else	/* CONFIG_PM */
>  #define MTK_RNG_PM_OPS NULL
> -- 
> 2.33.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] 3+ messages in thread

* Re: [PATCH] hwrng: mediatek - Force runtime pm ops for sleep ops
  2021-09-30 19:12 [PATCH] hwrng: mediatek - Force runtime pm ops for sleep ops Markus Schneider-Pargmann
  2021-09-30 19:40 ` Markus Schneider-Pargmann
@ 2021-10-08 12:24 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2021-10-08 12:24 UTC (permalink / raw)
  To: Markus Schneider-Pargmann
  Cc: Sean Wang, Matt Mackall, linux-mediatek, linux-crypto, linux-arm-kernel

On Thu, Sep 30, 2021 at 09:12:42PM +0200, Markus Schneider-Pargmann wrote:
> Currently mtk_rng_runtime_suspend/resume is called for both runtime pm
> and system sleep operations.
> 
> This is wrong as these should only be runtime ops as the name already
> suggests. Currently freezing the system will lead to a call to
> mtk_rng_runtime_suspend even if the device currently isn't active. This
> leads to a clock warning because it is disabled/unprepared although it
> isn't enabled/prepared currently.
> 
> This patch fixes this by only setting the runtime pm ops and forces to
> call the runtime pm ops from the system sleep ops as well if active but
> not otherwise.
> 
> Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
> ---
>  drivers/char/hw_random/mtk-rng.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)

Patch 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

_______________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2021-10-08 12:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30 19:12 [PATCH] hwrng: mediatek - Force runtime pm ops for sleep ops Markus Schneider-Pargmann
2021-09-30 19:40 ` Markus Schneider-Pargmann
2021-10-08 12:24 ` 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).