Skip to content

Commit

Permalink
hwrng: omap - Fix RNG wait loop timeout
Browse files Browse the repository at this point in the history
Existing RNG data read timeout is 200us but it doesn't cover EIP76 RNG
data rate which takes approx. 700us to produce 16 bytes of output data
as per testing results. So configure the timeout as 1000us to also take
account of lack of udelay()'s reliability.

Fixes: 3832124 ("hwrng: omap - Add device variant for SafeXcel IP-76 found in Armada 8K")
Cc: <[email protected]>
Signed-off-by: Sumit Garg <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
b49020 authored and herbertx committed Oct 25, 2019
1 parent e9fc367 commit be867f9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/char/hw_random/omap-rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@
#define OMAP4_RNG_OUTPUT_SIZE 0x8
#define EIP76_RNG_OUTPUT_SIZE 0x10

/*
* EIP76 RNG takes approx. 700us to produce 16 bytes of output data
* as per testing results. And to account for the lack of udelay()'s
* reliability, we keep the timeout as 1000us.
*/
#define RNG_DATA_FILL_TIMEOUT 100

enum {
RNG_OUTPUT_0_REG = 0,
RNG_OUTPUT_1_REG,
Expand Down Expand Up @@ -176,7 +183,7 @@ static int omap_rng_do_read(struct hwrng *rng, void *data, size_t max,
if (max < priv->pdata->data_size)
return 0;

for (i = 0; i < 20; i++) {
for (i = 0; i < RNG_DATA_FILL_TIMEOUT; i++) {
present = priv->pdata->data_present(priv);
if (present || !wait)
break;
Expand Down

0 comments on commit be867f9

Please sign in to comment.