diff options
| author | Alexander Steffen <Alexander.Steffen@infineon.com> | 2017-02-16 10:33:36 -0500 |
|---|---|---|
| committer | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> | 2017-04-03 15:46:00 -0400 |
| commit | 302a6ad7fc77146191126a1f3e2c5d724fd72416 (patch) | |
| tree | e7ef7a74c31397af36adc955176e3b1b298c87c9 | |
| parent | ddb99e118e37f324a4be65a411bb60ae62795cf9 (diff) | |
tpm_tis_core: Choose appropriate timeout for reading burstcount
TIS v1.3 for TPM 1.2 and PTP for TPM 2.0 disagree about which timeout
value applies to reading a valid burstcount. It is TIMEOUT_D according to
TIS, but TIMEOUT_A according to PTP, so choose the appropriate value
depending on whether we deal with a TPM 1.2 or a TPM 2.0.
This is important since according to the PTP TIMEOUT_D is much smaller
than TIMEOUT_A. So the previous implementation could run into timeouts
with a TPM 2.0, even though the TPM was behaving perfectly fine.
During tpm2_probe TIMEOUT_D will be used even with a TPM 2.0, because
TPM_CHIP_FLAG_TPM2 is not yet set. This is fine, since the timeout values
will only be changed afterwards by tpm_get_timeouts. Until then
TIS_TIMEOUT_D_MAX applies, which is large enough.
Cc: stable@vger.kernel.org
Fixes: aec04cbdf723 ("tpm: TPM 2.0 FIFO Interface")
Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
Signed-off-by: Peter Huewe <peter.huewe@infineon.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
| -rw-r--r-- | drivers/char/tpm/tpm_tis_core.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index c0f296b5d413..fc0e9a2734ed 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c | |||
| @@ -160,8 +160,10 @@ static int get_burstcount(struct tpm_chip *chip) | |||
| 160 | u32 value; | 160 | u32 value; |
| 161 | 161 | ||
| 162 | /* wait for burstcount */ | 162 | /* wait for burstcount */ |
| 163 | /* which timeout value, spec has 2 answers (c & d) */ | 163 | if (chip->flags & TPM_CHIP_FLAG_TPM2) |
| 164 | stop = jiffies + chip->timeout_d; | 164 | stop = jiffies + chip->timeout_a; |
| 165 | else | ||
| 166 | stop = jiffies + chip->timeout_d; | ||
| 165 | do { | 167 | do { |
| 166 | rc = tpm_tis_read32(priv, TPM_STS(priv->locality), &value); | 168 | rc = tpm_tis_read32(priv, TPM_STS(priv->locality), &value); |
| 167 | if (rc < 0) | 169 | if (rc < 0) |
