All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: "Álvaro Fernández Rojas" <noltari@gmail.com>,
	"Matt Mackall" <mpm@selenic.com>,
	"Herbert Xu" <herbert@gondor.apana.org.au>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Nicolas Saenz Julienne" <nsaenzjulienne@suse.de>,
	"Florian Fainelli" <f.fainelli@gmail.com>,
	"Ray Jui" <rjui@broadcom.com>,
	"Scott Branden" <sbranden@broadcom.com>,
	bcm-kernel-feedback-list@broadcom.com,
	"Philipp Zabel" <p.zabel@pengutronix.de>,
	"Mark Brown" <broonie@kernel.org>,
	"Guenter Roeck" <linux@roeck-us.net>,
	"Bjorn Andersson" <bjorn.andersson@linaro.org>,
	"Nícolas F. R. A. Prado" <nfraprado@protonmail.com>,
	"Rikard Falkeborn" <rikard.falkeborn@gmail.com>,
	"Stefan Wahren" <stefan.wahren@i2se.com>,
	linux-crypto@vger.kernel.org, devicetree@vger.kernel.org,
	linux-rpi-kernel@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] hwrng: bcm2835: add reset support
Date: Tue, 23 Feb 2021 12:43:32 -0800	[thread overview]
Message-ID: <0efc029f-dbb1-198c-8a1e-6bc85f5cc6ee@gmail.com> (raw)
In-Reply-To: <20210223170006.29558-3-noltari@gmail.com>



On 2/23/2021 9:00 AM, Álvaro Fernández Rojas wrote:
> BCM6368 devices need to reset the in order to generate true random numbers.
> This is what BCM6368 produces without a reset:
> root@OpenWrt:/# cat /dev/hwrng | rngtest -c 1000
> rngtest 6.10
> Copyright (c) 2004 by Henrique de Moraes Holschuh
> This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> rngtest: starting FIPS tests...
> rngtest: bits received from input: 20000032
> rngtest: FIPS 140-2 successes: 0
> rngtest: FIPS 140-2 failures: 1000
> rngtest: FIPS 140-2(2001-10-10) Monobit: 2
> rngtest: FIPS 140-2(2001-10-10) Poker: 1000
> rngtest: FIPS 140-2(2001-10-10) Runs: 1000
> rngtest: FIPS 140-2(2001-10-10) Long run: 30
> rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
> rngtest: input channel speed: (min=37.253; avg=320.827; max=635.783)Mibits/s
> rngtest: FIPS tests speed: (min=12.141; avg=15.034; max=16.428)Mibits/s
> rngtest: Program run time: 1336176 microseconds
> cat: write error: Broken pipe
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> ---
>  v3: no changes.
>  v2: no changes.
> 
>  drivers/char/hw_random/bcm2835-rng.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/char/hw_random/bcm2835-rng.c b/drivers/char/hw_random/bcm2835-rng.c
> index 1a7c43b43c6b..1b93a896d8e8 100644
> --- a/drivers/char/hw_random/bcm2835-rng.c
> +++ b/drivers/char/hw_random/bcm2835-rng.c
> @@ -13,6 +13,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/printk.h>
>  #include <linux/clk.h>
> +#include <linux/reset.h>
>  
>  #define RNG_CTRL	0x0
>  #define RNG_STATUS	0x4
> @@ -32,6 +33,7 @@ struct bcm2835_rng_priv {
>  	void __iomem *base;
>  	bool mask_interrupts;
>  	struct clk *clk;
> +	struct reset_control *reset;
>  };
>  
>  static inline struct bcm2835_rng_priv *to_rng_priv(struct hwrng *rng)
> @@ -94,6 +96,10 @@ static int bcm2835_rng_init(struct hwrng *rng)
>  			return ret;
>  	}
>  
> +	ret = reset_control_reset(priv->reset);
> +	if (ret)
> +		return ret;

For symmetry, the remove path should call reset_control_rearm(),
assuming that .reset() is what you want and not .deassert()/assert().
-- 
Florian

WARNING: multiple messages have this Message-ID (diff)
From: Florian Fainelli <f.fainelli@gmail.com>
To: "Álvaro Fernández Rojas" <noltari@gmail.com>,
	"Matt Mackall" <mpm@selenic.com>,
	"Herbert Xu" <herbert@gondor.apana.org.au>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Nicolas Saenz Julienne" <nsaenzjulienne@suse.de>,
	"Florian Fainelli" <f.fainelli@gmail.com>,
	"Ray Jui" <rjui@broadcom.com>,
	"Scott Branden" <sbranden@broadcom.com>,
	bcm-kernel-feedback-list@broadcom.com,
	"Philipp Zabel" <p.zabel@pengutronix.de>,
	"Mark Brown" <broonie@kernel.org>,
	"Guenter Roeck" <linux@roeck-us.net>,
	"Bjorn Andersson" <bjorn.andersson@linaro.org>,
	"Nícolas F. R. A. Prado" <nfraprado@protonmail.com>,
	"Rikard Falkeborn" <rikard.falkeborn@gmail.com>,
	"Stefan Wahren" <stefan.wahren@i2se.com>,
	linux-crypto@vger.kernel.org, devicetree@vger.kernel.org,
	linux-rpi-kernel@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] hwrng: bcm2835: add reset support
Date: Tue, 23 Feb 2021 12:43:32 -0800	[thread overview]
Message-ID: <0efc029f-dbb1-198c-8a1e-6bc85f5cc6ee@gmail.com> (raw)
In-Reply-To: <20210223170006.29558-3-noltari@gmail.com>



On 2/23/2021 9:00 AM, Álvaro Fernández Rojas wrote:
> BCM6368 devices need to reset the in order to generate true random numbers.
> This is what BCM6368 produces without a reset:
> root@OpenWrt:/# cat /dev/hwrng | rngtest -c 1000
> rngtest 6.10
> Copyright (c) 2004 by Henrique de Moraes Holschuh
> This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> rngtest: starting FIPS tests...
> rngtest: bits received from input: 20000032
> rngtest: FIPS 140-2 successes: 0
> rngtest: FIPS 140-2 failures: 1000
> rngtest: FIPS 140-2(2001-10-10) Monobit: 2
> rngtest: FIPS 140-2(2001-10-10) Poker: 1000
> rngtest: FIPS 140-2(2001-10-10) Runs: 1000
> rngtest: FIPS 140-2(2001-10-10) Long run: 30
> rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
> rngtest: input channel speed: (min=37.253; avg=320.827; max=635.783)Mibits/s
> rngtest: FIPS tests speed: (min=12.141; avg=15.034; max=16.428)Mibits/s
> rngtest: Program run time: 1336176 microseconds
> cat: write error: Broken pipe
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> ---
>  v3: no changes.
>  v2: no changes.
> 
>  drivers/char/hw_random/bcm2835-rng.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/char/hw_random/bcm2835-rng.c b/drivers/char/hw_random/bcm2835-rng.c
> index 1a7c43b43c6b..1b93a896d8e8 100644
> --- a/drivers/char/hw_random/bcm2835-rng.c
> +++ b/drivers/char/hw_random/bcm2835-rng.c
> @@ -13,6 +13,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/printk.h>
>  #include <linux/clk.h>
> +#include <linux/reset.h>
>  
>  #define RNG_CTRL	0x0
>  #define RNG_STATUS	0x4
> @@ -32,6 +33,7 @@ struct bcm2835_rng_priv {
>  	void __iomem *base;
>  	bool mask_interrupts;
>  	struct clk *clk;
> +	struct reset_control *reset;
>  };
>  
>  static inline struct bcm2835_rng_priv *to_rng_priv(struct hwrng *rng)
> @@ -94,6 +96,10 @@ static int bcm2835_rng_init(struct hwrng *rng)
>  			return ret;
>  	}
>  
> +	ret = reset_control_reset(priv->reset);
> +	if (ret)
> +		return ret;

For symmetry, the remove path should call reset_control_rearm(),
assuming that .reset() is what you want and not .deassert()/assert().
-- 
Florian

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

  reply	other threads:[~2021-02-23 20:44 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-22 19:45 [PATCH] hwrng: bcm2835: add reset support Álvaro Fernández Rojas
2021-02-22 19:45 ` Álvaro Fernández Rojas
2021-02-23 16:01 ` [PATCH 0/2] " Álvaro Fernández Rojas
2021-02-23 16:01   ` Álvaro Fernández Rojas
2021-02-23 16:01   ` [PATCH 1/2] dt-bindings: rng: bcm2835: document " Álvaro Fernández Rojas
2021-02-23 16:01     ` Álvaro Fernández Rojas
2021-02-23 16:36     ` Florian Fainelli
2021-02-23 16:36       ` Florian Fainelli
2021-02-23 17:17       ` Scott Branden
2021-02-23 17:17         ` Scott Branden
2021-02-23 17:22         ` Álvaro Fernández Rojas
2021-02-23 17:22           ` Álvaro Fernández Rojas
2021-02-23 16:01   ` [PATCH 2/2] hwrng: bcm2835: add " Álvaro Fernández Rojas
2021-02-23 16:01     ` Álvaro Fernández Rojas
2021-02-24  8:22   ` [PATCH v4 0/2] " Álvaro Fernández Rojas
2021-02-24  8:22     ` Álvaro Fernández Rojas
2021-02-24  8:22     ` [PATCH v4 1/2] dt-bindings: rng: bcm2835: document " Álvaro Fernández Rojas
2021-02-24  8:22       ` Álvaro Fernández Rojas
2021-02-24  8:22     ` [PATCH v4 2/2] hwrng: bcm2835: add " Álvaro Fernández Rojas
2021-02-24  8:22       ` Álvaro Fernández Rojas
2021-03-03 13:52       ` Philipp Zabel
2021-03-03 13:52         ` Philipp Zabel
2021-03-03 14:06         ` Álvaro Fernández Rojas
2021-03-03 14:06           ` Álvaro Fernández Rojas
2021-03-03 19:16           ` Florian Fainelli
2021-03-03 19:16             ` Florian Fainelli
2021-02-23 17:00 ` [PATCH v3 0/2] " Álvaro Fernández Rojas
2021-02-23 17:00   ` Álvaro Fernández Rojas
2021-02-23 17:00   ` [PATCH v3 1/2] dt-bindings: rng: bcm2835: document " Álvaro Fernández Rojas
2021-02-23 17:00     ` Álvaro Fernández Rojas
2021-02-23 19:34     ` Rob Herring
2021-02-23 19:34       ` Rob Herring
2021-02-23 20:48       ` Álvaro Fernández Rojas
2021-02-23 20:48         ` Álvaro Fernández Rojas
2021-03-04 12:07     ` Nicolas Saenz Julienne
2021-03-04 12:07       ` Nicolas Saenz Julienne
2021-03-04 12:18       ` Álvaro Fernández Rojas
2021-03-04 12:18         ` Álvaro Fernández Rojas
2021-03-04 13:30         ` Nicolas Saenz Julienne
2021-03-04 13:30           ` Nicolas Saenz Julienne
2021-03-04 14:57           ` Álvaro Fernández Rojas
2021-03-04 14:57             ` Álvaro Fernández Rojas
2021-03-04 19:58       ` Rob Herring
2021-03-04 19:58         ` Rob Herring
2021-02-23 17:00   ` [PATCH v3 2/2] hwrng: bcm2835: add " Álvaro Fernández Rojas
2021-02-23 17:00     ` Álvaro Fernández Rojas
2021-02-23 20:43     ` Florian Fainelli [this message]
2021-02-23 20:43       ` Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0efc029f-dbb1-198c-8a1e-6bc85f5cc6ee@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=linux@roeck-us.net \
    --cc=mpm@selenic.com \
    --cc=nfraprado@protonmail.com \
    --cc=noltari@gmail.com \
    --cc=nsaenzjulienne@suse.de \
    --cc=p.zabel@pengutronix.de \
    --cc=rikard.falkeborn@gmail.com \
    --cc=rjui@broadcom.com \
    --cc=robh+dt@kernel.org \
    --cc=sbranden@broadcom.com \
    --cc=stefan.wahren@i2se.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.