* [PATCH] tpm: tpm_i2c_nuvoton: use correct command duration for TPM 2.x
@ 2018-10-17 16:32 Tomas Winkler
2018-10-19 4:44 ` Nayna Jain
2018-10-19 23:24 ` Jarkko Sakkinen
0 siblings, 2 replies; 4+ messages in thread
From: Tomas Winkler @ 2018-10-17 16:32 UTC (permalink / raw)
To: Jarkko Sakkinen, Jason Gunthorpe
Cc: Nayna Jain, Alexander Usyskin, Tadeusz Struk, linux-integrity,
linux-security-module, linux-kernel, Tomas Winkler
tpm_i2c_nuvoton calculated commands duration using TPM 1.x
values via tpm_calc_ordinal_duration() also for TPM 2.x chips.
Call tpm2_calc_ordinal_duration() for retrieving ordinal
duration for TPM 2.X chips.
Cc: Nayna Jain <nayna@linux.vnet.ibm.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/char/tpm/tpm_i2c_nuvoton.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
index caa86b19c76d..f74f451baf6a 100644
--- a/drivers/char/tpm/tpm_i2c_nuvoton.c
+++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
@@ -369,6 +369,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
struct device *dev = chip->dev.parent;
struct i2c_client *client = to_i2c_client(dev);
u32 ordinal;
+ unsigned long duration;
size_t count = 0;
int burst_count, bytes2write, retries, rc = -EIO;
@@ -455,10 +456,12 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
return rc;
}
ordinal = be32_to_cpu(*((__be32 *) (buf + 6)));
- rc = i2c_nuvoton_wait_for_data_avail(chip,
- tpm_calc_ordinal_duration(chip,
- ordinal),
- &priv->read_queue);
+ if (chip->flags & TPM_CHIP_FLAG_TPM2)
+ duration = tpm2_calc_ordinal_duration(chip, ordinal);
+ else
+ duration = tpm_calc_ordinal_duration(chip, ordinal);
+
+ rc = i2c_nuvoton_wait_for_data_avail(chip, duration, &priv->read_queue);
if (rc) {
dev_err(dev, "%s() timeout command duration\n", __func__);
i2c_nuvoton_ready(chip);
--
2.14.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] tpm: tpm_i2c_nuvoton: use correct command duration for TPM 2.x
2018-10-17 16:32 [PATCH] tpm: tpm_i2c_nuvoton: use correct command duration for TPM 2.x Tomas Winkler
@ 2018-10-19 4:44 ` Nayna Jain
2018-10-19 7:30 ` Winkler, Tomas
2018-10-19 23:24 ` Jarkko Sakkinen
1 sibling, 1 reply; 4+ messages in thread
From: Nayna Jain @ 2018-10-19 4:44 UTC (permalink / raw)
To: Tomas Winkler, Jarkko Sakkinen, Jason Gunthorpe
Cc: Nayna Jain, Alexander Usyskin, Tadeusz Struk, linux-integrity,
linux-security-module, linux-kernel
On 10/17/2018 10:02 PM, Tomas Winkler wrote:
> diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
> index caa86b19c76d..f74f451baf6a 100644
> --- a/drivers/char/tpm/tpm_i2c_nuvoton.c
> +++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
> @@ -369,6 +369,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
> struct device *dev = chip->dev.parent;
> struct i2c_client *client = to_i2c_client(dev);
> u32 ordinal;
> + unsigned long duration;
> size_t count = 0;
> int burst_count, bytes2write, retries, rc = -EIO;
>
> @@ -455,10 +456,12 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
> return rc;
> }
> ordinal = be32_to_cpu(*((__be32 *) (buf + 6)));
> - rc = i2c_nuvoton_wait_for_data_avail(chip,
> - tpm_calc_ordinal_duration(chip,
> - ordinal),
> - &priv->read_queue);
> + if (chip->flags & TPM_CHIP_FLAG_TPM2)
> + duration = tpm2_calc_ordinal_duration(chip, ordinal);
> + else
> + duration = tpm_calc_ordinal_duration(chip, ordinal);
> +
> + rc = i2c_nuvoton_wait_for_data_avail(chip, duration, &priv->read_queue);
> if (rc) {
> dev_err(dev, "%s() timeout command duration\n", __func__);
> i2c_nuvoton_ready(chip);
I only have Nuvoton TPM 2.0, tested for that.
Reviewed-by: Nayna Jain <nayna@linux.ibm.com>
Tested-by: Nayna Jain <nayna@linux.ibm.com> (For TPM 2.0)
Thanks & Regards,
- Nayna
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tpm: tpm_i2c_nuvoton: use correct command duration for TPM 2.x
2018-10-19 4:44 ` Nayna Jain
@ 2018-10-19 7:30 ` Winkler, Tomas
0 siblings, 0 replies; 4+ messages in thread
From: Winkler, Tomas @ 2018-10-19 7:30 UTC (permalink / raw)
To: jarkko.sakkinen, jgg, nayna
Cc: nayna, Struk, Tadeusz, linux-integrity, Usyskin, Alexander,
linux-security-module, linux-kernel
On Fri, 2018-10-19 at 10:14 +0530, Nayna Jain wrote:
>
> On 10/17/2018 10:02 PM, Tomas Winkler wrote:
> > diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
> > index caa86b19c76d..f74f451baf6a 100644
> > --- a/drivers/char/tpm/tpm_i2c_nuvoton.c
> > +++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
> > @@ -369,6 +369,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
> > struct device *dev = chip->dev.parent;
> > struct i2c_client *client = to_i2c_client(dev);
> > u32 ordinal;
> > + unsigned long duration;
> > size_t count = 0;
> > int burst_count, bytes2write, retries, rc = -EIO;
> >
> > @@ -455,10 +456,12 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
> > return rc;
> > }
> > ordinal = be32_to_cpu(*((__be32 *) (buf + 6)));
> > - rc = i2c_nuvoton_wait_for_data_avail(chip,
> > - tpm_calc_ordinal_duration(chip,
> > - ordinal),
> > - &priv->read_queue);
> > + if (chip->flags & TPM_CHIP_FLAG_TPM2)
> > + duration = tpm2_calc_ordinal_duration(chip, ordinal);
> > + else
> > + duration = tpm_calc_ordinal_duration(chip, ordinal);
> > +
> > + rc = i2c_nuvoton_wait_for_data_avail(chip, duration, &priv->read_queue);
> > if (rc) {
> > dev_err(dev, "%s() timeout command duration\n", __func__);
> > i2c_nuvoton_ready(chip);
>
> I only have Nuvoton TPM 2.0, tested for that.
>
> Reviewed-by: Nayna Jain <nayna@linux.ibm.com>
> Tested-by: Nayna Jain <nayna@linux.ibm.com> (For TPM 2.0)
That's what we needed as TPM 1.2 should be unchanged.
Really appreciate the quick response. I will rebase the series on to of
this patch.
Thanks
Tomas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tpm: tpm_i2c_nuvoton: use correct command duration for TPM 2.x
2018-10-17 16:32 [PATCH] tpm: tpm_i2c_nuvoton: use correct command duration for TPM 2.x Tomas Winkler
2018-10-19 4:44 ` Nayna Jain
@ 2018-10-19 23:24 ` Jarkko Sakkinen
1 sibling, 0 replies; 4+ messages in thread
From: Jarkko Sakkinen @ 2018-10-19 23:24 UTC (permalink / raw)
To: Tomas Winkler
Cc: Jarkko Sakkinen, Jason Gunthorpe, Nayna Jain, Alexander Usyskin,
Tadeusz Struk, linux-integrity, linux-security-module,
linux-kernel
On Wed, 17 Oct 2018, Tomas Winkler wrote:
> tpm_i2c_nuvoton calculated commands duration using TPM 1.x
> values via tpm_calc_ordinal_duration() also for TPM 2.x chips.
> Call tpm2_calc_ordinal_duration() for retrieving ordinal
> duration for TPM 2.X chips.
>
> Cc: Nayna Jain <nayna@linux.vnet.ibm.com>
> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Does this require a fixes tag?
/Jarkko
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-10-19 23:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-17 16:32 [PATCH] tpm: tpm_i2c_nuvoton: use correct command duration for TPM 2.x Tomas Winkler
2018-10-19 4:44 ` Nayna Jain
2018-10-19 7:30 ` Winkler, Tomas
2018-10-19 23:24 ` 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).