* [RESEND][PATCH] tpm: read burstcount from TPM_STS in one 32-bit transaction
@ 2016-06-30 17:25 apronin-F7+t8E8rja9g9hUCZPvPmw
[not found] ` <1467307543-44566-1-git-send-email-apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: apronin-F7+t8E8rja9g9hUCZPvPmw @ 2016-06-30 17:25 UTC (permalink / raw)
To: Jarkko Sakkinen
Cc: Christophe Ricard, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
From: Andrey Pronin <apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Some chips incorrectly support partial reads from TPM_STS register
at non-zero offsets. Read the entire 32-bits register instead of
making two 8-bit reads to support such devices and reduce the number
of bus transactions when obtaining the burstcount from TPM_STS.
Signed-off-by: Andrey Pronin <apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
No changes.
Re-sending to tpmdd-devel member-only list after subscribing.
drivers/char/tpm/tpm_tis_core.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index 03a06b3..8110b52 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -157,22 +157,17 @@ static int get_burstcount(struct tpm_chip *chip)
struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
unsigned long stop;
int burstcnt, rc;
- u8 value;
+ u32 value;
/* wait for burstcount */
/* which timeout value, spec has 2 answers (c & d) */
stop = jiffies + chip->timeout_d;
do {
- rc = tpm_tis_read8(priv, TPM_STS(priv->locality) + 1, &value);
+ rc = tpm_tis_read32(priv, TPM_STS(priv->locality), &value);
if (rc < 0)
return rc;
- burstcnt = value;
- rc = tpm_tis_read8(priv, TPM_STS(priv->locality) + 2, &value);
- if (rc < 0)
- return rc;
-
- burstcnt += value << 8;
+ burstcnt = (value >> 8) & 0xFFFF;
if (burstcnt)
return burstcnt;
msleep(TPM_TIMEOUT);
--
2.6.6
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
^ permalink raw reply related [flat|nested] 4+ messages in thread[parent not found: <1467307543-44566-1-git-send-email-apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>]
* Re: [RESEND][PATCH] tpm: read burstcount from TPM_STS in one 32-bit transaction [not found] ` <1467307543-44566-1-git-send-email-apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> @ 2016-07-01 8:43 ` Jarkko Sakkinen [not found] ` <20160701084323.GA15718-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: Jarkko Sakkinen @ 2016-07-01 8:43 UTC (permalink / raw) To: apronin-F7+t8E8rja9g9hUCZPvPmw Cc: Christophe Ricard, linux-kernel-u79uwXL29TY76Z2rM5mHXA, tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f On Thu, Jun 30, 2016 at 10:25:43AM -0700, apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org wrote: > From: Andrey Pronin <apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> > > Some chips incorrectly support partial reads from TPM_STS register > at non-zero offsets. Read the entire 32-bits register instead of > making two 8-bit reads to support such devices and reduce the number > of bus transactions when obtaining the burstcount from TPM_STS. > > Signed-off-by: Andrey Pronin <apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> /Jarkko > --- > > No changes. > Re-sending to tpmdd-devel member-only list after subscribing. > > drivers/char/tpm/tpm_tis_core.c | 11 +++-------- > 1 file changed, 3 insertions(+), 8 deletions(-) > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c > index 03a06b3..8110b52 100644 > --- a/drivers/char/tpm/tpm_tis_core.c > +++ b/drivers/char/tpm/tpm_tis_core.c > @@ -157,22 +157,17 @@ static int get_burstcount(struct tpm_chip *chip) > struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); > unsigned long stop; > int burstcnt, rc; > - u8 value; > + u32 value; > > /* wait for burstcount */ > /* which timeout value, spec has 2 answers (c & d) */ > stop = jiffies + chip->timeout_d; > do { > - rc = tpm_tis_read8(priv, TPM_STS(priv->locality) + 1, &value); > + rc = tpm_tis_read32(priv, TPM_STS(priv->locality), &value); > if (rc < 0) > return rc; > > - burstcnt = value; > - rc = tpm_tis_read8(priv, TPM_STS(priv->locality) + 2, &value); > - if (rc < 0) > - return rc; > - > - burstcnt += value << 8; > + burstcnt = (value >> 8) & 0xFFFF; > if (burstcnt) > return burstcnt; > msleep(TPM_TIMEOUT); > -- > 2.6.6 > ------------------------------------------------------------------------------ Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San Francisco, CA to explore cutting-edge tech and listen to tech luminaries present their vision of the future. This family event has something for everyone, including kids. Get more information and register today. http://sdm.link/attshape ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <20160701084323.GA15718-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>]
* Re: [RESEND][PATCH] tpm: read burstcount from TPM_STS in one 32-bit transaction [not found] ` <20160701084323.GA15718-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> @ 2016-07-01 8:45 ` Jarkko Sakkinen 2016-07-19 14:41 ` [tpmdd-devel] " Jarkko Sakkinen 0 siblings, 1 reply; 4+ messages in thread From: Jarkko Sakkinen @ 2016-07-01 8:45 UTC (permalink / raw) To: apronin-F7+t8E8rja9g9hUCZPvPmw Cc: Christophe Ricard, linux-kernel-u79uwXL29TY76Z2rM5mHXA, tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f On Fri, Jul 01, 2016 at 11:43:23AM +0300, Jarkko Sakkinen wrote: > On Thu, Jun 30, 2016 at 10:25:43AM -0700, apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org wrote: > > From: Andrey Pronin <apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> > > > > Some chips incorrectly support partial reads from TPM_STS register > > at non-zero offsets. Read the entire 32-bits register instead of > > making two 8-bit reads to support such devices and reduce the number > > of bus transactions when obtaining the burstcount from TPM_STS. > > > > Signed-off-by: Andrey Pronin <apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> > > Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> Applied to my master branch. /Jarkko > > /Jarkko > > > --- > > > > No changes. > > Re-sending to tpmdd-devel member-only list after subscribing. > > > > drivers/char/tpm/tpm_tis_core.c | 11 +++-------- > > 1 file changed, 3 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c > > index 03a06b3..8110b52 100644 > > --- a/drivers/char/tpm/tpm_tis_core.c > > +++ b/drivers/char/tpm/tpm_tis_core.c > > @@ -157,22 +157,17 @@ static int get_burstcount(struct tpm_chip *chip) > > struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); > > unsigned long stop; > > int burstcnt, rc; > > - u8 value; > > + u32 value; > > > > /* wait for burstcount */ > > /* which timeout value, spec has 2 answers (c & d) */ > > stop = jiffies + chip->timeout_d; > > do { > > - rc = tpm_tis_read8(priv, TPM_STS(priv->locality) + 1, &value); > > + rc = tpm_tis_read32(priv, TPM_STS(priv->locality), &value); > > if (rc < 0) > > return rc; > > > > - burstcnt = value; > > - rc = tpm_tis_read8(priv, TPM_STS(priv->locality) + 2, &value); > > - if (rc < 0) > > - return rc; > > - > > - burstcnt += value << 8; > > + burstcnt = (value >> 8) & 0xFFFF; > > if (burstcnt) > > return burstcnt; > > msleep(TPM_TIMEOUT); > > -- > > 2.6.6 > > ------------------------------------------------------------------------------ Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San Francisco, CA to explore cutting-edge tech and listen to tech luminaries present their vision of the future. This family event has something for everyone, including kids. Get more information and register today. http://sdm.link/attshape ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [tpmdd-devel] [RESEND][PATCH] tpm: read burstcount from TPM_STS in one 32-bit transaction 2016-07-01 8:45 ` Jarkko Sakkinen @ 2016-07-19 14:41 ` Jarkko Sakkinen 0 siblings, 0 replies; 4+ messages in thread From: Jarkko Sakkinen @ 2016-07-19 14:41 UTC (permalink / raw) To: apronin Cc: Christophe Ricard, linux-kernel, tpmdd-devel, linux-security-module, leendert On Fri, Jul 01, 2016 at 11:45:45AM +0300, Jarkko Sakkinen wrote: > On Fri, Jul 01, 2016 at 11:43:23AM +0300, Jarkko Sakkinen wrote: > > On Thu, Jun 30, 2016 at 10:25:43AM -0700, apronin@chromium.org wrote: > > > From: Andrey Pronin <apronin@chromium.org> > > > > > > Some chips incorrectly support partial reads from TPM_STS register > > > at non-zero offsets. Read the entire 32-bits register instead of > > > making two 8-bit reads to support such devices and reduce the number > > > of bus transactions when obtaining the burstcount from TPM_STS. > > > > > > Signed-off-by: Andrey Pronin <apronin@chromium.org> > > > > Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> > > Applied to my master branch. I added also added a fixes line. /Jarkko ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-07-19 14:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-30 17:25 [RESEND][PATCH] tpm: read burstcount from TPM_STS in one 32-bit transaction apronin-F7+t8E8rja9g9hUCZPvPmw
[not found] ` <1467307543-44566-1-git-send-email-apronin-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2016-07-01 8:43 ` Jarkko Sakkinen
[not found] ` <20160701084323.GA15718-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-07-01 8:45 ` Jarkko Sakkinen
2016-07-19 14:41 ` [tpmdd-devel] " Jarkko Sakkinen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).