[v7,01/21] tpm: tpm_i2c_nuvoton: use correct command duration for TPM 2.x
diff mbox series

Message ID 20181019182307.17745-2-tomas.winkler@intel.com
State Accepted
Commit 2ba5780ce30549cf57929b01d8cba6fe656e31c5
Headers show
Series
  • tpm: separate tpm 1.x and tpm 2.x commands
Related show

Commit Message

Tomas Winkler Oct. 19, 2018, 6:22 p.m. UTC
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: stable@vger.kernel.org
Cc: Nayna Jain <nayna@linux.vnet.ibm.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Reviewed-by: Nayna Jain <nayna@linux.ibm.com>
Tested-by: Nayna Jain <nayna@linux.ibm.com> (For TPM 2.0)
---
V7: new in the series.

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

Comments

Jarkko Sakkinen Oct. 20, 2018, 12:51 a.m. UTC | #1
On Fri, 19 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: stable@vger.kernel.org
> Cc: Nayna Jain <nayna@linux.vnet.ibm.com>
> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
> Reviewed-by: Nayna Jain <nayna@linux.ibm.com>
> Tested-by: Nayna Jain <nayna@linux.ibm.com> (For TPM 2.0)
> ---
> V7: new in the series.

Please, put change log entries only to the cover letter.

>
> 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
>
>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

/Jarkko

Patch
diff mbox series

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