提交 12ebbe79 编写于 作者: F Fabio Estevam 提交者: Zheng Zengkai

crypto: caam - fix i.MX6SX entropy delay value

stable inclusion
from stable-v5.10.120
commit c013f7d1cd92d945398c63a7d6a8b0dd99c23679
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6BR

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=c013f7d1cd92d945398c63a7d6a8b0dd99c23679

--------------------------------

commit 4ee4cdad upstream.

Since commit 358ba762 ("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: 358ba762 ("crypto: caam - enable prediction resistance in HRWNG")
Signed-off-by: NFabio Estevam <festevam@denx.de>
Reviewed-by: NHoria Geantă <horia.geanta@nxp.com>
Reviewed-by: NVabhav Sharma <vabhav.sharma@nxp.com>
Reviewed-by: NGaurav Jain <gaurav.jain@nxp.com>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 10aea0f7
...@@ -609,6 +609,13 @@ static bool check_version(struct fsl_mc_version *mc_version, u32 major, ...@@ -609,6 +609,13 @@ static bool check_version(struct fsl_mc_version *mc_version, u32 major,
} }
#endif #endif
static bool needs_entropy_delay_adjustment(void)
{
if (of_machine_is_compatible("fsl,imx6sx"))
return true;
return false;
}
/* Probe routine for CAAM top (controller) level */ /* Probe routine for CAAM top (controller) level */
static int caam_probe(struct platform_device *pdev) static int caam_probe(struct platform_device *pdev)
{ {
...@@ -855,6 +862,8 @@ static int caam_probe(struct platform_device *pdev) ...@@ -855,6 +862,8 @@ static int caam_probe(struct platform_device *pdev)
* Also, if a handle was instantiated, do not change * Also, if a handle was instantiated, do not change
* the TRNG parameters. * the TRNG parameters.
*/ */
if (needs_entropy_delay_adjustment())
ent_delay = 12000;
if (!(ctrlpriv->rng4_sh_init || inst_handles)) { if (!(ctrlpriv->rng4_sh_init || inst_handles)) {
dev_info(dev, dev_info(dev,
"Entropy delay = %u\n", "Entropy delay = %u\n",
...@@ -871,6 +880,15 @@ static int caam_probe(struct platform_device *pdev) ...@@ -871,6 +880,15 @@ static int caam_probe(struct platform_device *pdev)
*/ */
ret = instantiate_rng(dev, inst_handles, ret = instantiate_rng(dev, inst_handles,
gen_sk); gen_sk);
/*
* Entropy delay is determined via TRNG characterization.
* TRNG characterization is run across different voltages
* and temperatures.
* If worst case value for ent_dly is identified,
* the loop can be skipped for that platform.
*/
if (needs_entropy_delay_adjustment())
break;
if (ret == -EAGAIN) if (ret == -EAGAIN)
/* /*
* if here, the loop will rerun, * if here, the loop will rerun,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册