Skip to content

Commit 7146dff

Browse files
u1f35cjarkkojs
authored andcommitted
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: [email protected] # v6.4+ Fixes: e87fcf0 ("tpm, tpm_tis: Only handle supported interrupts") Signed-off-by: Jonathan McDowell <[email protected]> Reviewed-by: Michal Suchánek <[email protected]> Reviewed-by: Lino Sanfilippo <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
1 parent 6359691 commit 7146dff

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
@@ -114,11 +114,10 @@ static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask,
114114
return 0;
115115
/* process status changes without irq support */
116116
do {
117+
usleep_range(priv->timeout_min, priv->timeout_max);
117118
status = chip->ops->status(chip);
118119
if ((status & mask) == mask)
119120
return 0;
120-
usleep_range(priv->timeout_min,
121-
priv->timeout_max);
122121
} while (time_before(jiffies, stop));
123122
return -ETIME;
124123
}

0 commit comments

Comments
 (0)