]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
hwrng: optee - handle unlimited data rates
authorJorge Ramirez-Ortiz <jorge@foundries.io>
Thu, 6 Aug 2020 10:00:09 +0000 (12:00 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 21 Aug 2020 04:45:28 +0000 (14:45 +1000)
Data rates of MAX_UINT32 will schedule an unnecessary one jiffy
timeout on the call to msleep. Avoid this scenario by using 0 as the
unlimited data rate.

Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/char/hw_random/optee-rng.c

index 49b2e02537ddb729395be08d83fbe95a3e50db17..5bc4700c4dae1a615106cfddf0551ec944e5f86c 100644 (file)
@@ -128,7 +128,7 @@ static int optee_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
                data += rng_size;
                read += rng_size;
 
-               if (wait) {
+               if (wait && pvt_data->data_rate) {
                        if (timeout-- == 0)
                                return read;
                        msleep((1000 * (max - read)) / pvt_data->data_rate);