diff options
author | Aymen Sghaier <aymen.sghaier@nxp.com> | 2017-12-18 12:06:00 +0100 |
---|---|---|
committer | Jason Liu <jason.hui.liu@nxp.com> | 2019-02-12 10:32:46 +0800 |
commit | 1091a6fb0749b2fd1e8f663ecbd7f2d6aa861e72 (patch) | |
tree | 2c63ca85f579a5b5fdc8121afedae22a91f08ec5 | |
parent | 0e77b44cc01f3388ebe6e2066c49a5474016bf79 (diff) |
MLK-17111-4: crypto: caam: Fix RNG Kernel oops on i.MX8QXP
Seen on i.MX8QXP board by reboot test, that Kernel oops occurs
due to failing RNG instantiation with default entropy delay.
The fix is to disable all job rings if RNG failed to prevent
Kernel crash. And print an error message saying that this is
a known limitation on REV A0 SoC.
Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
-rw-r--r-- | drivers/crypto/caam/jr.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c index b96d4db6709b..8662e6062956 100644 --- a/drivers/crypto/caam/jr.c +++ b/drivers/crypto/caam/jr.c @@ -486,7 +486,7 @@ static int caam_jr_probe(struct platform_device *pdev) struct device *jrdev; struct device_node *nprop; struct caam_job_ring __iomem *ctrl; - struct caam_drv_private_jr *jrpriv; + struct caam_drv_private_jr *jrpriv, *jrppriv; static int total_jobrs; int error; @@ -563,7 +563,20 @@ static int caam_jr_probe(struct platform_device *pdev) /* * Instantiate RNG by JR rather than DECO */ - if (jrpriv->ridx == 0) { + spin_lock(&driver_data.jr_alloc_lock); + if (list_empty(&driver_data.jr_list)) { + spin_unlock(&driver_data.jr_alloc_lock); + dev_err(jrdev, "jr_list is empty\n"); + return -ENODEV; + } + jrppriv = list_first_entry(&driver_data.jr_list, + struct caam_drv_private_jr, list_node); + spin_unlock(&driver_data.jr_alloc_lock); + /* + * If this is the first available JR + * then try to instantiate RNG + */ + if (jrppriv->ridx == jrpriv->ridx) { if (of_machine_is_compatible("fsl,imx8qm") || of_machine_is_compatible("fsl,imx8qxp")) { /* @@ -584,6 +597,17 @@ static int caam_jr_probe(struct platform_device *pdev) error = inst_rng_imx6(pdev); } } + if (error != 0) { +#ifdef CONFIG_HAVE_IMX8_SOC + if (imx8_get_soc_revision() == IMX_CHIP_REVISION_1_0) + dev_err(jrdev, + "This is a known limitation on A0 SOC revision\n" + "RNG instantiation failed, CAAM needs a reboot\n"); +#endif /* CONFIG_HAVE_IMX8_SOC */ + spin_lock(&driver_data.jr_alloc_lock); + list_del(&jrpriv->list_node); + spin_unlock(&driver_data.jr_alloc_lock); + } return error; } |