Skip to content

Commit c013f7d

Browse files
Fabio Estevamgregkh
authored andcommitted
crypto: caam - fix i.MX6SX entropy delay value
commit 4ee4cda upstream. Since commit 358ba76 ("crypto: caam - enable prediction resistance in HRWNG") the following CAAM errors can be seen on i.MX6SX: caam_jr 2101000.jr: 20003c5b: CCB: desc idx 60: RNG: Hardware error hwrng: no data available This error is due to an incorrect entropy delay for i.MX6SX. Fix it by increasing the minimum entropy delay for i.MX6SX as done in U-Boot: https://patchwork.ozlabs.org/project/uboot/patch/20220415111049.2565744-1-gaurav.jain@nxp.com/ As explained in the U-Boot patch: "RNG self tests are run to determine the correct entropy delay. Such tests are executed with different voltages and temperatures to identify the worst case value for the entropy delay. For i.MX6SX, it was determined that after adding a margin value of 1000 the minimum entropy delay should be at least 12000." Cc: <stable@vger.kernel.org> Fixes: 358ba76 ("crypto: caam - enable prediction resistance in HRWNG") Signed-off-by: Fabio Estevam <festevam@denx.de> Reviewed-by: Horia Geantă <horia.geanta@nxp.com> Reviewed-by: Vabhav Sharma <vabhav.sharma@nxp.com> Reviewed-by: Gaurav Jain <gaurav.jain@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3d8fc6e commit c013f7d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

drivers/crypto/caam/ctrl.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,13 @@ static bool check_version(struct fsl_mc_version *mc_version, u32 major,
609609
}
610610
#endif
611611

612+
static bool needs_entropy_delay_adjustment(void)
613+
{
614+
if (of_machine_is_compatible("fsl,imx6sx"))
615+
return true;
616+
return false;
617+
}
618+
612619
/* Probe routine for CAAM top (controller) level */
613620
static int caam_probe(struct platform_device *pdev)
614621
{
@@ -855,6 +862,8 @@ static int caam_probe(struct platform_device *pdev)
855862
* Also, if a handle was instantiated, do not change
856863
* the TRNG parameters.
857864
*/
865+
if (needs_entropy_delay_adjustment())
866+
ent_delay = 12000;
858867
if (!(ctrlpriv->rng4_sh_init || inst_handles)) {
859868
dev_info(dev,
860869
"Entropy delay = %u\n",
@@ -871,6 +880,15 @@ static int caam_probe(struct platform_device *pdev)
871880
*/
872881
ret = instantiate_rng(dev, inst_handles,
873882
gen_sk);
883+
/*
884+
* Entropy delay is determined via TRNG characterization.
885+
* TRNG characterization is run across different voltages
886+
* and temperatures.
887+
* If worst case value for ent_dly is identified,
888+
* the loop can be skipped for that platform.
889+
*/
890+
if (needs_entropy_delay_adjustment())
891+
break;
874892
if (ret == -EAGAIN)
875893
/*
876894
* if here, the loop will rerun,

0 commit comments

Comments
 (0)