]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/patches/suse-2.6.27.31/patches.drivers/tpm-correct-timeouts.patch
Reenabled linux-xen, added patches for Xen Kernel Version 2.6.27.31,
[ipfire-2.x.git] / src / patches / suse-2.6.27.31 / patches.drivers / tpm-correct-timeouts.patch
diff --git a/src/patches/suse-2.6.27.31/patches.drivers/tpm-correct-timeouts.patch b/src/patches/suse-2.6.27.31/patches.drivers/tpm-correct-timeouts.patch
new file mode 100644 (file)
index 0000000..e5f3f23
--- /dev/null
@@ -0,0 +1,77 @@
+From 9e5b1b12226d5a501fbc6706ca090e00d18a01ad Mon Sep 17 00:00:00 2001
+From: Marcin Obara <marcin_obara@users.sourceforge.net>
+Date: Wed, 15 Oct 2008 22:04:34 -0700
+Subject: [PATCH] tpm: correct tpm timeouts to jiffies conversion
+Patch-mainline: 2.6.28
+References: bnc#425747 FATE304221
+
+This patch fixes timeouts conversion to jiffies, by replacing
+msecs_to_jiffies() calls with usecs_to_jiffies().  According to TCG TPM
+Specification Version 1.2 Revision 103 (pages 166, 167) TPM timeouts and
+durations are returned in microseconds (usec) not in miliseconds (msec).
+
+This fixes a long hang while loading TPM driver, if TPM chip starts in
+"Idle" state instead of "Ready" state.  Without this patch - 'modprobe'
+may hang for 30 seconds or more.
+
+Signed-off-by: Marcin Obara <marcin_obara@users.sourceforge.net>
+Cc: Marcel Selhorst <tpm@selhorst.net>
+Cc: Kylene Jo Hall <kjhall@us.ibm.com>
+Cc: Jiri Slaby <jirislaby@gmail.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Jiri Slaby <jslaby@suse.cz>
+---
+ drivers/char/tpm/tpm.c |   14 +++++++-------
+ 1 files changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
+index 1fee703..6b5a0e0 100644
+--- a/drivers/char/tpm/tpm.c
++++ b/drivers/char/tpm/tpm.c
+@@ -525,19 +525,19 @@ void tpm_get_timeouts(struct tpm_chip *chip)
+       timeout =
+           be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_1_IDX)));
+       if (timeout)
+-              chip->vendor.timeout_a = msecs_to_jiffies(timeout);
++              chip->vendor.timeout_a = usecs_to_jiffies(timeout);
+       timeout =
+           be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_2_IDX)));
+       if (timeout)
+-              chip->vendor.timeout_b = msecs_to_jiffies(timeout);
++              chip->vendor.timeout_b = usecs_to_jiffies(timeout);
+       timeout =
+           be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_3_IDX)));
+       if (timeout)
+-              chip->vendor.timeout_c = msecs_to_jiffies(timeout);
++              chip->vendor.timeout_c = usecs_to_jiffies(timeout);
+       timeout =
+           be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_4_IDX)));
+       if (timeout)
+-              chip->vendor.timeout_d = msecs_to_jiffies(timeout);
++              chip->vendor.timeout_d = usecs_to_jiffies(timeout);
+ duration:
+       memcpy(data, tpm_cap, sizeof(tpm_cap));
+@@ -554,15 +554,15 @@ duration:
+               return;
+       chip->vendor.duration[TPM_SHORT] =
+-          msecs_to_jiffies(be32_to_cpu
++          usecs_to_jiffies(be32_to_cpu
+                            (*((__be32 *) (data +
+                                           TPM_GET_CAP_RET_UINT32_1_IDX))));
+       chip->vendor.duration[TPM_MEDIUM] =
+-          msecs_to_jiffies(be32_to_cpu
++          usecs_to_jiffies(be32_to_cpu
+                            (*((__be32 *) (data +
+                                           TPM_GET_CAP_RET_UINT32_2_IDX))));
+       chip->vendor.duration[TPM_LONG] =
+-          msecs_to_jiffies(be32_to_cpu
++          usecs_to_jiffies(be32_to_cpu
+                            (*((__be32 *) (data +
+                                           TPM_GET_CAP_RET_UINT32_3_IDX))));
+ }
+-- 
+1.6.0.2
+