From: "Álvaro Fernández Rojas" <noltari@gmail.com>
To: mpm@selenic.com, herbert@gondor.apana.org.au,
nsaenzjulienne@suse.de, f.fainelli@gmail.com, rjui@broadcom.com,
sbranden@broadcom.com, bcm-kernel-feedback-list@broadcom.com,
rikard.falkeborn@gmail.com, noltari@gmail.com,
linux-crypto@vger.kernel.org,
linux-rpi-kernel@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, stijn@linux-ipv6.be, ynezz@true.cz
Subject: [PATCH v3] hwrng: bcm2835: set quality
Date: Mon, 22 Feb 2021 20:50:40 +0100 [thread overview]
Message-ID: <20210222195040.16900-1-noltari@gmail.com> (raw)
In-Reply-To: <20210220195748.3153-1-noltari@gmail.com>
This allows devices without a high precission timer to speed up boot from
more than 100s to lest than 30s.
BCM2835 rngtest:
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: 996
rngtest: FIPS 140-2 failures: 4
rngtest: FIPS 140-2(2001-10-10) Monobit: 0
rngtest: FIPS 140-2(2001-10-10) Poker: 0
rngtest: FIPS 140-2(2001-10-10) Runs: 1
rngtest: FIPS 140-2(2001-10-10) Long run: 3
rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
rngtest: input channel speed: (min=146.002; avg=349.394;
max=1302083.333)Kibits/s
rngtest: FIPS tests speed: (min=12.126; avg=22.750; max=23.432)Mibits/s
rngtest: Program run time: 56826982 microseconds
996 successes and 4 failures -> 99.6% success rate
1024 * 99.6% = 1019 (rounded down to 1000)
BCM6368 rngtest:
root@OpenWrt:/# 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: 751
rngtest: FIPS 140-2 failures: 249
rngtest: FIPS 140-2(2001-10-10) Monobit: 0
rngtest: FIPS 140-2(2001-10-10) Poker: 34
rngtest: FIPS 140-2(2001-10-10) Runs: 245
rngtest: FIPS 140-2(2001-10-10) Long run: 0
rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
rngtest: input channel speed: (min=1.202; avg=16.434; max=1003.868)Mibits/s
rngtest: FIPS tests speed: (min=761.155; avg=8343.383; max=15662.590)Kibits/s
rngtest: Program run time: 3539183 microseconds
cat: write error: Broken pipe
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
v3: set different qualities for each SoC
v2: add jusftification
drivers/char/hw_random/bcm2835-rng.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/char/hw_random/bcm2835-rng.c b/drivers/char/hw_random/bcm2835-rng.c
index 1a7c43b43c6b..a6121a04f624 100644
--- a/drivers/char/hw_random/bcm2835-rng.c
+++ b/drivers/char/hw_random/bcm2835-rng.c
@@ -121,6 +121,15 @@ static void bcm2835_rng_cleanup(struct hwrng *rng)
struct bcm2835_rng_of_data {
bool mask_interrupts;
+ unsigned short quality;
+};
+
+static const struct bcm2835_rng_of_data bcm283x_rng_of_data = {
+ .quality = 1000,
+};
+
+static const struct bcm2835_rng_of_data bcm6368_rng_of_data = {
+ .quality = 700,
};
static const struct bcm2835_rng_of_data nsp_rng_of_data = {
@@ -128,10 +137,10 @@ static const struct bcm2835_rng_of_data nsp_rng_of_data = {
};
static const struct of_device_id bcm2835_rng_of_match[] = {
- { .compatible = "brcm,bcm2835-rng"},
+ { .compatible = "brcm,bcm2835-rng", .data = &bcm283x_rng_of_data },
{ .compatible = "brcm,bcm-nsp-rng", .data = &nsp_rng_of_data },
{ .compatible = "brcm,bcm5301x-rng", .data = &nsp_rng_of_data },
- { .compatible = "brcm,bcm6368-rng"},
+ { .compatible = "brcm,bcm6368-rng", .data = &bcm6368_rng_of_data },
{},
};
@@ -171,8 +180,10 @@ static int bcm2835_rng_probe(struct platform_device *pdev)
/* Check for rng init function, execute it */
of_data = rng_id->data;
- if (of_data)
+ if (of_data) {
priv->mask_interrupts = of_data->mask_interrupts;
+ priv->rng.quality = of_data->quality;
+ }
}
/* register driver */
--
2.20.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2021-02-22 19:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-20 17:47 [PATCH] hwrng: bcm2835: set quality to 1000 Álvaro Fernández Rojas
2021-02-20 19:09 ` Andrew Lunn
2021-02-20 19:12 ` Álvaro Fernández Rojas
2021-02-20 19:40 ` Andrew Lunn
2021-03-03 9:20 ` Herbert Xu
2021-03-03 9:29 ` Álvaro Fernández Rojas
2021-03-04 15:11 ` Nicolas Saenz Julienne
2021-03-04 22:28 ` Florian Fainelli
2021-03-05 6:26 ` Álvaro Fernández Rojas
2021-03-12 4:52 ` Florian Fainelli
2021-02-20 19:57 ` [PATCH v2] " Álvaro Fernández Rojas
2021-02-22 19:50 ` Álvaro Fernández Rojas [this message]
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=20210222195040.16900-1-noltari@gmail.com \
--to=noltari@gmail.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=f.fainelli@gmail.com \
--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=mpm@selenic.com \
--cc=nsaenzjulienne@suse.de \
--cc=rikard.falkeborn@gmail.com \
--cc=rjui@broadcom.com \
--cc=sbranden@broadcom.com \
--cc=stijn@linux-ipv6.be \
--cc=ynezz@true.cz \
/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 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).