From 9776cb83b194adf8571be16da0ec6b51f67d54d8 Mon Sep 17 00:00:00 2001 From: Mary Ruthven Date: Thu, 21 Jan 2021 14:55:58 +1100 Subject: Reland "trng: change TRNG_EMPTY_COUNT to 0x7ff" This is a reland of 2ec3f05cb79ee3ec00ec2a3e3a70cbecd5f1382b Original change's description: > trng: change TRNG_EMPTY_COUNT to 0x7ff > > Increase TRNG_EMPTY_COUNT, so boards with slow TRNG have enough time to > generate a sample. > > BUG=b:172542178,b:178116958 > TEST=generate RSA keys 50 times on the hatch with slow TRNG. Verify the > average time is around 6 seconds. > > Change-Id: I1b821286e1e4b5da8baa59caeda907ab3fe49f81 > Signed-off-by: Mary Ruthven > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2641744 > Reviewed-by: Andrey Pronin > Reviewed-by: Vadim Sukhomlinov > (cherry picked from commit 88b7c50e717211fbced47709e78a9e95c91ce533) > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2669410 > (cherry picked from commit 1d41ad204955874b96248ace0d288535d86b2495) > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2713839 Bug: b:172542178 Bug: b:178116958 Change-Id: Ia9062b217420a41b9dce067fa9e3f305ef037e75 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2718508 Tested-by: Mary Ruthven Reviewed-by: Mary Ruthven Commit-Queue: Mary Ruthven --- chip/g/trng.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/chip/g/trng.c b/chip/g/trng.c index e817034937..94363b29c4 100644 --- a/chip/g/trng.c +++ b/chip/g/trng.c @@ -32,11 +32,12 @@ #endif /** - * Attempts to read TRNG_EMPTY before reporting a stall. - * Practically data should be available in less than 777 - * cycles under normal conditions. + * Attempts to read TRNG_EMPTY before reporting a stall. Practically data should + * be available in less than 0x7ff cycles under normal conditions. 0x7ff was + * chosen to match the hardware TRNG TIMEOUT_COUNTER. Test on boards with slow + * TRNG before reducing this number. */ -#define TRNG_EMPTY_COUNT 777 +#define TRNG_EMPTY_COUNT 0x7ff void init_trng(void) { -- cgit v1.2.1