Skip to content

Commit fff9296

Browse files
committed
tpm, tpm_tis: Fix timeout handling when waiting for TPM status
JIRA: https://issues.redhat.com/browse/RHEL-72765 Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git commit 7146dff Author: Jonathan McDowell <noodles@meta.com> Date: Wed Mar 12 07:31:57 2025 +0200 tpm, tpm_tis: Fix timeout handling when waiting for TPM status The change to only use interrupts to handle supported status changes introduced an issue when it is necessary to poll for the status. Rather than checking for the status after sleeping the code now sleeps after the check. This means a correct, but slower, status change on the part of the TPM can be missed, resulting in a spurious timeout error, especially on a more loaded system. Switch back to sleeping *then* checking. An up front check of the status has been done at the start of the function, so this does not cause an additional delay when the status is already what we're looking for. Cc: stable@vger.kernel.org # v6.4+ Fixes: e87fcf0 ("tpm, tpm_tis: Only handle supported interrupts") Signed-off-by: Jonathan McDowell <noodles@meta.com> Reviewed-by: Michal Suchánek <msuchanek@suse.de> Reviewed-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Štěpán Horáček <shoracek@redhat.com>
1 parent 6f1a787 commit fff9296

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/char/tpm/tpm_tis_core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,10 @@ static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask,
111111
return 0;
112112
/* process status changes without irq support */
113113
do {
114+
usleep_range(priv->timeout_min, priv->timeout_max);
114115
status = chip->ops->status(chip);
115116
if ((status & mask) == mask)
116117
return 0;
117-
usleep_range(priv->timeout_min,
118-
priv->timeout_max);
119118
} while (time_before(jiffies, stop));
120119
return -ETIME;
121120
}

0 commit comments

Comments
 (0)