2022-05-31 10:01:04

by Vabhav Sharma

[permalink] [raw]
Subject: [PATCH 0/3] add entropy delay device tree property

Add entropy delay device tree property,TRNG self test are run to determine
the correct entropy delay.
Firmware test is executed with different voltage and temperature to
identify the worst case value for entropy delay on imx6sx platform, after
adding a margin value(1000),entropy delay should be at least 12000.
- Add dt-bindings
- updated imx6sx device tree
- modify caam driver to read the property

Vabhav Sharma (3):
dt-bindings: crypto: fsl: add entropy delay property
arm: dts: imx6sx: Add entropy delay property
crypto: caam: read entropy delay from device tree

.../devicetree/bindings/crypto/fsl-sec4.txt | 6 ++++++
arch/arm/boot/dts/imx6sx.dtsi | 1 +
drivers/crypto/caam/ctrl.c | 16 ++++++++++++----
3 files changed, 19 insertions(+), 4 deletions(-)

--
2.25.1



2022-05-31 13:57:52

by Vabhav Sharma

[permalink] [raw]
Subject: [PATCH 3/3] crypto: caam: read entropy delay from device tree

Read entropy-delay property from device tree for
TRNG configuration.

update the value if entry is missing in DT.

Signed-off-by: Vabhav Sharma <[email protected]>
Reviewed-by: Gaurav Jain <[email protected]>
Reviewed-by: Horia Geanta <[email protected]>
---
drivers/crypto/caam/ctrl.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
index 32253a064d0f..5ffab99d831c 100644
--- a/drivers/crypto/caam/ctrl.c
+++ b/drivers/crypto/caam/ctrl.c
@@ -619,7 +619,7 @@ static bool needs_entropy_delay_adjustment(void)
/* Probe routine for CAAM top (controller) level */
static int caam_probe(struct platform_device *pdev)
{
- int ret, ring, gen_sk, ent_delay = RTSDCTL_ENT_DLY_MIN;
+ int ret, ring, gen_sk;
u64 caam_id;
const struct soc_device_attribute *imx_soc_match;
struct device *dev;
@@ -627,7 +627,7 @@ static int caam_probe(struct platform_device *pdev)
struct caam_ctrl __iomem *ctrl;
struct caam_drv_private *ctrlpriv;
struct dentry *dfs_root;
- u32 scfgr, comp_params;
+ u32 scfgr, comp_params, ent_delay = RTSDCTL_ENT_DLY_MIN;
u8 rng_vid;
int pg_size;
int BLOCK_OFFSET = 0;
@@ -847,6 +847,16 @@ static int caam_probe(struct platform_device *pdev)
(rd_reg32(&ctrl->vreg.aesa) & CHA_VER_MISC_AES_NUM_MASK);
}

+ /*
+ * Read entropy-delay property from device tree. If property is not
+ * available or missing, update the entropy delay value only for imx6sx.
+ */
+ if (device_property_read_u32(dev, "entropy-delay", &ent_delay)) {
+ dev_dbg(dev, "entropy-delay property missing in DT\n");
+ if (needs_entropy_delay_adjustment())
+ ent_delay = 12000;
+ }
+
/*
* If SEC has RNG version >= 4 and RNG state handle has not been
* already instantiated, do RNG instantiation
@@ -875,8 +885,6 @@ static int caam_probe(struct platform_device *pdev)
* Also, if a handle was instantiated, do not change
* the TRNG parameters.
*/
- if (needs_entropy_delay_adjustment())
- ent_delay = 12000;
if (!(ctrlpriv->rng4_sh_init || inst_handles)) {
dev_info(dev,
"Entropy delay = %u\n",
--
2.25.1


2022-05-31 19:29:43

by Vabhav Sharma

[permalink] [raw]
Subject: [PATCH 1/3] dt-bindings: crypto: fsl: add entropy delay property

Add entropy delay property which defines the length (in system clocks) of
each Entropy sample taken for TRNG configuration.

Signed-off-by: Vabhav Sharma <[email protected]>
Reviewed-by: Horia Geanta <[email protected]>
Reviewed-by: Varun Sethi <[email protected]>
---
Documentation/devicetree/bindings/crypto/fsl-sec4.txt | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/crypto/fsl-sec4.txt b/Documentation/devicetree/bindings/crypto/fsl-sec4.txt
index 8f359f473ada..1477294eda38 100644
--- a/Documentation/devicetree/bindings/crypto/fsl-sec4.txt
+++ b/Documentation/devicetree/bindings/crypto/fsl-sec4.txt
@@ -62,6 +62,12 @@ PROPERTIES
Definition: A standard property. Define the 'ERA' of the SEC
device.

+ - entropy-delay
+ Usage: optional
+ Value type: <u32>
+ Definition: A property which specifies the length (in system clocks)
+ of each Entropy sample taken.
+
- #address-cells
Usage: required
Value type: <u32>
--
2.25.1