]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
tpm: move the delay_msec increment after sleep in tpm_transmit()
authorNayna Jain <nayna@linux.vnet.ibm.com>
Mon, 2 Apr 2018 16:20:06 +0000 (21:50 +0530)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Wed, 9 May 2018 11:45:46 +0000 (14:45 +0300)
Commit e2fb992d82c6 ("tpm: add retry logic") introduced a new loop to
handle the TPM2_RC_RETRY error. The loop retries the command after
sleeping for the specified time, which is incremented exponentially in
every iteration.

Unfortunately, the loop doubles the time before sleeping, causing the
initial sleep to be doubled. This patch fixes the initial sleep time.

Fixes: commit e2fb992d82c6 ("tpm: add retry logic")
Signed-off-by: Nayna Jain <nayna@linux.vnet.ibm.com>
Reviewed-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
drivers/char/tpm/tpm-interface.c

index c43a9e28995eb2f03911504fe125523e86ccd107..6201aab374e6ac35da76bb57c1a54cbe860bc1ac 100644 (file)
@@ -587,7 +587,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space,
                 */
                if (rc == TPM2_RC_TESTING && cc == TPM2_CC_SELF_TEST)
                        break;
-               delay_msec *= 2;
+
                if (delay_msec > TPM2_DURATION_LONG) {
                        if (rc == TPM2_RC_RETRY)
                                dev_err(&chip->dev, "in retry loop\n");
@@ -597,6 +597,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space,
                        break;
                }
                tpm_msleep(delay_msec);
+               delay_msec *= 2;
                memcpy(buf, save, save_size);
        }
        return ret;