stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Alexander Steffen <Alexander.Steffen@infineon.com>,
	Jarkko Sakkinen <jarkko@kernel.org>,
	Sasha Levin <sashal@kernel.org>,
	peterhuewe@gmx.de, linux-integrity@vger.kernel.org
Subject: [PATCH AUTOSEL 4.14 4/8] tpm_tis: Resend command to recover from data transfer errors
Date: Fri,  8 Sep 2023 14:21:23 -0400	[thread overview]
Message-ID: <20230908182127.3461199-4-sashal@kernel.org> (raw)
In-Reply-To: <20230908182127.3461199-1-sashal@kernel.org>

From: Alexander Steffen <Alexander.Steffen@infineon.com>

[ Upstream commit 280db21e153d8810ce3b93640c63ae922bcb9e8e ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/char/tpm/tpm_tis_core.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index 3255815585096..9d731e2655949 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -364,10 +364,17 @@ static int tpm_tis_send_main(struct tpm_chip *chip, const u8 *buf, size_t len)
 	int rc;
 	u32 ordinal;
 	unsigned long dur;
-
-	rc = tpm_tis_send_data(chip, buf, len);
-	if (rc < 0)
-		return rc;
+	unsigned int try;
+
+	for (try = 0; try < TPM_RETRY; try++) {
+		rc = tpm_tis_send_data(chip, buf, len);
+		if (rc >= 0)
+			/* Data transfer done successfully */
+			break;
+		else if (rc != -EIO)
+			/* Data transfer failed, not recoverable */
+			return rc;
+	}
 
 	/* go and do it */
 	rc = tpm_tis_write8(priv, TPM_STS(priv->locality), TPM_STS_GO);
-- 
2.40.1


  parent reply	other threads:[~2023-09-08 18:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-08 18:21 [PATCH AUTOSEL 4.14 1/8] wifi: ath9k: fix printk specifier Sasha Levin
2023-09-08 18:21 ` [PATCH AUTOSEL 4.14 2/8] wifi: mwifiex: fix fortify warning Sasha Levin
2023-09-08 18:21 ` [PATCH AUTOSEL 4.14 3/8] crypto: lib/mpi - avoid null pointer deref in mpi_cmp_ui() Sasha Levin
2023-09-08 18:21 ` Sasha Levin [this message]
2023-09-08 18:21 ` [PATCH AUTOSEL 4.14 5/8] alx: fix OOB-read compiler warning Sasha Levin
2023-09-08 18:21 ` [PATCH AUTOSEL 4.14 6/8] netfilter: ebtables: fix fortify warnings in size_entry_mwt() Sasha Levin
2023-09-11  9:36   ` Pavel Machek
2023-09-08 18:21 ` [PATCH AUTOSEL 4.14 7/8] wifi: cfg80211: ocb: don't leave if not joined Sasha Levin
2023-09-11  9:38   ` Pavel Machek
2023-09-08 18:21 ` [PATCH AUTOSEL 4.14 8/8] Bluetooth: btusb: Fix quirks table naming Sasha Levin
2023-09-11  9:40   ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230908182127.3461199-4-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=Alexander.Steffen@infineon.com \
    --cc=jarkko@kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).