Skip to content

Commit 59f5a6b

Browse files
naynajainJarkko Sakkinen
authored andcommitted
tpm: reduce poll sleep time in tpm_transmit()
tpm_try_transmit currently checks TPM status every 5 msecs between send and recv. It does so in a loop for the maximum timeout as defined in the TPM Interface Specification. However, the TPM may return before 5 msecs. Thus the polling interval for each iteration can be reduced, which improves overall performance. This patch changes the polling sleep time from 5 msecs to 1 msec. Additionally, this patch renames TPM_POLL_SLEEP to TPM_TIMEOUT_POLL and moves it to tpm.h as an enum value. After this change, performance on a system[1] with a TPM 1.2 with an 8 byte burstcount for 1000 extends improved from ~14 sec to ~10.7 sec. [1] All tests are performed on an x86 based, locked down, single purpose closed system. It has Infineon TPM 1.2 using LPC Bus. Signed-off-by: Nayna Jain <[email protected]> Acked-by: Jay Freyensee <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Tested-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
1 parent 33bafe9 commit 59f5a6b

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

drivers/char/tpm/tpm-interface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip,
489489
goto out;
490490
}
491491

492-
tpm_msleep(TPM_TIMEOUT);
492+
tpm_msleep(TPM_TIMEOUT_POLL);
493493
rmb();
494494
} while (time_before(jiffies, stop));
495495

drivers/char/tpm/tpm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ enum tpm_const {
5353
enum tpm_timeout {
5454
TPM_TIMEOUT = 5, /* msecs */
5555
TPM_TIMEOUT_RETRY = 100, /* msecs */
56-
TPM_TIMEOUT_RANGE_US = 300 /* usecs */
56+
TPM_TIMEOUT_RANGE_US = 300, /* usecs */
57+
TPM_TIMEOUT_POLL = 1 /* msecs */
5758
};
5859

5960
/* TPM addresses */

drivers/char/tpm/tpm_tis_core.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@
3131
#include "tpm.h"
3232
#include "tpm_tis_core.h"
3333

34-
/* This is a polling delay to check for status and burstcount.
35-
* As per ddwg input, expectation is that status check and burstcount
36-
* check should return within few usecs.
37-
*/
38-
#define TPM_POLL_SLEEP 1 /* msec */
39-
4034
static void tpm_tis_clkrun_enable(struct tpm_chip *chip, bool value);
4135

4236
static bool wait_for_tpm_stat_cond(struct tpm_chip *chip, u8 mask,
@@ -90,7 +84,7 @@ static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask,
9084
}
9185
} else {
9286
do {
93-
tpm_msleep(TPM_POLL_SLEEP);
87+
tpm_msleep(TPM_TIMEOUT_POLL);
9488
status = chip->ops->status(chip);
9589
if ((status & mask) == mask)
9690
return 0;
@@ -279,7 +273,7 @@ static int get_burstcount(struct tpm_chip *chip)
279273
burstcnt = (value >> 8) & 0xFFFF;
280274
if (burstcnt)
281275
return burstcnt;
282-
tpm_msleep(TPM_POLL_SLEEP);
276+
tpm_msleep(TPM_TIMEOUT_POLL);
283277
} while (time_before(jiffies, stop));
284278
return -EBUSY;
285279
}

0 commit comments

Comments
 (0)