From 5188d521f467f1933e925a4e45db770b8a75edaa Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Tue, 4 Jun 2019 09:01:42 -0700 Subject: tpm: reset command_ready bit when entering idle state TPM could enter idle state even when current command has not yet been fully processed (for instance if the AP releases locality at an arbitrary moment). The status register command_ready bit needs to be unconditionally reset when TPM enters idle state. BRANCH=cr50, cr50-mp BUG=none TEST=verified reliable behavior during lengthy concurrent runs of processes accessing TPM. The same type of testing was causing occasional TPM lockups before this fix. Change-Id: I6e1dc334713c666e4ef566d41bd0cbff841f1179 Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1643828 Reviewed-by: Andrey Pronin --- common/tpm_registers.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'common/tpm_registers.c') diff --git a/common/tpm_registers.c b/common/tpm_registers.c index 6a0e7e6ac7..62aa4ce23e 100644 --- a/common/tpm_registers.c +++ b/common/tpm_registers.c @@ -187,9 +187,12 @@ static void set_tpm_state(enum tpm_states state) /* Make sure FIFO is empty. */ tpm_.fifo_read_index = 0; tpm_.fifo_write_index = 0; - tpm_.regs.sts &= ~data_avail; - /* Set burst size for the following write requests. */ - tpm_.regs.sts &= ~(burst_count_mask << burst_count_shift); + /* + * Set proper fields of the status register: FIFO depth 63, + * not ready, no data available. + */ + tpm_.regs.sts &= ~((burst_count_mask << burst_count_shift) | + command_ready | data_avail); tpm_.regs.sts |= 63 << burst_count_shift; } } @@ -283,7 +286,6 @@ static void sts_reg_write_cr(void) case tpm_state_executing_cmd: case tpm_state_receiving_cmd: set_tpm_state(tpm_state_idle); - tpm_.regs.sts &= ~command_ready; break; } } -- cgit v1.2.1