i.MX6SX: crypto/fsl: fix entropy delay value
PATCH 1/1 i.MX6SX: crypto/fsl: fix entropy delay value
RNG Hardware error is reported due to incorrect entropy delay
rng self test are run to determine the correct ent_dly.
test is executed with different voltage and temperature to identify the worst case value for ent_dly. after adding a margin value(1000), ent_dly should be at least 12000.
--- drivers/crypto/fsl/jr.c | 11 ++++++++++- include/fsl_sec.h | 6 +++++- 2 files changed, 15 insertions(+), 2 deletions(-)
drivers/crypto/fsl/jr.c +10 -1
@@ -623,7 +623,7 @@ static void kick_trng(int ent_delay, ccsr_sec_t *sec)static int rng_init (uint8_t sec_idx,ccsr_sec_t *sec) { -int ret, gen_sk, ent_delay =RTSDCTL_ENT_DLY_MIN ; +int ret, gen_sk, ent_delay =RTSDCTL_ENT_DLY ;struct rng4tst __iomem *rng = (struct rng4tst __iomem *)&sec->rng;u32 inst_handles;
@@ -652,6 +652,15 @@ static int rng_init(uint8_t sec_idx, ccsr_sec_t *sec)* the RNG. */ ret =instantiate_rng (sec_idx, sec, gen_sk); +/* +* entropy delay is calculated via self-test method. +* self-test are run across different volatge, temp. +* if worst case value for ent_dly is identified, +* loop can be skipped for that platform. +*/ +if (IS_ENABLED (CONFIG_MX6SX )) +break ; + }while ((ret ==-1 ) && (ent_delay <RTSDCTL_ENT_DLY_MAX ));if (ret) {printf ("SEC%u: Failed to instantiate RNG\n" , sec_idx);
include/fsl_sec.h +5 -1
@@ -48,7 +48,11 @@ struct rng4tst {u32 rtmctl;/* misc. control register */ u32 rtscmisc;/* statistical check misc. register */ u32 rtpkrrng;/* poker range register */ -#define RTSDCTL_ENT_DLY_MIN 3200 +#ifdef CONFIG_MX6SX +#define RTSDCTL_ENT_DLY 12000 +#else +#define RTSDCTL_ENT_DLY 3200 +#endif #define RTSDCTL_ENT_DLY_MAX 12800union {u32 rtpkrmax;/* PRGM=1: poker max. limit register */
Signature · 1 line
2.25.1
Quoted 2 lines · Gaurav Jain
RNG Hardware error is reported due to incorrect entropy delay
Yes, I observe the RNG hardware error in the kernel too.
Quoted 25 lines
rng self test are run to determine the correct
ent_dly.
test is executed with different voltage and temperature to identify the worst case value forent_dly. after adding a margin value(1000),ent_dlyshould be at least 12000.Signed-off-by Gaurav Jain <[email protected]>--- drivers/crypto/fsl/jr.c | 11 ++++++++++- include/fsl_sec.h | 6 +++++- 2 files changed, 15 insertions(+), 2 deletions(-)drivers/crypto/fsl/jr.c +1
-1@@ -623,7 +623,7 @@ static void kick_trng(int ent_delay, ccsr_sec_t *sec)static int rng_init (uint8_t sec_idx,ccsr_sec_t *sec) { -int ret, gen_sk, ent_delay =RTSDCTL_ENT_DLY_MIN ; +int ret, gen_sk, ent_delay =RTSDCTL_ENT_DLY ;struct rng4tst __iomem *rng = (struct rng4tst __iomem *)&sec->rng;u32 inst_handles;
drivers/crypto/fsl/jr.c static int rng_init(uint8_t sec_idx, ccsr_sec_t *sec) · line 657
Quoted 6 lines
drivers/crypto/fsl/jr.c +3
-0@@ -652,6 +652,15 @@ static int rng_init(uint8_t sec_idx, ccsr_sec_t *sec)* the RNG. */ ret =instantiate_rng (sec_idx, sec, gen_sk); +/* +* entropy delay is calculated via self-test method. +* self-test are run across different volatge, temp.
s/volatge/voltage
Hello Stefano
This patch is already merged in kernel https://patchwork.kernel.org/project/linux-crypto/patch/[email protected]/
Can you help to check and merge this in Uboot as well.
Regards
Gaurav Jain
Quoted 70 lines
-----Original Message-----
From: Gaurav Jain
Sent: Friday, April 15, 2022 4:41 PM
To: Stefano Babic <[email protected]>; [email protected]
Cc: Fabio Estevam <[email protected]>; Peng Fan <[email protected]>; Priyanka Jain <[email protected]>; Ye Li <[email protected]>; Horia Geanta <[email protected]>; Silvano Di Ninno <[email protected]>; Varun Sethi <[email protected]>; dl-uboot-imx <[email protected]>; Gaurav Jain <[email protected]>
Subject: [PATCH] i.MX6SX:crypto/fsl: fix entropy delay valueRNG Hardware error is reported due to incorrect entropy delay
rng self test are run to determine the correct
ent_dly.
test is executed with different voltage and temperature to identify the worst case value forent_dly. after adding a margin value(1000),ent_dlyshould be at least 12000.Signed-off-by Gaurav Jain <[email protected]>--- drivers/crypto/fsl/jr.c | 11 ++++++++++- include/fsl_sec.h | 6 +++++- 2 files changed, 15 insertions(+), 2 deletions(-)drivers/crypto/fsl/jr.c index renamed from drivers/crypto/fsl/jr.c +0
-0
1d951cf0a6..85a3dac796100644drivers/crypto/fsl/jr.c +10
-1@@ -623,7 +623,7 @@ static void kick_trng(int ent_delay, ccsr_sec_t *sec)static int rng_init (uint8_t sec_idx,ccsr_sec_t *sec) { -int ret, gen_sk, ent_delay =RTSDCTL_ENT_DLY_MIN ; +int ret, gen_sk, ent_delay =RTSDCTL_ENT_DLY ;struct rng4tst __iomem *rng = (struct rng4tst __iomem *)&sec->rng;u32 inst_handles;@@ -652,6 +652,15 @@ static int rng_init(uint8_t sec_idx, ccsr_sec_t *sec)* the RNG. */ ret =instantiate_rng (sec_idx, sec, gen_sk); +/* +* entropy delay is calculated via self-test method. +* self-test are run across different volatge, temp. +* if worst case value for ent_dly is identified, +* loop can be skipped for that platform. +*/ +if (IS_ENABLED (CONFIG_MX6SX )) +break ; + }while ((ret ==-1 ) && (ent_delay <RTSDCTL_ENT_DLY_MAX ));if (ret) { printf("SEC%u: Failed to instantiate RNG\n", sec_idx); diff --git
a/include/fsl_sec.hb/include/fsl_sec.hindex7b6e3e2c20..d57c4ca820100644include/fsl_sec.h +5
-2@@ -48,7 +48,11 @@ struct rng4tst {u32 rtmctl;/* misc. control register */ u32 rtscmisc;/* statistical check misc. register */ u32 rtpkrrng;/* poker range register */ -#define RTSDCTL_ENT_DLY_MIN 3200 +#ifdef CONFIG_MX6SX +#define RTSDCTL_ENT_DLY 12000 +#else +#define RTSDCTL_ENT_DLY 3200 +#endif #define RTSDCTL_ENT_DLY_MAX 12800union {u32 rtpkrmax;/* PRGM=1: poker max. limit register */ --2.25.1
PATCH 1/1 i.MX6SX: crypto/fsl: fix entropy delay value
In reply to Gaurav JainQuoted 7 lines
RNG Hardware error is reported due to incorrect entropy delay rng self test are run to determine the correct
ent_dly.
test is executed with different voltage and temperature to identify the worst case value forent_dly. after adding a margin value(1000),ent_dlyshould be at least 12000.Signed-off-by Gaurav Jain <[email protected]>Reviewed-by Fabio Estevam <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected] =====================================================================