mbox series

[v3,0/4] Raspberry Pi 4 HWRNG Support

Message ID 20191120031622.88949-1-stephen@brennan.io (mailing list archive)
Headers show
Series Raspberry Pi 4 HWRNG Support | expand

Message

Stephen Brennan Nov. 20, 2019, 3:16 a.m. UTC
This patch series enables support for the HWRNG included on the Raspberry
Pi 4.  It is simply a rebase of Stefan's branch [1]. I went ahead and
tested this out on a Pi 4.  Prior to this patch series, attempting to use
the hwrng gives:

    $ head -c 2 /dev/hwrng
    head: /dev/hwrng: Input/output error

After this series, the same command gives two random bytes.

Changes in v3:
- drop interrupts from bcm2711 rng node
- move bcm283x rng into bcm2835-common.dtsi
- add reviewed-by tag
- separated out patch 3 into two parts

Changes in v2:
- specify the correct size for the region in the dts, refactor bcm283x rng

---

Stefan Wahren (2):
  dt-bindings: rng: add BCM2711 RNG compatible
  hwrng: iproc-rng200: Add support for BCM2711

Stephen Brennan (2):
  ARM: dts: bcm2835: Move rng definition to common location
  ARM: dts: bcm2711: Enable HWRNG support

 .../devicetree/bindings/rng/brcm,iproc-rng200.txt          | 1 +
 arch/arm/boot/dts/bcm2711.dtsi                             | 7 +++----
 arch/arm/boot/dts/bcm2835-common.dtsi                      | 6 ++++++
 arch/arm/boot/dts/bcm283x.dtsi                             | 6 ------
 drivers/char/hw_random/Kconfig                             | 2 +-
 drivers/char/hw_random/iproc-rng200.c                      | 1 +
 6 files changed, 12 insertions(+), 11 deletions(-)

Comments

Stefan Wahren Nov. 20, 2019, 4:16 p.m. UTC | #1
Hi Stephen,

Am 20.11.19 um 04:16 schrieb Stephen Brennan:
> This patch series enables support for the HWRNG included on the Raspberry
> Pi 4.  It is simply a rebase of Stefan's branch [1]. I went ahead and
> tested this out on a Pi 4.  Prior to this patch series, attempting to use
> the hwrng gives:
>
>     $ head -c 2 /dev/hwrng
>     head: /dev/hwrng: Input/output error
>
> After this series, the same command gives two random bytes.

just a note: a more expressive test would be running rngtest (package
rng-tools) on this device.

Regards
Stefan
Nicolas Saenz Julienne Nov. 20, 2019, 7:50 p.m. UTC | #2
On Wed, 2019-11-20 at 17:16 +0100, Stefan Wahren wrote:
> Hi Stephen,
> 
> Am 20.11.19 um 04:16 schrieb Stephen Brennan:
> > This patch series enables support for the HWRNG included on the Raspberry
> > Pi 4.  It is simply a rebase of Stefan's branch [1]. I went ahead and
> > tested this out on a Pi 4.  Prior to this patch series, attempting to use
> > the hwrng gives:
> > 
> >     $ head -c 2 /dev/hwrng
> >     head: /dev/hwrng: Input/output error
> > 
> > After this series, the same command gives two random bytes.
> 
> just a note: a more expressive test would be running rngtest (package
> rng-tools) on this device.

Just had a go at it,

root@rpi4:~# rngtest -c 1000 < /dev/hwrng
rngtest 2-unofficial-mt.14
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: 998
rngtest: FIPS 140-2 failures: 2
rngtest: FIPS 140-2(2001-10-10) Monobit: 0
rngtest: FIPS 140-2(2001-10-10) Poker: 1
rngtest: FIPS 140-2(2001-10-10) Runs: 0
rngtest: FIPS 140-2(2001-10-10) Long run: 1
rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
rngtest: input channel speed: (min=1.284; avg=113.786; max=126.213)Kibits/s
rngtest: FIPS tests speed: (min=17.122; avg=28.268; max=28.812)Mibits/s
rngtest: Program run time: 172323761 microseconds

AFAIR (Arch wiki) some small failures are acceptable.

Regards,
Nicolas
Florian Fainelli Nov. 21, 2019, 4:09 a.m. UTC | #3
Hi Herbert,

On 11/19/2019 7:16 PM, Stephen Brennan wrote:
> This patch series enables support for the HWRNG included on the Raspberry
> Pi 4.  It is simply a rebase of Stefan's branch [1]. I went ahead and
> tested this out on a Pi 4.  Prior to this patch series, attempting to use
> the hwrng gives:
> 
>     $ head -c 2 /dev/hwrng
>     head: /dev/hwrng: Input/output error
> 
> After this series, the same command gives two random bytes.

When we get a review from Rob, you can take patches 1-2 through your
tree and Stefan/Nicholas can queue patches 3-4 through the BCM2835 tree
where the DTS files already exist. Does that work for you?

> 
> Changes in v3:
> - drop interrupts from bcm2711 rng node
> - move bcm283x rng into bcm2835-common.dtsi
> - add reviewed-by tag
> - separated out patch 3 into two parts
> 
> Changes in v2:
> - specify the correct size for the region in the dts, refactor bcm283x rng
> 
> ---
> 
> Stefan Wahren (2):
>   dt-bindings: rng: add BCM2711 RNG compatible
>   hwrng: iproc-rng200: Add support for BCM2711
> 
> Stephen Brennan (2):
>   ARM: dts: bcm2835: Move rng definition to common location
>   ARM: dts: bcm2711: Enable HWRNG support
> 
>  .../devicetree/bindings/rng/brcm,iproc-rng200.txt          | 1 +
>  arch/arm/boot/dts/bcm2711.dtsi                             | 7 +++----
>  arch/arm/boot/dts/bcm2835-common.dtsi                      | 6 ++++++
>  arch/arm/boot/dts/bcm283x.dtsi                             | 6 ------
>  drivers/char/hw_random/Kconfig                             | 2 +-
>  drivers/char/hw_random/iproc-rng200.c                      | 1 +
>  6 files changed, 12 insertions(+), 11 deletions(-)
>
Herbert Xu Nov. 21, 2019, 5:30 a.m. UTC | #4
On Wed, Nov 20, 2019 at 08:09:57PM -0800, Florian Fainelli wrote:
> Hi Herbert,
> 
> On 11/19/2019 7:16 PM, Stephen Brennan wrote:
> > This patch series enables support for the HWRNG included on the Raspberry
> > Pi 4.  It is simply a rebase of Stefan's branch [1]. I went ahead and
> > tested this out on a Pi 4.  Prior to this patch series, attempting to use
> > the hwrng gives:
> > 
> >     $ head -c 2 /dev/hwrng
> >     head: /dev/hwrng: Input/output error
> > 
> > After this series, the same command gives two random bytes.
> 
> When we get a review from Rob, you can take patches 1-2 through your
> tree and Stefan/Nicholas can queue patches 3-4 through the BCM2835 tree
> where the DTS files already exist. Does that work for you?

Yes sure.

Cheers,
Stefan Wahren Nov. 21, 2019, 10:14 a.m. UTC | #5
Hi,

Am 20.11.19 um 20:50 schrieb Nicolas Saenz Julienne:
> On Wed, 2019-11-20 at 17:16 +0100, Stefan Wahren wrote:
>> Hi Stephen,
>>
>> Am 20.11.19 um 04:16 schrieb Stephen Brennan:
>>> This patch series enables support for the HWRNG included on the Raspberry
>>> Pi 4.  It is simply a rebase of Stefan's branch [1]. I went ahead and
>>> tested this out on a Pi 4.  Prior to this patch series, attempting to use
>>> the hwrng gives:
>>>
>>>     $ head -c 2 /dev/hwrng
>>>     head: /dev/hwrng: Input/output error
>>>
>>> After this series, the same command gives two random bytes.
>> just a note: a more expressive test would be running rngtest (package
>> rng-tools) on this device.
> Just had a go at it,
>
> root@rpi4:~# rngtest -c 1000 < /dev/hwrng
> rngtest 2-unofficial-mt.14
> 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: 998
> rngtest: FIPS 140-2 failures: 2
> rngtest: FIPS 140-2(2001-10-10) Monobit: 0
> rngtest: FIPS 140-2(2001-10-10) Poker: 1
> rngtest: FIPS 140-2(2001-10-10) Runs: 0
> rngtest: FIPS 140-2(2001-10-10) Long run: 1
> rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
> rngtest: input channel speed: (min=1.284; avg=113.786; max=126.213)Kibits/s
> rngtest: FIPS tests speed: (min=17.122; avg=28.268; max=28.812)Mibits/s
> rngtest: Program run time: 172323761 microseconds
>
> AFAIR (Arch wiki) some small failures are acceptable.
>
> Regards,
> Nicolas
>
thanks for the results. AFAIR the downstream implementation [1] has a
significant higher input speed. So there is possibly some room for
optimizations later.

Regards
Stefan

[1] -
https://github.com/raspberrypi/linux/commit/5e74aadfd1e0e6c00994521863ba044ce25b40de
Florian Fainelli Dec. 4, 2019, 4:55 a.m. UTC | #6
On 11/20/2019 9:30 PM, Herbert Xu wrote:
> On Wed, Nov 20, 2019 at 08:09:57PM -0800, Florian Fainelli wrote:
>> Hi Herbert,
>>
>> On 11/19/2019 7:16 PM, Stephen Brennan wrote:
>>> This patch series enables support for the HWRNG included on the Raspberry
>>> Pi 4.  It is simply a rebase of Stefan's branch [1]. I went ahead and
>>> tested this out on a Pi 4.  Prior to this patch series, attempting to use
>>> the hwrng gives:
>>>
>>>     $ head -c 2 /dev/hwrng
>>>     head: /dev/hwrng: Input/output error
>>>
>>> After this series, the same command gives two random bytes.
>>
>> When we get a review from Rob, you can take patches 1-2 through your
>> tree and Stefan/Nicholas can queue patches 3-4 through the BCM2835 tree
>> where the DTS files already exist. Does that work for you?
> 
> Yes sure.

Rob has provided his Acked-by for the binding patch, are you targeting
these changes for 5.5 or 5.6 at this point?
Herbert Xu Dec. 4, 2019, 4:59 a.m. UTC | #7
On Tue, Dec 03, 2019 at 08:55:04PM -0800, Florian Fainelli wrote:
>
> Rob has provided his Acked-by for the binding patch, are you targeting
> these changes for 5.5 or 5.6 at this point?

They are too late for 5.5 so it's going to be 5.6.

Cheers,