aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Pronin <apronin@chromium.org>2016-06-30 13:25:43 -0400
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>2016-07-19 10:43:38 -0400
commit9754d45e997000ad4021bc4606cc266bb38d876f (patch)
tree1d4cd24830105e0ea9c14bc6bb6bc11ee23995c3
parent1b0612b04090e416828c0dd5ed197b0913d834a0 (diff)
tpm: read burstcount from TPM_STS in one 32-bit transaction
Some chips incorrectly support partial reads from TPM_STS register at non-zero offsets. Read the entire 32-bits register instead of making two 8-bit reads to support such devices and reduce the number of bus transactions when obtaining the burstcount from TPM_STS. Fixes: 27084efee0c3 ("tpm: driver for next generation TPM chips") Signed-off-by: Andrey Pronin <apronin@chromium.org> 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.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index ace95b39566f..fb8c3de55746 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -157,22 +157,17 @@ static int get_burstcount(struct tpm_chip *chip)
157 struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); 157 struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
158 unsigned long stop; 158 unsigned long stop;
159 int burstcnt, rc; 159 int burstcnt, rc;
160 u8 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 /* which timeout value, spec has 2 answers (c & d) */
164 stop = jiffies + chip->timeout_d; 164 stop = jiffies + chip->timeout_d;
165 do { 165 do {
166 rc = tpm_tis_read8(priv, TPM_STS(priv->locality) + 1, &value); 166 rc = tpm_tis_read32(priv, TPM_STS(priv->locality), &value);
167 if (rc < 0) 167 if (rc < 0)
168 return rc; 168 return rc;
169 169
170 burstcnt = value; 170 burstcnt = (value >> 8) & 0xFFFF;
171 rc = tpm_tis_read8(priv, TPM_STS(priv->locality) + 2, &value);
172 if (rc < 0)
173 return rc;
174
175 burstcnt += value << 8;
176 if (burstcnt) 171 if (burstcnt)
177 return burstcnt; 172 return burstcnt;
178 msleep(TPM_TIMEOUT); 173 msleep(TPM_TIMEOUT);