tpm_tis: fix retry exhaustion and add logging
Subsystems (2)
v3 cover tpm_tis: fix retry exhaustion and add logging
The Fix:
- Patch 1: Adds error logs to identify the specific hardware status mismatch.
- Patch 2: Stops execution immediately when retries are exhausted.
v3 changes:
- Improved code alignment to pass checkpatch --strict.
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(-)
Signature · 1 line
2.54.0.rc0.605.g598a273b03-goog
PATCH v3 1/2 tpm: tpm_tis: add error logging for data transfer
Add logging to more easily determine reason for transmit failure
--- drivers/char/tpm/tpm_tis_core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/char/tpm/tpm_tis_core.c +4 -0
@@ -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; }
Signature · 1 line
2.54.0.rc0.605.g598a273b03-goog
PATCH v3 2/2 tpm: tpm_tis: stop transmit if retries are exhausted
In reply to Jacqueline Wongtpm_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.
--- drivers/char/tpm/tpm_tis_core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +6 -1
@@ -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 )
Signature · 1 line
2.54.0.rc0.605.g598a273b03-goog
Quoted 7 lines · Jacqueline Wong
The Fix:
- Patch 1: Adds error logs to identify the specific hardware status mismatch.
- Patch 2: Stops execution immediately when retries are exhausted.v3 changes:
- Improved code alignment to pass checkpatch --strict.
Thanks for sending the v3 Jacqueline!
I suspect this may have slipped under folks' radar by not CC'ing +linux-kernel@.
Quoted 37 lines
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 timeoutsAfter:
[ 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 timeoutsJacqueline Wong (2):
tpm:tpm_tis: add error logging for data transfer
tpm:tpm_tis: stop transmit if retries are exhausteddrivers/char/tpm/tpm_tis_core.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)--
2.54.0.rc0.605.g598a273b03-goog
Jarkko Sakkinen
maintainerQuoted 11 lines · Axel Rasmussen
Quoted 7 lines · Jacqueline Wong
The Fix:
- Patch 1: Adds error logs to identify the specific hardware status mismatch.
- Patch 2: Stops execution immediately when retries are exhausted.v3 changes:
- Improved code alignment to pass checkpatch --strict.Thanks for sending the v3 Jacqueline!
I suspect this may have slipped under folks' radar by not CC'ing +linux-kernel@.
Please check that I carry the correct version of patches:
https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd.git/log/?h=for-next-tpm
This is related to:
1. https://lore.kernel.org/linux-integrity/[email protected]/
2. https://lore.kernel.org/linux-integrity/CAHk-=wiPWCUHsNvzKep7z4VGaL-Brx6Zmh7Efn28WWTPbwn5dA@mail.gmail.com/
3. https://lore.kernel.org/all/[email protected]/
I will try to send PRs after my split next branches are sync to -next.
BR, Jarkko
A message that is not in the archive (sent off-list or not yet received): CAK8FdkqPzOiZZHsZPbMQg0s_=+rU6ENtBx-6YtuekyiqG8cvPw@mail.gmail.com
Jarkko Sakkinen
maintainerOK cool, thanks for heads up.
I'll most likely address this mess I'm having ATM by doing rc2 PR with the bug fixes.
BR, Jarkko
Quoted 39 lines · Jacqueline Wong
Thanks Jarkko, the patches look correct to me.
Thanks,
JacquelineOn Thu, Apr 23, 2026 at 3:21 AM Jarkko Sakkinen <[email protected]> wrote:
On Wed, Apr 22, 2026 at 04:00:17PM -0700, Axel Rasmussen wrote:
> On Wed, Apr 15, 2026 at 9:00 AM Jacqueline Wong <[email protected]> wrote:
> >
> > The Fix:
> > - Patch 1: Adds error logs to identify the specific hardware status mismatch.
> > - Patch 2: Stops execution immediately when retries are exhausted. > >
> > v3 changes:
> > - Improved code alignment to pass checkpatch --strict. >
> Thanks for sending the v3 Jacqueline!
> I suspect this may have slipped under folks' radar by not CC'ing +linux-kernel@.Please check that I carry the correct version of patches:
https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd.git/log
/?h=for-next-tpmThis is related to:
1. https://lore.kernel.org/linux-integrity/[email protected]/
2. https://lore.kernel.org/linux-integrity/CAHk-=
[email protected]/
3. https://lore.kernel.org/all/[email protected]/I will try to send PRs after my split next branches are sync to -next.
BR, Jarkko