* [PATCH v2 1/2] tpm: tpm_tis: add error logging for data transfer
2026-04-11 0:32 [PATCH v2 0/2] tpm_tis: fix retry exhaustion and add logging Jacqueline Wong
@ 2026-04-11 0:32 ` Jacqueline Wong
2026-04-11 0:33 ` [PATCH v2 2/2] tpm: tpm_tis: stop transmit if retries are exhausted Jacqueline Wong
2026-04-15 2:40 ` [PATCH v2 0/2] tpm_tis: fix retry exhaustion and add logging Jarkko Sakkinen
2 siblings, 0 replies; 4+ messages in thread
From: Jacqueline Wong @ 2026-04-11 0:32 UTC (permalink / raw)
To: linux-integrity
Cc: jarkko, peterhuewe, jgg, axelrasmussen, Jacqueline Wong,
Jordan Hand
Add logging to more easily determine reason for transmit failure
Fixes: 280db21e153d8 ("tpm_tis: Resend command to recover from data transfer errors")
Signed-off-by: Jacqueline Wong <jacqwong@google.com>
Signed-off-by: Jordan Hand <jhand@google.com>
---
drivers/char/tpm/tpm_tis_core.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index e2a1769081b1..c79b696086fe 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -471,6 +471,8 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
status = tpm_tis_status(chip);
if (!itpm && (status & TPM_STS_DATA_EXPECT) == 0) {
rc = -EIO;
+ dev_err(&chip->dev, "TPM_STS_DATA_EXPECT should be set. sts = 0x%08x\n",
+ status);
goto out_err;
}
}
@@ -491,6 +493,8 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
status = tpm_tis_status(chip);
if (!itpm && (status & TPM_STS_DATA_EXPECT) != 0) {
rc = -EIO;
+ dev_err(&chip->dev, "TPM_STS_DATA_EXPECT should be unset. sts = 0x%08x\n",
+ status);
goto out_err;
}
--
2.53.0.1213.gd9a14994de-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH v2 2/2] tpm: tpm_tis: stop transmit if retries are exhausted
2026-04-11 0:32 [PATCH v2 0/2] tpm_tis: fix retry exhaustion and add logging Jacqueline Wong
2026-04-11 0:32 ` [PATCH v2 1/2] tpm: tpm_tis: add error logging for data transfer Jacqueline Wong
@ 2026-04-11 0:33 ` Jacqueline Wong
2026-04-15 2:40 ` [PATCH v2 0/2] tpm_tis: fix retry exhaustion and add logging Jarkko Sakkinen
2 siblings, 0 replies; 4+ messages in thread
From: Jacqueline Wong @ 2026-04-11 0:33 UTC (permalink / raw)
To: linux-integrity
Cc: jarkko, peterhuewe, jgg, axelrasmussen, Jacqueline Wong,
Jordan Hand
tpm_tis_send_main() will attempt to retry sending data TPM_RETRY times.
Currently, if those retries are exhausted, the driver will attempt to
call execute. The TPM will be in the wrong state, leading to the
operation simply timing out.
Instead, if there is still an error after retries are exhausted, return
that error immediately.
Fixes: 280db21e153d8 ("tpm_tis: Resend command to recover from data transfer errors")
Signed-off-by: Jacqueline Wong <jacqwong@google.com>
Signed-off-by: Jordan Hand <jhand@google.com>
---
drivers/char/tpm/tpm_tis_core.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index c79b696086fe..ecda3c1085c7 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -556,11 +556,16 @@ static int tpm_tis_send_main(struct tpm_chip *chip, const u8 *buf, size_t len)
break;
else if (rc != -EAGAIN && rc != -EIO)
/* Data transfer failed, not recoverable */
- return rc;
+ goto out_err;
usleep_range(priv->timeout_min, priv->timeout_max);
}
+ if (rc == -EAGAIN || rc == -EIO) {
+ dev_err(&chip->dev, "Exhausted %d tpm_tis_send_data retries\n", TPM_RETRY);
+ goto out_err;
+ }
+
/* go and do it */
rc = tpm_tis_write8(priv, TPM_STS(priv->locality), TPM_STS_GO);
if (rc < 0)
--
2.53.0.1213.gd9a14994de-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2 0/2] tpm_tis: fix retry exhaustion and add logging
2026-04-11 0:32 [PATCH v2 0/2] tpm_tis: fix retry exhaustion and add logging Jacqueline Wong
2026-04-11 0:32 ` [PATCH v2 1/2] tpm: tpm_tis: add error logging for data transfer Jacqueline Wong
2026-04-11 0:33 ` [PATCH v2 2/2] tpm: tpm_tis: stop transmit if retries are exhausted Jacqueline Wong
@ 2026-04-15 2:40 ` Jarkko Sakkinen
2 siblings, 0 replies; 4+ messages in thread
From: Jarkko Sakkinen @ 2026-04-15 2:40 UTC (permalink / raw)
To: Jacqueline Wong; +Cc: linux-integrity, peterhuewe, jgg, axelrasmussen
On Sat, Apr 11, 2026 at 12:32:58AM +0000, Jacqueline Wong wrote:
> The Fix:
> - Patch 1: Adds error logs to identify the specific hardware status mismatch.
> - Patch 2: Stops execution immediately when retries are exhausted.
>
> v2 changes:
> - Split logging and logic into separate patches.
> - Added retry count to the error message.
> - Included dmesg traces below.
>
> Testing:
> Dmesg traces obtained using error injection to simulate status register mismatches.
>
> Before:
> [ 130.288751] tpm tpm0: Operation Timed out
> [ 250.306070] tpm tpm0: Operation Timed out
> [ 250.310173] tpm tpm0: A TPM error (-62) occurred attempting to determine the timeouts
>
> After:
> [ 10.271547] tpm tpm0: TPM_STS_DATA_EXPECT should be unset. sts = 0x00000080
> ...
> [ 10.646283] tpm tpm0: TPM_STS_DATA_EXPECT should be unset. sts = 0x00000080
> [ 10.653461] tpm tpm0: Exhausted 50 tpm_tis_send_data retries
> [ 10.659304] tpm tpm0: tpm_try_transmit: send(): error -5
> [ 10.665435] tpm tpm0: TPM_STS_DATA_EXPECT should be unset. sts = 0x00000080
> ...
> [ 11.037198] tpm tpm0: TPM_STS_DATA_EXPECT should be unset. sts = 0x00000080
> [ 11.044441] tpm tpm0: Exhausted 50 tpm_tis_send_data retries
> [ 11.050288] tpm tpm0: tpm_try_transmit: send(): error -5
> [ 11.055723] tpm tpm0: A TPM error (-5) occurred attempting to determine the timeouts
>
> Jacqueline Wong (2):
> tpm: tpm_tis: add error logging for data transfer
> tpm: tpm_tis: stop transmit if retries are exhausted
>
> drivers/char/tpm/tpm_tis_core.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> --
> 2.53.0.1213.gd9a14994de-goog
>
OK, I dropped the patch that as I applied as I did not see this :-)
Now that we are cycling, please send v3 with checkpatch --strict passing
BR, Jarkko
^ permalink raw reply [flat|nested] 4+ messages in thread