]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
hwrng: bcm2835 - Fix hwrng throughput regression
authorStefan Wahren <wahrenst@gmx.net>
Tue, 5 Sep 2023 23:27:57 +0000 (01:27 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Nov 2023 10:52:04 +0000 (11:52 +0100)
commit3c5c7f926a4b63018a754584e81a0174ed67343c
tree69d4a097256af9936dd391ff6c89dbb16dac6ab2
parent0c824b77ad480475136800f4f522e057d668f74e
hwrng: bcm2835 - Fix hwrng throughput regression

[ Upstream commit b58a36008bfa1aadf55f516bcbfae40c779eb54b ]

The last RCU stall fix caused a massive throughput regression of the
hwrng on Raspberry Pi 0 - 3. hwrng_msleep doesn't sleep precisely enough
and usleep_range doesn't allow scheduling. So try to restore the
best possible throughput by introducing hwrng_yield which interruptable
sleeps for one jiffy.

Some performance measurements on Raspberry Pi 3B+ (arm64/defconfig):

sudo dd if=/dev/hwrng of=/dev/null count=1 bs=10000

cpu_relax              ~138025 Bytes / sec
hwrng_msleep(1000)         ~13 Bytes / sec
hwrng_yield              ~2510 Bytes / sec

Fixes: 96cb9d055445 ("hwrng: bcm2835 - use hwrng_msleep() instead of cpu_relax()")
Link: https://lore.kernel.org/linux-arm-kernel/bc97ece5-44a3-4c4e-77da-2db3eb66b128@gmx.net/
Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/char/hw_random/bcm2835-rng.c
drivers/char/hw_random/core.c
include/linux/hw_random.h