From 765c8930024f104a659a47773e55d19dc868f6d4 Mon Sep 17 00:00:00 2001 From: Andrei Nistor Date: Sat, 28 Nov 2026 21:26:43 +0200 Subject: [PATCH] hwrng: nvt-rng: set a quality so the core feeds the entropy pool The driver registers its hwrng with no quality. The hw_random core starts the hwrng fill thread only when the selected generator has a quality above zero or rng_core.default_quality is set, and that thread is the only path that credits generator output to the entropy pool. With a quality of zero the kernel never reads the generator on its own, and a system with no saved seed waits for interrupt entropy. On a quiet board the pool stays uninitialised, getrandom() blocks, and services that need random numbers at start, such as dropbear and majestic, never open their ports. Set the quality to 500, which credits about half of the bits read. The block is a ring oscillator followed by a CASR and a post-processing stage. The Novatek sources give no entropy rate for it, and the driver reads the data register back to back with no pacing. The block offers no per-word handshake to pace on. Measured on hardware, RNG_TDES_DONE is set in about one control register read in ten, clears by itself whether or not the data register is read, and is found clear after the block has been idle for milliseconds, while 800000 data words read back to back in four runs, most of them with the bit clear, contain no repeated neighbour. The other drivers in this tree that set a quality use 900 to 1000, so half credit is a conservative figure for a generator with no documented rate. The lower value costs nothing at boot, because the first reads go to crng_fast_load() whatever the credit and the pool is ready a few milliseconds after the driver registers. Tested on a Reolink E340 (NT98566) started by kexec with no rng_core parameter. The hwrng thread runs, "random: crng init done" is logged at 0.74 s, 10 ms after the driver registers, and both RTSP streams deliver. In QEMU with a model of the generator and a root filesystem with no saved seed, the pool is ready at 0.12 s and the streamer serves video. The same image with the unpatched kernel has not initialised the pool after 170 s. Co-Authored-By: Claude Fable 5.2 --- drivers/char/hw_random/nvt-rng.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/char/hw_random/nvt-rng.c b/drivers/char/hw_random/nvt-rng.c index 406e9631af0..e992ec36088 100644 --- a/drivers/char/hw_random/nvt-rng.c +++ b/drivers/char/hw_random/nvt-rng.c @@ -122,6 +122,12 @@ static int nvt_rng_probe(struct platform_device *pdev) rng->rng.init = nvt_rng_init; rng->rng.cleanup = nvt_rng_cleanup; rng->rng.read = nvt_rng_read; + /* + * The entropy rate of the oscillator behind the CASR and the + * post-processing stage is undocumented, and reads are unpaced, + * so credit half of what is read. + */ + rng->rng.quality = 500; ret = devm_hwrng_register(&pdev->dev, &rng->rng); if (ret) {