]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
hwrng: omap - Fix RNG wait loop timeout
authorSumit Garg <sumit.garg@linaro.org>
Mon, 14 Oct 2019 12:02:45 +0000 (17:32 +0530)
committerMarcelo Henrique Cerri <marcelo.cerri@canonical.com>
Fri, 17 Jan 2020 17:23:49 +0000 (14:23 -0300)
BugLink: https://bugs.launchpad.net/bugs/1856869
commit be867f987a4e1222114dd07a01838a17c26f3fff upstream.

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: 383212425c92 ("hwrng: omap - Add device variant for SafeXcel IP-76 found in Armada 8K")
Cc: <stable@vger.kernel.org>
Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Connor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/char/hw_random/omap-rng.c

index e9b6ac61fb7f64953e988c130d53f518ca3e7ab0..49882524263421bdefea2ec69cd304eaf98a02c9 100644 (file)
 #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,
@@ -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;