Skip to content

Commit 280db21

Browse files
webmeisterjarkkojs
authored andcommitted
tpm_tis: Resend command to recover from data transfer errors
Similar to the transmission of TPM responses, also the transmission of TPM commands may become corrupted. Instead of aborting when detecting such issues, try resending the command again. Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
1 parent b400f9d commit 280db21

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

drivers/char/tpm/tpm_tis_core.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,10 +539,17 @@ static int tpm_tis_send_main(struct tpm_chip *chip, const u8 *buf, size_t len)
539539
int rc;
540540
u32 ordinal;
541541
unsigned long dur;
542+
unsigned int try;
542543

543-
rc = tpm_tis_send_data(chip, buf, len);
544-
if (rc < 0)
545-
return rc;
544+
for (try = 0; try < TPM_RETRY; try++) {
545+
rc = tpm_tis_send_data(chip, buf, len);
546+
if (rc >= 0)
547+
/* Data transfer done successfully */
548+
break;
549+
else if (rc != -EIO)
550+
/* Data transfer failed, not recoverable */
551+
return rc;
552+
}
546553

547554
/* go and do it */
548555
rc = tpm_tis_write8(priv, TPM_STS(priv->locality), TPM_STS_GO);

0 commit comments

Comments
 (0)