summaryrefslogtreecommitdiff
path: root/drivers/char/tpm/tpm-interface.c
diff options
context:
space:
mode:
authorNayna Jain <nayna@linux.vnet.ibm.com>2018-04-02 21:50:06 +0530
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>2018-05-09 14:45:46 +0300
commit92980756979a9c51be0275f395f4e89c42cf199a (patch)
treeeaa9d1445a332e906e6891fadfae3470f66329e2 /drivers/char/tpm/tpm-interface.c
parent5859cdf55063943192f316b3d6c673fd6fcbee46 (diff)
tpm: move the delay_msec increment after sleep in tpm_transmit()
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>
Diffstat (limited to 'drivers/char/tpm/tpm-interface.c')
-rw-r--r--drivers/char/tpm/tpm-interface.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index c43a9e28995e..6201aab374e6 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -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;