hwrng: imx-rngc - reasonable timeout for selftest
authorMartin Kaiser <martin@kaiser.cx>
Tue, 12 Sep 2023 14:31:17 +0000 (16:31 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 20 Sep 2023 05:15:29 +0000 (13:15 +0800)
Set a more reasonable timeout for the rngc selftest.

According to the reference manual, "The self test takes approximately
29,000 cycles to complete." The lowest possible frequency of the rngc
peripheral clock is 33.25MHz, the selftest would then take about 872us.

2.5ms should be enough for the selftest timeout.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/char/hw_random/imx-rngc.c

index e4b385b01b1134017e37f3a0c0e9903b93492d5b..127c292dfbbfbfd53502ce45b25f5b22b8a55b69 100644 (file)
@@ -53,6 +53,7 @@
 
 #define RNGC_TIMEOUT  3000 /* 3 sec */
 
+#define RNGC_SELFTEST_TIMEOUT 2500 /* us */
 
 static bool self_test = true;
 module_param(self_test, bool, 0);
@@ -110,7 +111,8 @@ static int imx_rngc_self_test(struct imx_rngc *rngc)
        cmd = readl(rngc->base + RNGC_COMMAND);
        writel(cmd | RNGC_CMD_SELF_TEST, rngc->base + RNGC_COMMAND);
 
-       ret = wait_for_completion_timeout(&rngc->rng_op_done, msecs_to_jiffies(RNGC_TIMEOUT));
+       ret = wait_for_completion_timeout(&rngc->rng_op_done,
+                                         usecs_to_jiffies(RNGC_SELFTEST_TIMEOUT));
        imx_rngc_irq_mask_clear(rngc);
        if (!ret)
                return -ETIMEDOUT;