From d6d12ec67bb0d20229ee0c273bc9d917b0821eb4 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Mon, 26 Sep 2016 15:47:16 -0700 Subject: cr50: tpm: ignore sys_rst_l/plt_rst_l when TPM reset is in progress There is no point in invoking TPM reset while the current invocation is in progress. One of the cases when this is happening is early start up on Kevin/Gru: the device starts booting, the EC comes around to pulsing sys_rst_l when TPM is already busy installing endorsement certificates. There is no point in issuing another reset at that point, just let the process continue. BRANCH=none BUG=chrome-os-partner:52366 TEST=firmware_TPMKernelVersion firmware_TPMExtend autotests still pass on kevin. Certificate installation during startup does not get interrupted any more. Change-Id: Ibdface9f7a76186e210ef0f4111cd5fe9905bba9 Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/389811 Reviewed-by: Bill Richardson --- board/cr50/board.c | 8 ++++++-- common/tpm_registers.c | 7 ++++++- include/tpm_registers.h | 7 +++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/board/cr50/board.c b/board/cr50/board.c index e370973778..b232633a87 100644 --- a/board/cr50/board.c +++ b/board/cr50/board.c @@ -390,9 +390,13 @@ void sys_rst_asserted(enum gpio_signal signal) * Cr50 drives SYS_RST_L in certain scenarios, in those cases * this signal's assertion should be ignored here. */ - CPRINTS("%s", __func__); - if (usb_spi_update_in_progress() || is_sys_rst_asserted()) + CPRINTS("%s from %d", __func__, signal); + if (usb_spi_update_in_progress() || + is_sys_rst_asserted() || + tpm_is_resetting()) { + CPRINTS("%s ignored", __func__); return; + } /* Re-initialize the TPM software state */ tpm_reset(); diff --git a/common/tpm_registers.c b/common/tpm_registers.c index a2bdec4925..0e2733b472 100644 --- a/common/tpm_registers.c +++ b/common/tpm_registers.c @@ -625,6 +625,11 @@ int tpm_reset(void) return 1; } +int tpm_is_resetting(void) +{ + return reset_in_progress; +} + static void tpm_reset_now(void) { reset_in_progress = 1; @@ -659,7 +664,7 @@ static void tpm_reset_now(void) void tpm_task(void) { - tpm_init(); + tpm_reset_now(); while (1) { uint8_t *response; unsigned response_size; diff --git a/include/tpm_registers.h b/include/tpm_registers.h index 9c9390ffb7..dfdfefdc34 100644 --- a/include/tpm_registers.h +++ b/include/tpm_registers.h @@ -41,6 +41,13 @@ void tpm_register_interface(interface_restart_func interface_restart); */ int tpm_reset(void); +/* + * Return true if tpm is being reset. Usually this helps to avoid unnecessary + * extra reset early at startup time, when TPM could be busy installing + * endorsement certificates. + */ +int tpm_is_resetting(void); + /* * This structure describes the header of all commands and responses sent and * received over TPM FIFO. -- cgit v1.2.1