public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: "Marcin Obara" <marcin_obara@users.sourceforge.net>
Cc: Valdis.Kletnieks@vt.edu, torvalds@linux-foundation.org,
	linux-kernel@vger.kernel.org, tpm@selhorst.net,
	kjhall@us.ibm.com, tpmdd-devel@lists.sourceforge.net
Subject: Re: [PATCH] 2.6.26-mmotm tpm-correct-tpm-timeouts-to-jiffies-conversion-d820-fix.patch
Date: Mon, 11 Aug 2008 13:44:13 -0700	[thread overview]
Message-ID: <20080811134413.014ddcf2.akpm@linux-foundation.org> (raw)
In-Reply-To: <ea8d860a0807261227w66e29978uecd12cf1fcb915d1@mail.gmail.com>

On Sat, 26 Jul 2008 20:27:33 +0100
"Marcin Obara" <marcin_obara@users.sourceforge.net> wrote:

> 2008/7/26  <Valdis.Kletnieks@vt.edu>:
> > +       if (chip->vendor.duration[TPM_SHORT] == 1)
> > +               chip->vendor.duration[TPM_SHORT] *= 1000;
> > +
> >        chip->vendor.duration[TPM_MEDIUM] =
> >            usecs_to_jiffies(be32_to_cpu
> >                             (*((__be32 *) (data +
> 
> 
> Value in  chip->vendor.duration[TPM_SHORT]  is in jiffies not in  milliseconds.
>  (As I know it's not the same. Jiffy is in range 1-10 ms.)
> I know the result may be the same, but it is unclear.
> 
> Maybe... value should be compared (to 1000) before conversion?
> or...
> If after conversion, there should be something like this:
>        if (chip->vendor.duration[TPM_SHORT]  < (HZ/100))  /*  less
> than 10ms ? */
>                chip->vendor.duration[TPM_SHORT] = HZ;
> 
> What do you think?
> 

This all seemed to die off without a conclusion.

Here's the current
tpm-correct-tpm-timeouts-to-jiffies-conversion.patch.  Does it need
updating?

Thanks.


From: Marcin Obara <marcin_obara@users.sourceforge.net>

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).

Signed-off-by: Marcin Obara <marcin_obara@users.sourceforge.net>
Cc: Marcel Selhorst <tpm@selhorst.net>
Cc: Kylene Jo Hall <kjhall@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 drivers/char/tpm/tpm.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff -puN drivers/char/tpm/tpm.c~tpm-correct-tpm-timeouts-to-jiffies-conversion drivers/char/tpm/tpm.c
--- a/drivers/char/tpm/tpm.c~tpm-correct-tpm-timeouts-to-jiffies-conversion
+++ a/drivers/char/tpm/tpm.c
@@ -525,19 +525,19 @@ void tpm_get_timeouts(struct tpm_chip *c
 	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))));
 }
_


  reply	other threads:[~2008-08-11 20:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080725164614.044a526e.akpm@linux-foundation.org>
     [not found] ` <50684.1217035060@turing-police.cc.vt.edu>
     [not found]   ` <20080725185115.5d1a107d.akpm@linux-foundation.org>
2008-07-26  4:03     ` [PATCH] 2.6.26-mmotm tpm-correct-tpm-timeouts-to-jiffies-conversion-d820-fix.patch Valdis.Kletnieks
2008-07-26 19:27       ` Marcin Obara
2008-08-11 20:44         ` Andrew Morton [this message]
2008-08-15  9:39         ` Valdis.Kletnieks

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080811134413.014ddcf2.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=kjhall@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcin_obara@users.sourceforge.net \
    --cc=torvalds@linux-foundation.org \
    --cc=tpm@selhorst.net \
    --cc=tpmdd-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox