From 0c649ba01ab555e84ab030b7f1a38c48b294bbe2 Mon Sep 17 00:00:00 2001 From: Vadim Sukhomlinov Date: Thu, 18 Jun 2020 09:09:04 -0700 Subject: trng: adjust TRNG timeout to reduce TRNG resets Time it takes for TRNG to come-up with 32-bit of randomness varies, and once TRNG started to use 1-bit alphabet, it's average increased. We handle this timeout by resetting TRNG and writing record in the flash log. With current setting of EMPTY_COUNT set to 400 it's almost never happens under normal use, and is harmless, but adds unnecessary records in the log under heavy use like TRNG health tests. Adjusting EMPTY_COUNT to higher value reduce probability of TRNG reset when value is just delayed, but TRNG is not stalled yet. BUG=b:138578157 TEST=tpmtest -t0 Signed-off-by: Vadim Sukhomlinov Change-Id: Ic0152da05934a70dd16b3e4178361bfcefbdda26 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2252481 Reviewed-by: Vadim Sukhomlinov Reviewed-by: William Wesson Reviewed-by: Vadim Bendebury Auto-Submit: Vadim Sukhomlinov Commit-Queue: Vadim Sukhomlinov Commit-Queue: Vadim Bendebury Tested-by: Vadim Sukhomlinov --- chip/g/trng.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chip/g/trng.c b/chip/g/trng.c index b64c3c7dbe..e817034937 100644 --- a/chip/g/trng.c +++ b/chip/g/trng.c @@ -33,10 +33,10 @@ /** * Attempts to read TRNG_EMPTY before reporting a stall. - * Practically data should be available in less than 400 + * Practically data should be available in less than 777 * cycles under normal conditions. */ -#define TRNG_EMPTY_COUNT 400 +#define TRNG_EMPTY_COUNT 777 void init_trng(void) { -- cgit v1.2.1