]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
tpm: read burstcount from TPM_STS in one 32-bit transaction
authorAndrey Pronin <apronin@chromium.org>
Thu, 30 Jun 2016 17:25:43 +0000 (10:25 -0700)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tue, 19 Jul 2016 14:43:38 +0000 (17:43 +0300)
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>
drivers/char/tpm/tpm_tis_core.c

index ace95b39566f25e575c51fb4c55e109781690e5a..fb8c3de557469088a2b41cc4066a7746eb305a75 100644 (file)
@@ -157,22 +157,17 @@ static int get_burstcount(struct tpm_chip *chip)
        struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
        unsigned long stop;
        int burstcnt, rc;
-       u8 value;
+       u32 value;
 
        /* wait for burstcount */
        /* which timeout value, spec has 2 answers (c & d) */
        stop = jiffies + chip->timeout_d;
        do {
-               rc = tpm_tis_read8(priv, TPM_STS(priv->locality) + 1, &value);
+               rc = tpm_tis_read32(priv, TPM_STS(priv->locality), &value);
                if (rc < 0)
                        return rc;
 
-               burstcnt = value;
-               rc = tpm_tis_read8(priv, TPM_STS(priv->locality) + 2, &value);
-               if (rc < 0)
-                       return rc;
-
-               burstcnt += value << 8;
+               burstcnt = (value >> 8) & 0xFFFF;
                if (burstcnt)
                        return burstcnt;
                msleep(TPM_TIMEOUT);