Skip to content

Commit

Permalink
hwrng: imx-rngc - reasonable timeout for initial seed
Browse files Browse the repository at this point in the history
Set a more reasonable timeout for calculating the initial seed.

The reference manuals says that "The initial seed takes approximately
2,000,000 clock cycles." The rngc peripheral clock runs at >= 33.25MHz,
so seeding takes at most 60ms.

A timeout of 200ms is more appropriate than the current value of 3
seconds.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
martin-kaiser authored and herbertx committed Sep 20, 2023
1 parent b6c6044 commit 50fb6d5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/char/hw_random/imx-rngc.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@

#define RNGC_ERROR_STATUS_STAT_ERR 0x00000008

#define RNGC_TIMEOUT 3000 /* 3 sec */

#define RNGC_SELFTEST_TIMEOUT 2500 /* us */
#define RNGC_SEED_TIMEOUT 200 /* ms */

static bool self_test = true;
module_param(self_test, bool, 0);
Expand Down Expand Up @@ -184,7 +183,8 @@ static int imx_rngc_init(struct hwrng *rng)
cmd = readl(rngc->base + RNGC_COMMAND);
writel(cmd | RNGC_CMD_SEED, 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,
msecs_to_jiffies(RNGC_SEED_TIMEOUT));
if (!ret) {
ret = -ETIMEDOUT;
goto err;
Expand Down

0 comments on commit 50fb6d5

Please sign in to comment.