]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
1 | From 9e5b1b12226d5a501fbc6706ca090e00d18a01ad Mon Sep 17 00:00:00 2001 |
2 | From: Marcin Obara <marcin_obara@users.sourceforge.net> | |
3 | Date: Wed, 15 Oct 2008 22:04:34 -0700 | |
4 | Subject: [PATCH] tpm: correct tpm timeouts to jiffies conversion | |
5 | Patch-mainline: 2.6.28 | |
6 | References: bnc#425747 FATE304221 | |
7 | ||
8 | This patch fixes timeouts conversion to jiffies, by replacing | |
9 | msecs_to_jiffies() calls with usecs_to_jiffies(). According to TCG TPM | |
10 | Specification Version 1.2 Revision 103 (pages 166, 167) TPM timeouts and | |
11 | durations are returned in microseconds (usec) not in miliseconds (msec). | |
12 | ||
13 | This fixes a long hang while loading TPM driver, if TPM chip starts in | |
14 | "Idle" state instead of "Ready" state. Without this patch - 'modprobe' | |
15 | may hang for 30 seconds or more. | |
16 | ||
17 | Signed-off-by: Marcin Obara <marcin_obara@users.sourceforge.net> | |
18 | Cc: Marcel Selhorst <tpm@selhorst.net> | |
19 | Cc: Kylene Jo Hall <kjhall@us.ibm.com> | |
20 | Cc: Jiri Slaby <jirislaby@gmail.com> | |
21 | Signed-off-by: Andrew Morton <akpm@linux-foundation.org> | |
22 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | |
23 | Signed-off-by: Jiri Slaby <jslaby@suse.cz> | |
24 | --- | |
25 | drivers/char/tpm/tpm.c | 14 +++++++------- | |
26 | 1 files changed, 7 insertions(+), 7 deletions(-) | |
27 | ||
28 | diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c | |
29 | index 1fee703..6b5a0e0 100644 | |
30 | --- a/drivers/char/tpm/tpm.c | |
31 | +++ b/drivers/char/tpm/tpm.c | |
32 | @@ -525,19 +525,19 @@ void tpm_get_timeouts(struct tpm_chip *chip) | |
33 | timeout = | |
34 | be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_1_IDX))); | |
35 | if (timeout) | |
36 | - chip->vendor.timeout_a = msecs_to_jiffies(timeout); | |
37 | + chip->vendor.timeout_a = usecs_to_jiffies(timeout); | |
38 | timeout = | |
39 | be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_2_IDX))); | |
40 | if (timeout) | |
41 | - chip->vendor.timeout_b = msecs_to_jiffies(timeout); | |
42 | + chip->vendor.timeout_b = usecs_to_jiffies(timeout); | |
43 | timeout = | |
44 | be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_3_IDX))); | |
45 | if (timeout) | |
46 | - chip->vendor.timeout_c = msecs_to_jiffies(timeout); | |
47 | + chip->vendor.timeout_c = usecs_to_jiffies(timeout); | |
48 | timeout = | |
49 | be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_4_IDX))); | |
50 | if (timeout) | |
51 | - chip->vendor.timeout_d = msecs_to_jiffies(timeout); | |
52 | + chip->vendor.timeout_d = usecs_to_jiffies(timeout); | |
53 | ||
54 | duration: | |
55 | memcpy(data, tpm_cap, sizeof(tpm_cap)); | |
56 | @@ -554,15 +554,15 @@ duration: | |
57 | return; | |
58 | ||
59 | chip->vendor.duration[TPM_SHORT] = | |
60 | - msecs_to_jiffies(be32_to_cpu | |
61 | + usecs_to_jiffies(be32_to_cpu | |
62 | (*((__be32 *) (data + | |
63 | TPM_GET_CAP_RET_UINT32_1_IDX)))); | |
64 | chip->vendor.duration[TPM_MEDIUM] = | |
65 | - msecs_to_jiffies(be32_to_cpu | |
66 | + usecs_to_jiffies(be32_to_cpu | |
67 | (*((__be32 *) (data + | |
68 | TPM_GET_CAP_RET_UINT32_2_IDX)))); | |
69 | chip->vendor.duration[TPM_LONG] = | |
70 | - msecs_to_jiffies(be32_to_cpu | |
71 | + usecs_to_jiffies(be32_to_cpu | |
72 | (*((__be32 *) (data + | |
73 | TPM_GET_CAP_RET_UINT32_3_IDX)))); | |
74 | } | |
75 | -- | |
76 | 1.6.0.2 | |
77 |