linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwrng: iproc-rng200: Implement suspend and resume calls
@ 2023-08-10 19:22 Florian Fainelli
  2023-08-18 10:24 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Fainelli @ 2023-08-10 19:22 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Olivia Mackall, Herbert Xu, Ray Jui,
	Scott Branden, Broadcom internal kernel review list,
	open list:HARDWARE RANDOM NUMBER GENERATOR CORE,
	moderated list:BROADCOM IPROC ARM ARCHITECTURE

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

Chips such as BCM7278 support system wide suspend/resume which will
cause the HWRNG block to lose its state and reset to its power on reset
register values. We need to cleanup and re-initialize the HWRNG for it
to be functional coming out of a system suspend cycle.

Fixes: c3577f6100ca ("hwrng: iproc-rng200 - Add support for BCM7278")
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 drivers/char/hw_random/iproc-rng200.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/char/hw_random/iproc-rng200.c b/drivers/char/hw_random/iproc-rng200.c
index 06bc060534d8..c0df053cbe4b 100644
--- a/drivers/char/hw_random/iproc-rng200.c
+++ b/drivers/char/hw_random/iproc-rng200.c
@@ -182,6 +182,8 @@ static int iproc_rng200_probe(struct platform_device *pdev)
 		return PTR_ERR(priv->base);
 	}
 
+	dev_set_drvdata(dev, priv);
+
 	priv->rng.name = "iproc-rng200";
 	priv->rng.read = iproc_rng200_read;
 	priv->rng.init = iproc_rng200_init;
@@ -199,6 +201,28 @@ static int iproc_rng200_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static int __maybe_unused iproc_rng200_suspend(struct device *dev)
+{
+	struct iproc_rng200_dev *priv = dev_get_drvdata(dev);
+
+	iproc_rng200_cleanup(&priv->rng);
+
+	return 0;
+}
+
+static int __maybe_unused iproc_rng200_resume(struct device *dev)
+{
+	struct iproc_rng200_dev *priv =  dev_get_drvdata(dev);
+
+	iproc_rng200_init(&priv->rng);
+
+	return 0;
+}
+
+static const struct dev_pm_ops iproc_rng200_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(iproc_rng200_suspend, iproc_rng200_resume)
+};
+
 static const struct of_device_id iproc_rng200_of_match[] = {
 	{ .compatible = "brcm,bcm2711-rng200", },
 	{ .compatible = "brcm,bcm7211-rng200", },
@@ -212,6 +236,7 @@ static struct platform_driver iproc_rng200_driver = {
 	.driver = {
 		.name		= "iproc-rng200",
 		.of_match_table = iproc_rng200_of_match,
+		.pm		= &iproc_rng200_pm_ops,
 	},
 	.probe		= iproc_rng200_probe,
 };
-- 
2.34.1


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4221 bytes --]

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

* Re: [PATCH] hwrng: iproc-rng200: Implement suspend and resume calls
  2023-08-10 19:22 [PATCH] hwrng: iproc-rng200: Implement suspend and resume calls Florian Fainelli
@ 2023-08-18 10:24 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2023-08-18 10:24 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: linux-kernel, Olivia Mackall, Ray Jui, Scott Branden,
	Broadcom internal kernel review list,
	open list:HARDWARE RANDOM NUMBER GENERATOR CORE,
	moderated list:BROADCOM IPROC ARM ARCHITECTURE

On Thu, Aug 10, 2023 at 12:22:08PM -0700, Florian Fainelli wrote:
> Chips such as BCM7278 support system wide suspend/resume which will
> cause the HWRNG block to lose its state and reset to its power on reset
> register values. We need to cleanup and re-initialize the HWRNG for it
> to be functional coming out of a system suspend cycle.
> 
> Fixes: c3577f6100ca ("hwrng: iproc-rng200 - Add support for BCM7278")
> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
> ---
>  drivers/char/hw_random/iproc-rng200.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)

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

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

end of thread, other threads:[~2023-08-18 10:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-10 19:22 [PATCH] hwrng: iproc-rng200: Implement suspend and resume calls Florian Fainelli
2023-08-18 10: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).