2023-06-12 08:35:39

by Meenakshi Aggarwal

[permalink] [raw]
Subject: [PATCH] crypto: caam - adjust RNG timing to support more devices

From: Victoria Milhoan <[email protected]>

Adjust RNG timing parameters to support more i.MX6 devices.

Signed-off-by: Victoria Milhoan <[email protected]>
Signed-off-by: Dan Douglass <[email protected]>
Signed-off-by: Vipul Kumar <[email protected]>
Signed-off-by: Horia Geantă <[email protected]>
---
drivers/crypto/caam/ctrl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
index 5fed3cf354c0..62dd069942e4 100644
--- a/drivers/crypto/caam/ctrl.c
+++ b/drivers/crypto/caam/ctrl.c
@@ -383,8 +383,8 @@ static void kick_trng(struct device *dev, int ent_delay)
wr_reg32(&r4tst->rtsdctl, val);
/* min. freq. count, equal to 1/4 of the entropy sample length */
wr_reg32(&r4tst->rtfrqmin, ent_delay >> 2);
- /* disable maximum frequency count */
- wr_reg32(&r4tst->rtfrqmax, RTFRQMAX_DISABLE);
+ /* max. freq. count, equal to 16 times the entropy sample length */
+ wr_reg32(&r4tst->rtfrqmax, ent_delay << 4);
/* read the control register */
val = rd_reg32(&r4tst->rtmctl);
start_rng:
--
2.25.1



2023-06-15 12:16:53

by Gaurav Jain

[permalink] [raw]
Subject: RE: [PATCH] crypto: caam - adjust RNG timing to support more devices

Reviewed-by: Gaurav Jain <[email protected]>

> -----Original Message-----
> From: Meenakshi Aggarwal <[email protected]>
> Sent: Monday, June 12, 2023 1:56 PM
> To: Horia Geanta <[email protected]>; Varun Sethi <[email protected]>;
> Pankaj Gupta <[email protected]>; Gaurav Jain <[email protected]>;
> [email protected]; [email protected]; linux-
> [email protected]; [email protected]
> Cc: Victoria Milhoan <[email protected]>; Dan Douglass
> <[email protected]>; Vipul Kumar <[email protected]>
> Subject: [PATCH] crypto: caam - adjust RNG timing to support more devices
>
> From: Victoria Milhoan <[email protected]>
>
> Adjust RNG timing parameters to support more i.MX6 devices.
>
> Signed-off-by: Victoria Milhoan <[email protected]>
> Signed-off-by: Dan Douglass <[email protected]>
> Signed-off-by: Vipul Kumar <[email protected]>
> Signed-off-by: Horia Geantă <[email protected]>
> ---
> drivers/crypto/caam/ctrl.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index
> 5fed3cf354c0..62dd069942e4 100644
> --- a/drivers/crypto/caam/ctrl.c
> +++ b/drivers/crypto/caam/ctrl.c
> @@ -383,8 +383,8 @@ static void kick_trng(struct device *dev, int ent_delay)
> wr_reg32(&r4tst->rtsdctl, val);
> /* min. freq. count, equal to 1/4 of the entropy sample length */
> wr_reg32(&r4tst->rtfrqmin, ent_delay >> 2);
> - /* disable maximum frequency count */
> - wr_reg32(&r4tst->rtfrqmax, RTFRQMAX_DISABLE);
> + /* max. freq. count, equal to 16 times the entropy sample length */
> + wr_reg32(&r4tst->rtfrqmax, ent_delay << 4);
> /* read the control register */
> val = rd_reg32(&r4tst->rtmctl);
> start_rng:
> --
> 2.25.1

2023-06-23 08:24:54

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: caam - adjust RNG timing to support more devices

On Mon, Jun 12, 2023 at 10:26:15AM +0200, [email protected] wrote:
> From: Victoria Milhoan <[email protected]>
>
> Adjust RNG timing parameters to support more i.MX6 devices.
>
> Signed-off-by: Victoria Milhoan <[email protected]>
> Signed-off-by: Dan Douglass <[email protected]>
> Signed-off-by: Vipul Kumar <[email protected]>
> Signed-off-by: Horia Geantă <[email protected]>
> ---
> drivers/crypto/caam/ctrl.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

Patch applied. Thanks.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2023-07-17 12:53:39

by Bastian Krause

[permalink] [raw]
Subject: Re: [PATCH] crypto: caam - adjust RNG timing to support more devices

On 6/12/23 10:26, [email protected] wrote:
> From: Victoria Milhoan <[email protected]>
>
> Adjust RNG timing parameters to support more i.MX6 devices.
>
> Signed-off-by: Victoria Milhoan <[email protected]>
> Signed-off-by: Dan Douglass <[email protected]>
> Signed-off-by: Vipul Kumar <[email protected]>
> Signed-off-by: Horia Geantă <[email protected]>
> ---
> drivers/crypto/caam/ctrl.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

This patch seems to breaks CAAM RNG instantiation on an i.MX8MM at my end:

caam 30900000.crypto: Entropy delay = 3200
caam 30900000.crypto: Entropy delay = 3600
[...]
caam 30900000.crypto: Entropy delay = 12400
caam 30900000.crypto: failed to instantiate RNG
caam: probe of 30900000.crypto failed with error -11

If I revert this patch or increase RTSDCTL_ENT_DLY_MAX to a value >
66800, it works again:

caam 30900000.crypto: Entropy delay = 32800
caam 30900000.crypto: Entropy delay = 33200
[...]
caam 30900000.crypto: Entropy delay = 66800
caam 30900000.crypto: Instantiated RNG4 SH0
caam 30900000.crypto: Instantiated RNG4 SH1
caam 30900000.crypto: device ID = 0x0a16040100000000 (Era 9)
caam 30900000.crypto: job rings = 2, qi = 0
caam algorithms registered in /proc/crypto
caam 30900000.crypto: caam pkc algorithms registered in /proc/crypto
caam 30900000.crypto: registering rng-caam
Executing RNG SELF-TEST with wait
random: crng init done
caam 30900000.crypto: rng crypto API alg registered prng-caam

Regards,
Bastian

>
> diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
> index 5fed3cf354c0..62dd069942e4 100644
> --- a/drivers/crypto/caam/ctrl.c
> +++ b/drivers/crypto/caam/ctrl.c
> @@ -383,8 +383,8 @@ static void kick_trng(struct device *dev, int ent_delay)
> wr_reg32(&r4tst->rtsdctl, val);
> /* min. freq. count, equal to 1/4 of the entropy sample length */
> wr_reg32(&r4tst->rtfrqmin, ent_delay >> 2);
> - /* disable maximum frequency count */
> - wr_reg32(&r4tst->rtfrqmax, RTFRQMAX_DISABLE);
> + /* max. freq. count, equal to 16 times the entropy sample length */
> + wr_reg32(&r4tst->rtfrqmax, ent_delay << 4);
> /* read the control register */
> val = rd_reg32(&r4tst->rtmctl);
> start_rng:

--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |


2023-07-18 09:54:52

by Bastian Krause

[permalink] [raw]
Subject: Re: [PATCH] crypto: caam - adjust RNG timing to support more devices

On 7/17/23 14:43, Bastian Krause wrote:
> On 6/12/23 10:26, [email protected] wrote:
>> From: Victoria Milhoan <[email protected]>
>>
>> Adjust RNG timing parameters to support more i.MX6 devices.
>>
>> Signed-off-by: Victoria Milhoan <[email protected]>
>> Signed-off-by: Dan Douglass <[email protected]>
>> Signed-off-by: Vipul Kumar <[email protected]>
>> Signed-off-by: Horia Geantă <[email protected]>
>> ---
>>   drivers/crypto/caam/ctrl.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> This patch seems to breaks CAAM RNG instantiation on an i.MX8MM at my end:
>
> caam 30900000.crypto: Entropy delay = 3200
> caam 30900000.crypto: Entropy delay = 3600
> [...]
> caam 30900000.crypto: Entropy delay = 12400
> caam 30900000.crypto: failed to instantiate RNG
> caam: probe of 30900000.crypto failed with error -11
>
> If I revert this patch or increase RTSDCTL_ENT_DLY_MAX to a value >
> 66800, it works again:
>
> caam 30900000.crypto: Entropy delay = 32800
> caam 30900000.crypto: Entropy delay = 33200
> [...]
> caam 30900000.crypto: Entropy delay = 66800
> caam 30900000.crypto: Instantiated RNG4 SH0
> caam 30900000.crypto: Instantiated RNG4 SH1
> caam 30900000.crypto: device ID = 0x0a16040100000000 (Era 9)
> caam 30900000.crypto: job rings = 2, qi = 0
> caam algorithms registered in /proc/crypto
> caam 30900000.crypto: caam pkc algorithms registered in /proc/crypto
> caam 30900000.crypto: registering rng-caam
> Executing RNG SELF-TEST with wait
> random: crng init done
> caam 30900000.crypto: rng crypto API alg registered prng-caam

This ^ was the kernel log for..


--- a/drivers/crypto/caam/regs.h
+++ b/drivers/crypto/caam/regs.h
@@@ -522,7 -522,7 +522,7 @@@ struct rng4tst
#define RTSDCTL_ENT_DLY_SHIFT 16
#define RTSDCTL_ENT_DLY_MASK (0xffff << RTSDCTL_ENT_DLY_SHIFT)
#define RTSDCTL_ENT_DLY_MIN 3200
--#define RTSDCTL_ENT_DLY_MAX 12800
++#define RTSDCTL_ENT_DLY_MAX 70000
#define RTSDCTL_SAMP_SIZE_MASK 0xffff
#define RTSDCTL_SAMP_SIZE_VAL 512
u32 rtsdctl; /* seed control register */


For completion's sake: Reverting this patch..


--- a/drivers/crypto/caam/ctrl.c
+++ b/drivers/crypto/caam/ctrl.c
@@ -383,7 +383,7 @@ static void kick_trng(struct device *dev, int ent_delay)
/* min. freq. count, equal to 1/4 of the entropy sample length */
wr_reg32(&r4tst->rtfrqmin, val >> 2);
/* max. freq. count, equal to 16 times the entropy sample length */
- wr_reg32(&r4tst->rtfrqmax, val << 4);
+ wr_reg32(&r4tst->rtfrqmax, RTFRQMAX_DISABLE);
}

wr_reg32(&r4tst->rtsdctl, (val << RTSDCTL_ENT_DLY_SHIFT) |


..produces this kernel log (without RNG SELF-TEST):

caam 30900000.crypto: Entropy delay = 3200
caam 30900000.crypto: Entropy delay = 3600
caam 30900000.crypto: Instantiated RNG4 SH0
caam 30900000.crypto: Instantiated RNG4 SH1
caam 30900000.crypto: device ID = 0x0a16040100000000 (Era 9)
caam 30900000.crypto: job rings = 2, qi = 0
caam algorithms registered in /proc/crypto
caam 30900000.crypto: caam pkc algorithms registered in /proc/crypto
caam 30900000.crypto: registering rng-caam
caam 30900000.crypto: rng crypto API alg registered prng-caam
random: crng init done

Regards,
Bastian

>>
>> diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
>> index 5fed3cf354c0..62dd069942e4 100644
>> --- a/drivers/crypto/caam/ctrl.c
>> +++ b/drivers/crypto/caam/ctrl.c
>> @@ -383,8 +383,8 @@ static void kick_trng(struct device *dev, int
>> ent_delay)
>>       wr_reg32(&r4tst->rtsdctl, val);
>>       /* min. freq. count, equal to 1/4 of the entropy sample length */
>>       wr_reg32(&r4tst->rtfrqmin, ent_delay >> 2);
>> -    /* disable maximum frequency count */
>> -    wr_reg32(&r4tst->rtfrqmax, RTFRQMAX_DISABLE);
>> +    /* max. freq. count, equal to 16 times the entropy sample length */
>> +    wr_reg32(&r4tst->rtfrqmax, ent_delay << 4);
>>       /* read the control register */
>>       val = rd_reg32(&r4tst->rtmctl);
>>   start_rng:
>

--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |


2023-07-19 07:13:43

by Meenakshi Aggarwal

[permalink] [raw]
Subject: RE: [PATCH] crypto: caam - adjust RNG timing to support more devices

Hi Bastian,

We have tested the patch on i.mx8mm board and we did not face any issue with the patch.

Please share your imx8mm board revision and complete logs (including bootloader logs),
It will help in investigating the issue you are facing.

Thanks,
Meenakshi

> -----Original Message-----
> From: Bastian Krause <[email protected]>
> Sent: Tuesday, July 18, 2023 3:13 PM
> To: Meenakshi Aggarwal <[email protected]>; Horia Geanta
> <[email protected]>; Varun Sethi <[email protected]>; Pankaj Gupta
> <[email protected]>; Gaurav Jain <[email protected]>;
> [email protected]; [email protected]; linux-
> [email protected]; [email protected]
> Cc: Victoria Milhoan <[email protected]>; Dan Douglass
> <[email protected]>; Vipul Kumar <[email protected]>;
> [email protected]
> Subject: Re: [PATCH] crypto: caam - adjust RNG timing to support more devices
>
> On 7/17/23 14:43, Bastian Krause wrote:
> > On 6/12/23 10:26, [email protected] wrote:
> >> From: Victoria Milhoan <[email protected]>
> >>
> >> Adjust RNG timing parameters to support more i.MX6 devices.
> >>
> >> Signed-off-by: Victoria Milhoan <[email protected]>
> >> Signed-off-by: Dan Douglass <[email protected]>
> >> Signed-off-by: Vipul Kumar <[email protected]>
> >> Signed-off-by: Horia Geant? <[email protected]>
> >> ---
> >> drivers/crypto/caam/ctrl.c | 4 ++--
> >> 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > This patch seems to breaks CAAM RNG instantiation on an i.MX8MM at my end:
> >
> > caam 30900000.crypto: Entropy delay = 3200 caam 30900000.crypto:
> > Entropy delay = 3600 [...] caam 30900000.crypto: Entropy delay = 12400
> > caam 30900000.crypto: failed to instantiate RNG
> > caam: probe of 30900000.crypto failed with error -11
> >
> > If I revert this patch or increase RTSDCTL_ENT_DLY_MAX to a value >
> > 66800, it works again:
> >
> > caam 30900000.crypto: Entropy delay = 32800 caam 30900000.crypto:
> > Entropy delay = 33200 [...] caam 30900000.crypto: Entropy delay =
> > 66800 caam 30900000.crypto: Instantiated RNG4 SH0 caam
> > 30900000.crypto: Instantiated RNG4 SH1 caam 30900000.crypto: device ID
> > = 0x0a16040100000000 (Era 9) caam 30900000.crypto: job rings = 2, qi =
> > 0 caam algorithms registered in /proc/crypto caam 30900000.crypto:
> > caam pkc algorithms registered in /proc/crypto caam 30900000.crypto:
> > registering rng-caam Executing RNG SELF-TEST with wait
> > random: crng init done
> > caam 30900000.crypto: rng crypto API alg registered prng-caam
>
> This ^ was the kernel log for..
>
>
> --- a/drivers/crypto/caam/regs.h
> +++ b/drivers/crypto/caam/regs.h
> @@@ -522,7 -522,7 +522,7 @@@ struct rng4tst
> #define RTSDCTL_ENT_DLY_SHIFT 16
> #define RTSDCTL_ENT_DLY_MASK (0xffff << RTSDCTL_ENT_DLY_SHIFT)
> #define RTSDCTL_ENT_DLY_MIN 3200
> --#define RTSDCTL_ENT_DLY_MAX 12800
> ++#define RTSDCTL_ENT_DLY_MAX 70000
> #define RTSDCTL_SAMP_SIZE_MASK 0xffff
> #define RTSDCTL_SAMP_SIZE_VAL 512
> u32 rtsdctl; /* seed control register */
>
>
> For completion's sake: Reverting this patch..
>
>
> --- a/drivers/crypto/caam/ctrl.c
> +++ b/drivers/crypto/caam/ctrl.c
> @@ -383,7 +383,7 @@ static void kick_trng(struct device *dev, int ent_delay)
> /* min. freq. count, equal to 1/4 of the entropy sample length */
> wr_reg32(&r4tst->rtfrqmin, val >> 2);
> /* max. freq. count, equal to 16 times the entropy sample length */
> - wr_reg32(&r4tst->rtfrqmax, val << 4);
> + wr_reg32(&r4tst->rtfrqmax, RTFRQMAX_DISABLE);
> }
>
> wr_reg32(&r4tst->rtsdctl, (val << RTSDCTL_ENT_DLY_SHIFT) |
>
>
> ..produces this kernel log (without RNG SELF-TEST):
>
> caam 30900000.crypto: Entropy delay = 3200 caam 30900000.crypto: Entropy
> delay = 3600 caam 30900000.crypto: Instantiated RNG4 SH0 caam
> 30900000.crypto: Instantiated RNG4 SH1 caam 30900000.crypto: device ID =
> 0x0a16040100000000 (Era 9) caam 30900000.crypto: job rings = 2, qi = 0 caam
> algorithms registered in /proc/crypto caam 30900000.crypto: caam pkc
> algorithms registered in /proc/crypto caam 30900000.crypto: registering rng-
> caam caam 30900000.crypto: rng crypto API alg registered prng-caam
> random: crng init done
>
> Regards,
> Bastian
>
> >>
> >> diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
> >> index 5fed3cf354c0..62dd069942e4 100644
> >> --- a/drivers/crypto/caam/ctrl.c
> >> +++ b/drivers/crypto/caam/ctrl.c
> >> @@ -383,8 +383,8 @@ static void kick_trng(struct device *dev, int
> >> ent_delay)
> >> wr_reg32(&r4tst->rtsdctl, val);
> >> /* min. freq. count, equal to 1/4 of the entropy sample length
> >> */
> >> wr_reg32(&r4tst->rtfrqmin, ent_delay >> 2);
> >> - /* disable maximum frequency count */
> >> - wr_reg32(&r4tst->rtfrqmax, RTFRQMAX_DISABLE);
> >> + /* max. freq. count, equal to 16 times the entropy sample length
> >> +*/
> >> + wr_reg32(&r4tst->rtfrqmax, ent_delay << 4);
> >> /* read the control register */
> >> val = rd_reg32(&r4tst->rtmctl);
> >> start_rng:
> >
>
> --
> Pengutronix e.K. | |
> Steuerwalder Str. 21 |
> http://www.pen/
> gutronix.de%2F&data=05%7C01%7Cmeenakshi.aggarwal%40nxp.com%7C1f556
> d6802434c00ef4f08db87736527%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C
> 0%7C0%7C638252701909887583%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4
> wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C
> %7C%7C&sdata=2vCBBdo%2FAkyz%2BaLXcDyeursw3Gle%2FKosiO%2FdPysOd3
> Q%3D&reserved=0 |
> 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |


2023-07-24 05:14:24

by Meenakshi Aggarwal

[permalink] [raw]
Subject: RE: [PATCH] crypto: caam - adjust RNG timing to support more devices

Hi Bastian,

Please share the required information.

Thanks,
Meenakshi

> -----Original Message-----
> From: Meenakshi Aggarwal <[email protected]>
> Sent: Wednesday, July 19, 2023 12:31 PM
> To: Bastian Krause <[email protected]>; Horia Geanta
> <[email protected]>; Varun Sethi <[email protected]>; Pankaj Gupta
> <[email protected]>; Gaurav Jain <[email protected]>;
> [email protected]; [email protected]; linux-
> [email protected]; [email protected]
> Cc: Victoria Milhoan <[email protected]>; Dan Douglass
> <[email protected]>; Vipul Kumar <[email protected]>;
> [email protected]
> Subject: RE: [PATCH] crypto: caam - adjust RNG timing to support more devices
>
> Hi Bastian,
>
> We have tested the patch on i.mx8mm board and we did not face any issue with
> the patch.
>
> Please share your imx8mm board revision and complete logs (including
> bootloader logs), It will help in investigating the issue you are facing.
>
> Thanks,
> Meenakshi
>
> > -----Original Message-----
> > From: Bastian Krause <[email protected]>
> > Sent: Tuesday, July 18, 2023 3:13 PM
> > To: Meenakshi Aggarwal <[email protected]>; Horia Geanta
> > <[email protected]>; Varun Sethi <[email protected]>; Pankaj Gupta
> > <[email protected]>; Gaurav Jain <[email protected]>;
> > [email protected]; [email protected]; linux-
> > [email protected]; [email protected]
> > Cc: Victoria Milhoan <[email protected]>; Dan Douglass
> > <[email protected]>; Vipul Kumar <[email protected]>;
> > [email protected]
> > Subject: Re: [PATCH] crypto: caam - adjust RNG timing to support more
> > devices
> >
> > On 7/17/23 14:43, Bastian Krause wrote:
> > > On 6/12/23 10:26, [email protected] wrote:
> > >> From: Victoria Milhoan <[email protected]>
> > >>
> > >> Adjust RNG timing parameters to support more i.MX6 devices.
> > >>
> > >> Signed-off-by: Victoria Milhoan <[email protected]>
> > >> Signed-off-by: Dan Douglass <[email protected]>
> > >> Signed-off-by: Vipul Kumar <[email protected]>
> > >> Signed-off-by: Horia Geant? <[email protected]>
> > >> ---
> > >> drivers/crypto/caam/ctrl.c | 4 ++--
> > >> 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > This patch seems to breaks CAAM RNG instantiation on an i.MX8MM at my
> end:
> > >
> > > caam 30900000.crypto: Entropy delay = 3200 caam 30900000.crypto:
> > > Entropy delay = 3600 [...] caam 30900000.crypto: Entropy delay =
> > > 12400 caam 30900000.crypto: failed to instantiate RNG
> > > caam: probe of 30900000.crypto failed with error -11
> > >
> > > If I revert this patch or increase RTSDCTL_ENT_DLY_MAX to a value >
> > > 66800, it works again:
> > >
> > > caam 30900000.crypto: Entropy delay = 32800 caam 30900000.crypto:
> > > Entropy delay = 33200 [...] caam 30900000.crypto: Entropy delay =
> > > 66800 caam 30900000.crypto: Instantiated RNG4 SH0 caam
> > > 30900000.crypto: Instantiated RNG4 SH1 caam 30900000.crypto: device
> > > ID = 0x0a16040100000000 (Era 9) caam 30900000.crypto: job rings = 2,
> > > qi =
> > > 0 caam algorithms registered in /proc/crypto caam 30900000.crypto:
> > > caam pkc algorithms registered in /proc/crypto caam 30900000.crypto:
> > > registering rng-caam Executing RNG SELF-TEST with wait
> > > random: crng init done
> > > caam 30900000.crypto: rng crypto API alg registered prng-caam
> >
> > This ^ was the kernel log for..
> >
> >
> > --- a/drivers/crypto/caam/regs.h
> > +++ b/drivers/crypto/caam/regs.h
> > @@@ -522,7 -522,7 +522,7 @@@ struct rng4tst
> > #define RTSDCTL_ENT_DLY_SHIFT 16
> > #define RTSDCTL_ENT_DLY_MASK (0xffff << RTSDCTL_ENT_DLY_SHIFT)
> > #define RTSDCTL_ENT_DLY_MIN 3200
> > --#define RTSDCTL_ENT_DLY_MAX 12800
> > ++#define RTSDCTL_ENT_DLY_MAX 70000
> > #define RTSDCTL_SAMP_SIZE_MASK 0xffff
> > #define RTSDCTL_SAMP_SIZE_VAL 512
> > u32 rtsdctl; /* seed control register */
> >
> >
> > For completion's sake: Reverting this patch..
> >
> >
> > --- a/drivers/crypto/caam/ctrl.c
> > +++ b/drivers/crypto/caam/ctrl.c
> > @@ -383,7 +383,7 @@ static void kick_trng(struct device *dev, int ent_delay)
> > /* min. freq. count, equal to 1/4 of the entropy sample length */
> > wr_reg32(&r4tst->rtfrqmin, val >> 2);
> > /* max. freq. count, equal to 16 times the entropy sample length */
> > - wr_reg32(&r4tst->rtfrqmax, val << 4);
> > + wr_reg32(&r4tst->rtfrqmax, RTFRQMAX_DISABLE);
> > }
> >
> > wr_reg32(&r4tst->rtsdctl, (val << RTSDCTL_ENT_DLY_SHIFT) |
> >
> >
> > ..produces this kernel log (without RNG SELF-TEST):
> >
> > caam 30900000.crypto: Entropy delay = 3200 caam 30900000.crypto:
> > Entropy delay = 3600 caam 30900000.crypto: Instantiated RNG4 SH0 caam
> > 30900000.crypto: Instantiated RNG4 SH1 caam 30900000.crypto: device ID
> > =
> > 0x0a16040100000000 (Era 9) caam 30900000.crypto: job rings = 2, qi = 0
> > caam algorithms registered in /proc/crypto caam 30900000.crypto: caam
> > pkc algorithms registered in /proc/crypto caam 30900000.crypto:
> > registering rng- caam caam 30900000.crypto: rng crypto API alg
> > registered prng-caam
> > random: crng init done
> >
> > Regards,
> > Bastian
> >
> > >>
> > >> diff --git a/drivers/crypto/caam/ctrl.c
> > >> b/drivers/crypto/caam/ctrl.c index 5fed3cf354c0..62dd069942e4
> > >> 100644
> > >> --- a/drivers/crypto/caam/ctrl.c
> > >> +++ b/drivers/crypto/caam/ctrl.c
> > >> @@ -383,8 +383,8 @@ static void kick_trng(struct device *dev, int
> > >> ent_delay)
> > >> wr_reg32(&r4tst->rtsdctl, val);
> > >> /* min. freq. count, equal to 1/4 of the entropy sample
> > >> length */
> > >> wr_reg32(&r4tst->rtfrqmin, ent_delay >> 2);
> > >> - /* disable maximum frequency count */
> > >> - wr_reg32(&r4tst->rtfrqmax, RTFRQMAX_DISABLE);
> > >> + /* max. freq. count, equal to 16 times the entropy sample
> > >> +length */
> > >> + wr_reg32(&r4tst->rtfrqmax, ent_delay << 4);
> > >> /* read the control register */
> > >> val = rd_reg32(&r4tst->rtmctl);
> > >> start_rng:
> > >
> >
> > --
> > Pengutronix e.K. | |
> > Steuerwalder Str. 21 |
> > http://www.p/
> >
> en%2F&data=05%7C01%7Cmeenakshi.aggarwal%40nxp.com%7C3e036baed8c9
> 4cf104
> >
> 4008db8825e5ce%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6382
> 534685
> >
> 76971721%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2l
> uMzIiL
> >
> CJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=vbtE1IciakfHjf
> JQiB
> > VxOGN%2Bm7JBlT%2B1obDRf0eyOuM%3D&reserved=0
> >
> gutronix.de%2F&data=05%7C01%7Cmeenakshi.aggarwal%40nxp.com%7C1f556
> >
> d6802434c00ef4f08db87736527%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C
> >
> 0%7C0%7C638252701909887583%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4
> >
> wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C
> > %7C%7C&sdata=2vCBBdo%2FAkyz%2BaLXcDyeursw3Gle%2FKosiO%2FdPysOd
> 3
> > Q%3D&reserved=0 |
> > 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |


2023-08-04 09:39:56

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: caam - adjust RNG timing to support more devices

On Mon, Jul 24, 2023 at 05:13:23AM +0000, Meenakshi Aggarwal wrote:
> Hi Bastian,
>
> Please share the required information.

Any progress on this?

Should we revert the offending patch?

Thanks,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Subject: Re: [PATCH] crypto: caam - adjust RNG timing to support more devices

[CCing the regression list, as it should be in the loop for regressions:
https://docs.kernel.org/admin-guide/reporting-regressions.html]

[TLDR: I'm adding this report to the list of tracked Linux kernel
regressions; the text you find below is based on a few templates
paragraphs you might have encountered already in similar form.
See link in footer if these mails annoy you.]

On 17.07.23 14:43, Bastian Krause wrote:
> On 6/12/23 10:26, [email protected] wrote:
>> From: Victoria Milhoan <[email protected]>
>>
>> Adjust RNG timing parameters to support more i.MX6 devices.
>>
>> Signed-off-by: Victoria Milhoan <[email protected]>
>> Signed-off-by: Dan Douglass <[email protected]>
>> Signed-off-by: Vipul Kumar <[email protected]>
>> Signed-off-by: Horia Geantă <[email protected]>
>> ---
>>   drivers/crypto/caam/ctrl.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> This patch seems to breaks CAAM RNG instantiation on an i.MX8MM at my end:
> [...]

Thanks for the report. I see that people are working on it already. But
to be sure the issue doesn't fall through the cracks unnoticed, I'm
adding it to regzbot, the Linux kernel regression tracking bot:

#regzbot ^introduced ef492d08030
#regzbot title crypto: broke CAAM RNG instantiation on an i.MX8MM
#regzbot ignore-activity

This isn't a regression? This issue or a fix for it are already
discussed somewhere else? It was fixed already? You want to clarify when
the regression started to happen? Or point out I got the title or
something else totally wrong? Then just reply and tell me -- ideally
while also telling regzbot about it, as explained by the page listed in
the footer of this mail.

Developers: When fixing the issue, remember to add 'Link:' tags pointing
to the report (the parent of this mail). See page linked in footer for
details.

Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat)
--
Everything you wanna know about Linux kernel regression tracking:
https://linux-regtracking.leemhuis.info/about/#tldr
That page also explains what to do if mails like this annoy you.