1From e7c976b5864e7d2649292d90ea60d5aea091a990 Mon Sep 17 00:00:00 2001
2From: Jason Andryuk <jandryuk@gmail.com>
3Date: Sun, 14 Mar 2021 12:46:34 -0400
4Subject: [PATCH 2/2] Increase command durations
5
6Wth Linux 5.4 xen-tpmfront and a Xen vtpm-stubdom, xen-tpmfront was
7failing commands with -ETIME:
8tpm tpm0: tpm_try_transmit: send(): error-62
9
10The vtpm was returning the data, but it was after the duration timeout
11in vtpm_send.  Linux may have started being more stringent about timing?
12
13The vtpm-stubdom has a little delay since it writes its disk before
14returning the response.
15
16Anyway, the durations are rather low.  When they were 1/10/1000 before
17converting to microseconds, Linux showed all three durations rounded to
1810000.  Update them with values from a physical TPM1.2.  These were
19taken from a WEC which was software downgraded from a TPM2 to a TPM1.2.
20They might be excessive, but I'd rather have a command succeed than
21return -ETIME.
22
23An IFX physical TPM1.2 uses:
241000000
251500000
26150000000
27
28Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
29---
30 tpm/tpm_data.c | 6 +++---
31 1 file changed, 3 insertions(+), 3 deletions(-)
32
33diff --git a/tpm/tpm_data.c b/tpm/tpm_data.c
34index bebaf10..844afca 100644
35--- a/tpm/tpm_data.c
36+++ b/tpm/tpm_data.c
37@@ -71,9 +71,9 @@ static void init_timeouts(void)
38   tpmData.permanent.data.tis_timeouts[1] = 2000000;
39   tpmData.permanent.data.tis_timeouts[2] = 750000;
40   tpmData.permanent.data.tis_timeouts[3] = 750000;
41-  tpmData.permanent.data.cmd_durations[0] = 1000;
42-  tpmData.permanent.data.cmd_durations[1] = 10000;
43-  tpmData.permanent.data.cmd_durations[2] = 1000000;
44+  tpmData.permanent.data.cmd_durations[0] = 3000000;
45+  tpmData.permanent.data.cmd_durations[1] = 3000000;
46+  tpmData.permanent.data.cmd_durations[2] = 600000000;
47 }
48
49 void tpm_init_data(void)
50--
512.30.2
52
53