]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
hwrng: cavium - Check health status while reading random data
authorSunil Goutham <sgoutham@marvell.com>
Fri, 29 Oct 2021 17:19:59 +0000 (22:49 +0530)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 27 Apr 2022 09:56:52 +0000 (11:56 +0200)
commit2f700c139fef7e1a5e41ff15563b8a1099f8e493
tree56caeaaaf8bb3c529ad869af70e9cfb05f524c56
parent6a4592552dc842091926c472f92e7223c01de82f
hwrng: cavium - Check health status while reading random data

BugLink: https://bugs.launchpad.net/bugs/1969110
[ Upstream commit 680efb33546be8960ccbb2f4e0e43034d9c93b30 ]

This RNG device is present on Marvell OcteonTx2 silicons as well and
also provides entropy health status.

HW continuously checks health condition of entropy and reports
faults. Fault is in terms of co-processor cycles since last fault
detected. This doesn't get cleared and only updated when new fault
is detected. Also there are chances of detecting false positives.
So to detect a entropy failure SW has to check if failures are
persistent ie cycles elapsed is frequently updated by HW.

This patch adds support to detect health failures using below algo.
1. Consider any fault detected before 10ms as a false positive and ignore.
   10ms is chosen randomly, no significance.
2. Upon first failure detection make a note of cycles elapsed and when this
   error happened in realtime (cntvct).
3. Upon subsequent failure, check if this is new or a old one by comparing
   current cycles with the ones since last failure. cycles or time since
   last failure is calculated using cycles and time info captured at (2).

HEALTH_CHECK status register is not available to VF, hence had to map
PF registers. Also since cycles are in terms of co-processor cycles,
had to retrieve co-processor clock rate from RST device.

Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 7919dfd84b352782df92c1ff2f0ca4dd5328d198)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/char/hw_random/Kconfig
drivers/char/hw_random/cavium-rng-vf.c
drivers/char/hw_random/cavium-rng.c