mbox series

[v4,0/5] hwrng: add support for i.MX6 rngb

Message ID 20200715152604.10407-1-horia.geanta@nxp.com
Headers show
Series hwrng: add support for i.MX6 rngb | expand

Message

Horia Geantă July 15, 2020, 3:25 p.m. UTC
Add support for RNGB found in some i.MX6 SoCs (6SL, 6SLL, 6ULL, 6ULZ),
based on RNGC driver (drivers/char/hw_random/imx-rngc.c).

This driver claims support also for RNGB (besides RNGC),
and is currently used only by i.MX25.

Note:

Several NXP SoC from QorIQ family (P1010, P1023, P4080, P3041, P5020)
also have a RNGB, however it's part of the CAAM
(Cryptograhic Accelerator and Assurance Module) crypto accelerator.
In this case, RNGB is managed in the caam driver
(drivers/crypto/caam/), since it's tightly related to
the caam "job ring" interface, not to mention CAAM internally relying on
RNGB as source of randomness.

On the other hand, the i.MX6 SoCs with RNGB have a DCP
(Data Co-Processor) crypto accelerator and this block and RNGB
are independent.

Changelog:
v4
-remove unneeded compatible strings from the driver
v3
-mention in the DT binding the compatibility with "fsl,imx25-rngb"
-collected Reviewed-by
v2
-update rngb DT binding with compatible strings for i.MX6 SoCs

Horia Geantă (5):
  dt-bindings: rng: add RNGB compatibles for i.MX6 SoCs
  ARM: dts: imx6sl: fix rng node
  ARM: dts: imx6sll: add rng
  ARM: dts: imx6ull: add rng
  hwrng: imx-rngc: enable driver for i.MX6

 Documentation/devicetree/bindings/rng/imx-rng.txt | 3 +++
 arch/arm/boot/dts/imx6sl.dtsi                     | 2 ++
 arch/arm/boot/dts/imx6sll.dtsi                    | 7 +++++++
 arch/arm/boot/dts/imx6ull.dtsi                    | 7 +++++++
 drivers/char/hw_random/Kconfig                    | 2 +-
 5 files changed, 20 insertions(+), 1 deletion(-)

Comments

Herbert Xu July 23, 2020, 7:57 a.m. UTC | #1
On Wed, Jul 15, 2020 at 06:25:59PM +0300, Horia Geantă wrote:
> Add support for RNGB found in some i.MX6 SoCs (6SL, 6SLL, 6ULL, 6ULZ),
> based on RNGC driver (drivers/char/hw_random/imx-rngc.c).
> 
> This driver claims support also for RNGB (besides RNGC),
> and is currently used only by i.MX25.
> 
> Note:
> 
> Several NXP SoC from QorIQ family (P1010, P1023, P4080, P3041, P5020)
> also have a RNGB, however it's part of the CAAM
> (Cryptograhic Accelerator and Assurance Module) crypto accelerator.
> In this case, RNGB is managed in the caam driver
> (drivers/crypto/caam/), since it's tightly related to
> the caam "job ring" interface, not to mention CAAM internally relying on
> RNGB as source of randomness.
> 
> On the other hand, the i.MX6 SoCs with RNGB have a DCP
> (Data Co-Processor) crypto accelerator and this block and RNGB
> are independent.
> 
> Changelog:
> v4
> -remove unneeded compatible strings from the driver
> v3
> -mention in the DT binding the compatibility with "fsl,imx25-rngb"
> -collected Reviewed-by
> v2
> -update rngb DT binding with compatible strings for i.MX6 SoCs
> 
> Horia Geantă (5):
>   dt-bindings: rng: add RNGB compatibles for i.MX6 SoCs
>   ARM: dts: imx6sl: fix rng node
>   ARM: dts: imx6sll: add rng
>   ARM: dts: imx6ull: add rng
>   hwrng: imx-rngc: enable driver for i.MX6
> 
>  Documentation/devicetree/bindings/rng/imx-rng.txt | 3 +++
>  arch/arm/boot/dts/imx6sl.dtsi                     | 2 ++
>  arch/arm/boot/dts/imx6sll.dtsi                    | 7 +++++++
>  arch/arm/boot/dts/imx6ull.dtsi                    | 7 +++++++
>  drivers/char/hw_random/Kconfig                    | 2 +-
>  5 files changed, 20 insertions(+), 1 deletion(-)

Patches 1 and 5 applied.  Thanks.
Shawn Guo Aug. 17, 2020, 8:07 a.m. UTC | #2
On Wed, Jul 15, 2020 at 06:25:59PM +0300, Horia Geantă wrote:
> Add support for RNGB found in some i.MX6 SoCs (6SL, 6SLL, 6ULL, 6ULZ),
> based on RNGC driver (drivers/char/hw_random/imx-rngc.c).
> 
> This driver claims support also for RNGB (besides RNGC),
> and is currently used only by i.MX25.
> 
> Note:
> 
> Several NXP SoC from QorIQ family (P1010, P1023, P4080, P3041, P5020)
> also have a RNGB, however it's part of the CAAM
> (Cryptograhic Accelerator and Assurance Module) crypto accelerator.
> In this case, RNGB is managed in the caam driver
> (drivers/crypto/caam/), since it's tightly related to
> the caam "job ring" interface, not to mention CAAM internally relying on
> RNGB as source of randomness.
> 
> On the other hand, the i.MX6 SoCs with RNGB have a DCP
> (Data Co-Processor) crypto accelerator and this block and RNGB
> are independent.
> 
> Changelog:
> v4
> -remove unneeded compatible strings from the driver
> v3
> -mention in the DT binding the compatibility with "fsl,imx25-rngb"
> -collected Reviewed-by
> v2
> -update rngb DT binding with compatible strings for i.MX6 SoCs
> 
> Horia Geantă (5):
...
>   ARM: dts: imx6sl: fix rng node
>   ARM: dts: imx6sll: add rng
>   ARM: dts: imx6ull: add rng

Applied these 3, thanks.

Shawn
Frieder Schrempf Aug. 17, 2021, 3:39 p.m. UTC | #3
Hi,

On 15.07.20 17:26, Horia Geantă wrote:
> Add node for the RNGB block.
> 
> Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
>  arch/arm/boot/dts/imx6ull.dtsi | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/imx6ull.dtsi b/arch/arm/boot/dts/imx6ull.dtsi
> index fcde7f77ae42..9bf67490ac49 100644
> --- a/arch/arm/boot/dts/imx6ull.dtsi
> +++ b/arch/arm/boot/dts/imx6ull.dtsi
> @@ -68,6 +68,13 @@
>  				clock-names = "dcp";
>  			};
>  
> +			rngb: rng@2284000 {
> +				compatible = "fsl,imx6ull-rngb", "fsl,imx25-rngb";
> +				reg = <0x02284000 0x4000>;
> +				interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
> +				clocks = <&clks IMX6UL_CLK_DUMMY>;
> +			};
> +

My board (imx6ull-kontron-n6411-s.dts) fails to boot since this was added in v5.10-rc1. There is a crash in the RNG probe. Can anyone help?
Below is the interesting part of the boot log from v5.14-rc6.

Thanks
Frieder


[...]
Asymmetric key parser 'x509' registered
io scheduler mq-deadline registered
io scheduler kyber registered
imx_soc_device_init: failed to find fsl,imx6ul-ocotp regmap!
2020000.serial: ttymxc0 at MMIO 0x2020000 (irq = 30, base_baud = 5000000) is a IMX
21e8000.serial: ttymxc1 at MMIO 0x21e8000 (irq = 69, base_baud = 5000000) is a IMX
21ec000.serial: ttymxc2 at MMIO 0x21ec000 (irq = 70, base_baud = 5000000) is a IMX
21f0000.serial: ttymxc3 at MMIO 0x21f0000 (irq = 71, base_baud = 5000000) is a IMX
imx-uart 21f0000.serial: Console IMX rounded baud rate from 114943 to 114900
printk: console [ttymxc3] enabled
8<--- cut here ---
Unhandled fault: external abort on non-linefetch (0x008) at 0xe08d8000
pgd = (ptrval)
[e08d8000] *pgd=81c89811, *pte=02284653, *ppte=02284453
Internal error: : 8 [#1] SMP ARM
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.14.0-rc6-ktn+g807a88195d76 #1
Hardware name: Freescale i.MX6 Ultralite (Device Tree)
PC is at imx_rngc_probe+0xa4/0x30c
LR is at _raw_spin_unlock_irqrestore+0x4c/0x50
pc : [<c06922b4>]    lr : [<c0c7ccd4>]    psr: 60000053
sp : c1ccfe00  ip : 00000001  fp : 00000000
r10: c1cb6240  r9 : c1fdeb40  r8 : 00000000
r7 : c1d98410  r6 : c1d98400  r5 : c1e07b40  r4 : 0000004c
r3 : e08d8000  r2 : 00000000  r1 : e591bac3  r0 : 00000000
Flags: nZCv  IRQs on  FIQs off  Mode SVC_32  ISA ARM  Segment none
Control: 10c5387d  Table: 8000406a  DAC: 00000051
Register r0 information: NULL pointer
Register r1 information: non-paged memory
Register r2 information: NULL pointer
Register r3 information: 0-page vmalloc region starting at 0xe08d8000 allocated at __devm_ioremap+0xa4/0xbc
Register r4 information: non-paged memory
Register r5 information: slab kmalloc-256 start c1e07b00 pointer offset 64 size 256
Register r6 information: slab kmalloc-1k start c1d98400 pointer offset 0 size 1024
Register r7 information: slab kmalloc-1k start c1d98400 pointer offset 16 size 1024
Register r8 information: NULL pointer
Register r9 information: slab kmalloc-64 start c1fdeb40 pointer offset 0 size 64
Register r10 information: slab kmalloc-192 start c1cb6240 pointer offset 0 size 192
Register r11 information: NULL pointer
Register r12 information: non-paged memory
Process swapper/0 (pid: 1, stack limit = 0x(ptrval))
Stack: (0xc1ccfe00 to 0xc1cd0000)
fe00: 00000000 00000000 00000000 9cd54eeb 00000000 c1d98410 c145a4d4 00000000
fe20: c1d98410 c1244854 c1cb6240 c0710fb4 c1d98410 00000000 c145a4d4 00000000
fe40: c1d98410 c070e86c c1d98410 c145a4d4 c145a4d4 c070eadc c1b3b0fc c1b3b100
fe60: c145a4d4 c070eb70 00000000 c1d98410 c145a4d4 c1cce000 00000000 c070ef24
fe80: 00000000 c145a4d4 c070eeb4 c070cb9c c1fdd900 c1cb32b0 c1de0a14 9cd54eeb
fea0: c1cb32e4 c145a4d4 c1fdd900 00000000 c145cdf0 c070db70 c1024488 c122e530
fec0: c145a4d4 c145a4d4 c122e530 c145a4d4 c1308fcc c070fc7c c145a4c0 c122e530
fee0: c145a4d4 c0711470 c1cce000 c122e530 c14c6b80 c0102220 00000000 00000000
ff00: c1cb62e1 c1106d00 000000fc c014cd08 000000a2 c11059b8 c1051d10 c12003e8
ff20: c1cce000 c14c6b80 c1308fcc c11059b8 c14d1000 c1244854 000000fc c01aa110
ff40: 00000000 9cd54eeb c1254540 00000007 c1244874 c11059b8 c14d1000 c1244854
ff60: c1cb6240 c1201200 00000006 00000006 00000000 c12003e8 00000000 000000fc
ff80: 00000000 00000000 c0c71b20 00000000 00000000 00000000 00000000 00000000
ffa0: 00000000 c0c71b30 00000000 c010013c 00000000 00000000 00000000 00000000
ffc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
[<c06922b4>] (imx_rngc_probe) from [<c0710fb4>] (platform_probe+0x58/0xb8)
[<c0710fb4>] (platform_probe) from [<c070e86c>] (really_probe+0x14c/0x33c)
[<c070e86c>] (really_probe) from [<c070eadc>] (__driver_probe_device+0x80/0xe4)
[<c070eadc>] (__driver_probe_device) from [<c070eb70>] (driver_probe_device+0x30/0xd4)
[<c070eb70>] (driver_probe_device) from [<c070ef24>] (__driver_attach+0x70/0xf4)
[<c070ef24>] (__driver_attach) from [<c070cb9c>] (bus_for_each_dev+0x78/0xb8)
[<c070cb9c>] (bus_for_each_dev) from [<c070db70>] (bus_add_driver+0x150/0x1dc)
[<c070db70>] (bus_add_driver) from [<c070fc7c>] (driver_register+0x74/0x108)
[<c070fc7c>] (driver_register) from [<c0711470>] (__platform_driver_probe+0x44/0xdc)
[<c0711470>] (__platform_driver_probe) from [<c0102220>] (do_one_initcall+0x80/0x3a8)
[<c0102220>] (do_one_initcall) from [<c1201200>] (kernel_init_freeable+0x1a0/0x234)
[<c1201200>] (kernel_init_freeable) from [<c0c71b30>] (kernel_init+0x10/0x124)
[<c0c71b30>] (kernel_init) from [<c010013c>] (ret_from_fork+0x14/0x38)
Exception stack(0xc1ccffb0 to 0xc1ccfff8)
ffa0:                                     00000000 00000000 00000000 00000000
ffc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffe0: 00000000 00000000 00000000 00000000 00000013 00000000
Code: ebfe93da e2508000 1a00000f e5953008 (e5939000)
---[ end trace 27e536094eba35b6 ]---
Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---
Frieder Schrempf Aug. 17, 2021, 5:38 p.m. UTC | #4
On 17.08.21 17:39, Frieder Schrempf wrote:
> Hi,
> 
> On 15.07.20 17:26, Horia Geantă wrote:
>> Add node for the RNGB block.
>>
>> Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
>> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
>> ---
>>  arch/arm/boot/dts/imx6ull.dtsi | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/arch/arm/boot/dts/imx6ull.dtsi b/arch/arm/boot/dts/imx6ull.dtsi
>> index fcde7f77ae42..9bf67490ac49 100644
>> --- a/arch/arm/boot/dts/imx6ull.dtsi
>> +++ b/arch/arm/boot/dts/imx6ull.dtsi
>> @@ -68,6 +68,13 @@
>>  				clock-names = "dcp";
>>  			};
>>  
>> +			rngb: rng@2284000 {
>> +				compatible = "fsl,imx6ull-rngb", "fsl,imx25-rngb";
>> +				reg = <0x02284000 0x4000>;
>> +				interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
>> +				clocks = <&clks IMX6UL_CLK_DUMMY>;
>> +			};
>> +
> 
> My board (imx6ull-kontron-n6411-s.dts) fails to boot since this was added in v5.10-rc1. There is a crash in the RNG probe. Can anyone help?
> Below is the interesting part of the boot log from v5.14-rc6.

I just found out, that I was trying to boot on an i.MX6UL when I was assuming the board had an i.MX6ULL. That won't work of course. Sorry for the noise!