diff options
author | Mary Ruthven <mruthven@chromium.org> | 2019-04-24 11:20:51 -0700 |
---|---|---|
committer | Vadim Bendebury <vbendeb@chromium.org> | 2019-09-21 19:11:18 -0700 |
commit | ff61eb24f668118e5d84cf6c2ea19feecf90b447 (patch) | |
tree | 82baa948907f0a3cb3067168a139ec6c811afe26 | |
parent | 92fb82fc9b543d06c38d96195a094801d268b60a (diff) | |
download | chrome-ec-ff61eb24f668118e5d84cf6c2ea19feecf90b447.tar.gz |
ccd: delay sleep while opening ccd
Cr50 may enter deep sleep while wiping the TPM. This change adds a sleep
delay before opening ccd.
BUG=b:130646257
BRANCH=cr50
TEST=manual
dut-control cold_reset:on
run ccd open
make sure ccd is open even after entering deep sleep
Change-Id: Id44b608702b664621bd2441f62a03ba6428135cf
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1585606
Reviewed-by: Namyoon Woo <namyoon@chromium.org>
(cherry picked from commit 0f25f85e44362e7feb15ce59974f0423abab0b5f)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1595415
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
(cherry picked from commit 892d0d99658beb67e17ac07208d16789cf313952)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1644520
(cherry picked from commit 68fd3780d72b2f1fb9d30d8de4dfec57d14be37f)
-rw-r--r-- | board/cr50/board.h | 15 | ||||
-rw-r--r-- | common/ccd_config.c | 6 | ||||
-rw-r--r-- | common/factory_mode.c | 21 |
3 files changed, 26 insertions, 16 deletions
diff --git a/board/cr50/board.h b/board/cr50/board.h index be0e378dbe..e44a2e4f77 100644 --- a/board/cr50/board.h +++ b/board/cr50/board.h @@ -438,4 +438,19 @@ enum nvmem_users { #define CONFIG_USB_I2C_MAX_WRITE_COUNT 508 #define CONFIG_USB_I2C_MAX_READ_COUNT 506 +/* The below time constants are way longer than should be required in practice: + * + * Time it takes to finish processing TPM command + */ +#define TPM_PROCESSING_TIME (1 * SECOND) + +/* + * Time it takse TPM reset function to wipe out the NVMEM and reboot the + * device. + */ +#define TPM_RESET_TIME (10 * SECOND) + +/* Total time deep sleep should not be allowed while wiping the TPM. */ +#define DISABLE_SLEEP_TIME_TPM_WIPE (TPM_PROCESSING_TIME + TPM_RESET_TIME) + #endif /* __CROS_EC_BOARD_H */ diff --git a/common/ccd_config.c b/common/ccd_config.c index e8bbf71002..00393326bf 100644 --- a/common/ccd_config.c +++ b/common/ccd_config.c @@ -560,6 +560,12 @@ static void ccd_open_done(int sync) { int rv; + /* + * Wiping the TPM may take a while. Delay sleep long enough for the + * open process to finish. + */ + delay_sleep_by(DISABLE_SLEEP_TIME_TPM_WIPE); + if (!ccd_is_cap_enabled(CCD_CAP_OPEN_WITHOUT_TPM_WIPE)) { /* Can't open unless wipe succeeds */ if (sync) diff --git a/common/factory_mode.c b/common/factory_mode.c index c497a212fe..6a4d4cf479 100644 --- a/common/factory_mode.c +++ b/common/factory_mode.c @@ -46,21 +46,6 @@ static void factory_enable_failed(void) } DECLARE_DEFERRED(factory_enable_failed); -/* The below time constants are way longer than should be required in practice: - * - * Time it takes to finish processing TPM command - */ -#define TPM_PROCESSING_TIME (1 * SECOND) - -/* - * Time it takse TPM reset function to wipe out the NVMEM and reboot the - * device. - */ -#define TPM_RESET_TIME (10 * SECOND) - -/* Total time deep sleep should not be allowed. */ -#define DISABLE_SLEEP_TIME (TPM_PROCESSING_TIME + TPM_RESET_TIME) - static void factory_enable_deferred(void) { int rv; @@ -114,7 +99,11 @@ DECLARE_DEFERRED(factory_enable_deferred); void enable_ccd_factory_mode(int reset_required) { - delay_sleep_by(DISABLE_SLEEP_TIME); + /* + * Wiping the TPM may take a while. Delay sleep long enough for the + * factory enable process to finish. + */ + delay_sleep_by(DISABLE_SLEEP_TIME_TPM_WIPE); reset_required_ = !!reset_required; hook_call_deferred(&factory_enable_deferred_data, |