Skip to contentSkip to conversation

tpm_tis: turn on TPM before calling tpm_get_timeouts

PATCH Superseded Jerry Snitselaar 3 participants 18 messages Nov 11, 2019 – Nov 15, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tpm_tis: turn on TPM before calling tpm_get_timeouts

With power gating moved out of the tpm_transmit code we need to power on the TPM prior to calling tpm_get_timeouts.

Cc Jarkko Sakkinen <[email protected]>
Cc Peter Huewe <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Fixes a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
---
 drivers/char/tpm/tpm_tis_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +2 -1
index 270f43acbb77..cb101cec8f8b 100644
@@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
 		 * to make sure it works. May as well use that command to set the
 		 * proper timeouts for the driver.
 		 */
+		tpm_chip_start(chip);
 		if (tpm_get_timeouts(chip)) {
 			dev_err(dev, "Could not get TPM timeouts and durations\n");
 			rc = -ENODEV;
+			tpm_stop_chip(chip);
 			goto out_err;
 		}
 
-		tpm_chip_start(chip);
 		chip->flags |= TPM_CHIP_FLAG_IRQ;
 		if (irq) {
 			tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED,
Signature · 1 line
2.24.0
#1 lore raw

PATCH v2 1/1 tpm_tis: turn on TPM before calling tpm_get_timeouts

With power gating moved out of the tpm_transmit code we need to power on the TPM prior to calling tpm_get_timeouts.

Cc Jarkko Sakkinen <[email protected]>
Cc Peter Huewe <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Fixes a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")

---
v2: fix stable cc to correct address

 drivers/char/tpm/tpm_tis_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +2 -1
index 270f43acbb77..cb101cec8f8b 100644
@@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
 		 * to make sure it works. May as well use that command to set the
 		 * proper timeouts for the driver.
 		 */
+		tpm_chip_start(chip);
 		if (tpm_get_timeouts(chip)) {
 			dev_err(dev, "Could not get TPM timeouts and durations\n");
 			rc = -ENODEV;
+			tpm_stop_chip(chip);
 			goto out_err;
 		}
 
-		tpm_chip_start(chip);
 		chip->flags |= TPM_CHIP_FLAG_IRQ;
 		if (irq) {
 			tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED,
Signature · 1 line
2.24.0
#2 lore raw
In reply to Jerry Snitselaar
Quoted 20 lines · Jerry Snitselaar

With power gating moved out of the tpm_transmit code we need to power on the TPM prior to calling tpm_get_timeouts.

Cc Jarkko Sakkinen <[email protected]>
Cc Peter Huewe <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Fixes a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
---
 drivers/char/tpm/tpm_tis_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +0 -0
index 270f43acbb77..cb101cec8f8b 100644

drivers/char/tpm/tpm_tis_core.c int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, · line 983

Quoted 10 lines
drivers/char/tpm/tpm_tis_core.c +2 -0
@@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
 		 * to make sure it works. May as well use that command to set the
 		 * proper timeouts for the driver.
 		 */
+		tpm_chip_start(chip);
 		if (tpm_get_timeouts(chip)) {
 			dev_err(dev, "Could not get TPM timeouts and durations\n");
 			rc = -ENODEV;
+			tpm_stop_chip(chip);
 			goto out_err;
 		}

Couldn't this call just be removed?

/Jarkko

#3 lore raw
Quoted 35 lines · Jarkko Sakkinen
Quoted 20 lines · Jerry Snitselaar

With power gating moved out of the tpm_transmit code we need to power on the TPM prior to calling tpm_get_timeouts.

Cc Jarkko Sakkinen <[email protected]>
Cc Peter Huewe <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Fixes a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
---
 drivers/char/tpm/tpm_tis_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +0 -0
index 270f43acbb77..cb101cec8f8b 100644

drivers/char/tpm/tpm_tis_core.c int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, · line 983

Quoted 10 lines
drivers/char/tpm/tpm_tis_core.c +2 -0
@@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
               * to make sure it works. May as well use that command to set the
               * proper timeouts for the driver.
               */
+             tpm_chip_start(chip);
              if (tpm_get_timeouts(chip)) {
                      dev_err(dev, "Could not get TPM timeouts and durations\n");
                      rc = -ENODEV;
+                     tpm_stop_chip(chip);
                      goto out_err;
              }

Couldn't this call just be removed?

Quoted 2 lines

/Jarkko

Probably. It will eventually get called when tpm_chip_register happens. I don't know what the reason was for trying it prior to the irq probe.

#4 lore raw
Quoted 35 lines · Jerry Snitselaar
Quoted 33 lines · Jarkko Sakkinen
Quoted 18 lines · Jerry Snitselaar

With power gating moved out of the tpm_transmit code we need to power on the TPM prior to calling tpm_get_timeouts.

Cc Jarkko Sakkinen <[email protected]>
Cc Peter Huewe <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Fixes a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
 drivers/char/tpm/tpm_tis_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +1 -0
index 270f43acbb77..cb101cec8f8b 100644
+++ b/drivers/char/tpm/tpm_tis_core.c

drivers/char/tpm/tpm_tis_core.c int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, · line 983

Quoted 10 lines
drivers/char/tpm/tpm_tis_core.c +2 -0
@@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
               * to make sure it works. May as well use that command to set the
               * proper timeouts for the driver.
               */
+             tpm_chip_start(chip);
              if (tpm_get_timeouts(chip)) {
                      dev_err(dev, "Could not get TPM timeouts and durations\n");
                      rc = -ENODEV;
+                     tpm_stop_chip(chip);
                      goto out_err;
              }

Couldn't this call just be removed?

Quoted 6 lines
Quoted 2 lines

/Jarkko

Probably. It will eventually get called when tpm_chip_register happens. I don't know what the reason was for trying it prior to the irq probe.

At least tis once needed the timeouts before registration because it was issuing TPM commands to complete its setup.

If timeouts have not been set then no TPM command should be executed.

Jason

#5 lore raw
Quoted 44 lines · Jason Gunthorpe
Quoted 35 lines · Jerry Snitselaar
Quoted 33 lines · Jarkko Sakkinen
Quoted 18 lines · Jerry Snitselaar

With power gating moved out of the tpm_transmit code we need to power on the TPM prior to calling tpm_get_timeouts.

Cc Jarkko Sakkinen <[email protected]>
Cc Peter Huewe <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Fixes a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
 drivers/char/tpm/tpm_tis_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +1 -0
index 270f43acbb77..cb101cec8f8b 100644
+++ b/drivers/char/tpm/tpm_tis_core.c

drivers/char/tpm/tpm_tis_core.c int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, · line 983

Quoted 10 lines
drivers/char/tpm/tpm_tis_core.c +2 -0
@@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
               * to make sure it works. May as well use that command to set the
               * proper timeouts for the driver.
               */
+             tpm_chip_start(chip);
              if (tpm_get_timeouts(chip)) {
                      dev_err(dev, "Could not get TPM timeouts and durations\n");
                      rc = -ENODEV;
+                     tpm_stop_chip(chip);
                      goto out_err;
              }

Couldn't this call just be removed?

Quoted 6 lines
Quoted 2 lines

/Jarkko

Probably. It will eventually get called when tpm_chip_register happens. I don't know what the reason was for trying it prior to the irq probe.

Quoted 7 lines

At least tis once needed the timeouts before registration because it was issuing TPM commands to complete its setup.

If timeouts have not been set then no TPM command should be executed.

Jason

Would it function with the timeout values set at the beginning of tpm_tis_core_init (max values)?

#6 lore raw
Quoted 49 lines · Jerry Snitselaar
Quoted 47 lines · Jason Gunthorpe
Quoted 35 lines · Jerry Snitselaar
Quoted 33 lines · Jarkko Sakkinen
Quoted 18 lines · Jerry Snitselaar

With power gating moved out of the tpm_transmit code we need to power on the TPM prior to calling tpm_get_timeouts.

Cc Jarkko Sakkinen <[email protected]>
Cc Peter Huewe <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Fixes a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
 drivers/char/tpm/tpm_tis_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +1 -0
index 270f43acbb77..cb101cec8f8b 100644
+++ b/drivers/char/tpm/tpm_tis_core.c

drivers/char/tpm/tpm_tis_core.c int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, · line 983

Quoted 10 lines
drivers/char/tpm/tpm_tis_core.c +2 -0
@@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
               * to make sure it works. May as well use that command to set the
               * proper timeouts for the driver.
               */
+             tpm_chip_start(chip);
              if (tpm_get_timeouts(chip)) {
                      dev_err(dev, "Could not get TPM timeouts and durations\n");
                      rc = -ENODEV;
+                     tpm_stop_chip(chip);
                      goto out_err;
              }

Couldn't this call just be removed?

Quoted 6 lines
Quoted 2 lines

/Jarkko

Probably. It will eventually get called when tpm_chip_register happens. I don't know what the reason was for trying it prior to the irq probe.

At least tis once needed the timeouts before registration because it was issuing TPM commands to complete its setup.

Quoted 7 lines
Quoted 4 lines

If timeouts have not been set then no TPM command should be executed.

Jason

Would it function with the timeout values set at the beginning of tpm_tis_core_init (max values)?

I guess that doesn't set the duration values though

#7 lore raw
Quoted 50 lines · Jerry Snitselaar
Quoted 49 lines · Jerry Snitselaar
Quoted 47 lines · Jason Gunthorpe
Quoted 35 lines · Jerry Snitselaar
Quoted 33 lines · Jarkko Sakkinen
Quoted 18 lines · Jerry Snitselaar

With power gating moved out of the tpm_transmit code we need to power on the TPM prior to calling tpm_get_timeouts.

Cc Jarkko Sakkinen <[email protected]>
Cc Peter Huewe <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Fixes a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
 drivers/char/tpm/tpm_tis_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +1 -0
index 270f43acbb77..cb101cec8f8b 100644
+++ b/drivers/char/tpm/tpm_tis_core.c

drivers/char/tpm/tpm_tis_core.c int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, · line 983

Quoted 10 lines
drivers/char/tpm/tpm_tis_core.c +2 -0
@@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
               * to make sure it works. May as well use that command to set the
               * proper timeouts for the driver.
               */
+             tpm_chip_start(chip);
              if (tpm_get_timeouts(chip)) {
                      dev_err(dev, "Could not get TPM timeouts and durations\n");
                      rc = -ENODEV;
+                     tpm_stop_chip(chip);
                      goto out_err;
              }

Couldn't this call just be removed?

Quoted 6 lines
Quoted 2 lines

/Jarkko

Probably. It will eventually get called when tpm_chip_register happens. I don't know what the reason was for trying it prior to the irq probe.

At least tis once needed the timeouts before registration because it was issuing TPM commands to complete its setup.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

If timeouts have not been set then no TPM command should be executed.

Would it function with the timeout values set at the beginning of tpm_tis_core_init (max values)?

I guess that doesn't set the duration values though

There is no reason to use anything but the correct timeouts, as read from the device.

Jason

#8 lore raw
Quoted 56 lines · Jason Gunthorpe
Quoted 55 lines · Jerry Snitselaar
Quoted 53 lines · Jerry Snitselaar
Quoted 40 lines · Jason Gunthorpe
Quoted 38 lines · Jerry Snitselaar
Quoted 35 lines · Jarkko Sakkinen
Quoted 18 lines · Jerry Snitselaar

With power gating moved out of the tpm_transmit code we need to power on the TPM prior to calling tpm_get_timeouts.

Cc Jarkko Sakkinen <[email protected]>
Cc Peter Huewe <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Fixes a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
 drivers/char/tpm/tpm_tis_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +1 -0
index 270f43acbb77..cb101cec8f8b 100644
+++ b/drivers/char/tpm/tpm_tis_core.c

drivers/char/tpm/tpm_tis_core.c int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, · line 983

Quoted 10 lines
drivers/char/tpm/tpm_tis_core.c +2 -0
@@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
               * to make sure it works. May as well use that command to set the
               * proper timeouts for the driver.
               */
+             tpm_chip_start(chip);
              if (tpm_get_timeouts(chip)) {
                      dev_err(dev, "Could not get TPM timeouts and durations\n");
                      rc = -ENODEV;
+                     tpm_stop_chip(chip);
                      goto out_err;
              }

Couldn't this call just be removed?

/Jarkko

Quoted 8 lines
Quoted 3 lines

Probably. It will eventually get called when tpm_chip_register happens. I don't know what the reason was for trying it prior to the irq probe.

At least tis once needed the timeouts before registration because it was issuing TPM commands to complete its setup.

If timeouts have not been set then no TPM command should be executed.

Would it function with the timeout values set at the beginning of tpm_tis_core_init (max values)?

Quoted 7 lines
Quoted 1 line

I guess that doesn't set the duration values though

There is no reason to use anything but the correct timeouts, as read from the device.

Jason

Should there be a check in tpm1_get_timeouts and tpm2_get_timeouts:

	if (chip->flags & TPM_CHIP_FLAG_HAVE_TIMEOUTS)
		return 0;

to skip going through it again in the auto startup code if it was already called and set?

#9 lore raw
In reply to Jerry Snitselaar
Quoted 48 lines · Jerry Snitselaar
Quoted 47 lines · Jason Gunthorpe
Quoted 35 lines · Jerry Snitselaar
Quoted 33 lines · Jarkko Sakkinen
Quoted 18 lines · Jerry Snitselaar

With power gating moved out of the tpm_transmit code we need to power on the TPM prior to calling tpm_get_timeouts.

Cc Jarkko Sakkinen <[email protected]>
Cc Peter Huewe <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Fixes a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
 drivers/char/tpm/tpm_tis_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +1 -0
index 270f43acbb77..cb101cec8f8b 100644
+++ b/drivers/char/tpm/tpm_tis_core.c

drivers/char/tpm/tpm_tis_core.c int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, · line 983

Quoted 10 lines
drivers/char/tpm/tpm_tis_core.c +2 -0
@@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
               * to make sure it works. May as well use that command to set the
               * proper timeouts for the driver.
               */
+             tpm_chip_start(chip);
              if (tpm_get_timeouts(chip)) {
                      dev_err(dev, "Could not get TPM timeouts and durations\n");
                      rc = -ENODEV;
+                     tpm_stop_chip(chip);
                      goto out_err;
              }

Couldn't this call just be removed?

Quoted 6 lines
Quoted 2 lines

/Jarkko

Probably. It will eventually get called when tpm_chip_register happens. I don't know what the reason was for trying it prior to the irq probe.

At least tis once needed the timeouts before registration because it was issuing TPM commands to complete its setup.

Quoted 7 lines
Quoted 4 lines

If timeouts have not been set then no TPM command should be executed.

Jason

Would it function with the timeout values set at the beginning of tpm_tis_core_init (max values)?

tpm_get_timeouts() should be replaced with:

if (tpm_chip_start()) {
	dev_err(dev, "Could not get TPM timeouts and durations\n");
	rc = -ENODEV;
	goto out_err;
}

tpm_stop_chip(chip);

tpm_get_timeouts() is called by tpm_auto_startup(). Also the function should be moved to tpm_chip.c and converted to a static function so that it won't be called from random cal sites like above.

/Jarkko

#10 lore raw
Quoted 11 lines · Jarkko Sakkinen
Quoted 2 lines

Would it function with the timeout values set at the beginning of tpm_tis_core_init (max values)?

tpm_get_timeouts() should be replaced with:

if (tpm_chip_start()) {
	dev_err(dev, "Could not get TPM timeouts and durations\n");
	rc = -ENODEV;
	goto out_err;
}
Quoted 5 lines

tpm_stop_chip(chip);

tpm_get_timeouts() is called by tpm_auto_startup(). Also the function should be moved to tpm_chip.c and converted to a static function so that it won't be called from random cal sites like above.

Careful, the design here was to allow a driver to do only get_timeouts, then additional setup work, then do auto_startup()

Forcing a driver to do auto_startup too early may not be good.

Jason

#11 lore raw
Quoted 14 lines · Jason Gunthorpe
Quoted 13 lines · Jarkko Sakkinen
Quoted 2 lines

Would it function with the timeout values set at the beginning of tpm_tis_core_init (max values)?

tpm_get_timeouts() should be replaced with:

if (tpm_chip_start()) {
	dev_err(dev, "Could not get TPM timeouts and durations\n");
	rc = -ENODEV;
	goto out_err;
}

tpm_stop_chip(chip);

Quoted 8 lines
Quoted 3 lines

tpm_get_timeouts() is called by tpm_auto_startup(). Also the function should be moved to tpm_chip.c and converted to a static function so that it won't be called from random cal sites like above.

Careful, the design here was to allow a driver to do only get_timeouts, then additional setup work, then do auto_startup()

Forcing a driver to do auto_startup too early may not be good.

All drivers always do it anyway because all drivers always call tpm_chip_register().

/Jarkko

#12 lore raw
Quoted 19 lines · Jarkko Sakkinen
Quoted 18 lines · Jason Gunthorpe
Quoted 16 lines · Jarkko Sakkinen
Quoted 2 lines

Would it function with the timeout values set at the beginning of tpm_tis_core_init (max values)?

tpm_get_timeouts() should be replaced with:

if (tpm_chip_start()) {
	dev_err(dev, "Could not get TPM timeouts and durations\n");
	rc = -ENODEV;
	goto out_err;
}

tpm_stop_chip(chip);

tpm_get_timeouts() is called by tpm_auto_startup(). Also the function should be moved to tpm_chip.c and converted to a static function so that it won't be called from random cal sites like above.

Quoted 7 lines
Quoted 4 lines

Careful, the design here was to allow a driver to do only get_timeouts, then additional setup work, then do auto_startup()

Forcing a driver to do auto_startup too early may not be good.

All drivers always do it anyway because all drivers always call tpm_chip_register().

But chip_register is after the driver has done it's setup and after it may have called get_timeouts

auto_setup should not be moved to before chip_register()

Jason

#13 lore raw
Quoted 25 lines · Jason Gunthorpe
Quoted 24 lines · Jarkko Sakkinen
Quoted 22 lines · Jason Gunthorpe
Quoted 11 lines · Jarkko Sakkinen
Quoted 2 lines

Would it function with the timeout values set at the beginning of tpm_tis_core_init (max values)?

tpm_get_timeouts() should be replaced with:

if (tpm_chip_start()) {
	dev_err(dev, "Could not get TPM timeouts and durations\n");
	rc = -ENODEV;
	goto out_err;
}
Quoted 5 lines

tpm_stop_chip(chip);

tpm_get_timeouts() is called by tpm_auto_startup(). Also the function should be moved to tpm_chip.c and converted to a static function so that it won't be called from random cal sites like above.

Careful, the design here was to allow a driver to do only get_timeouts, then additional setup work, then do auto_startup()

Forcing a driver to do auto_startup too early may not be good.

Quoted 7 lines
Quoted 2 lines

All drivers always do it anyway because all drivers always call tpm_chip_register().

But chip_register is after the driver has done it's setup and after it may have called get_timeouts

auto_setup should not be moved to before chip_register()

I do not see any sense calling from get_timeouts() from call sites in the same initialization flow.

/Jarkko

#14 lore raw
In reply to Jason Gunthorpe
Quoted 39 lines · Jason Gunthorpe
Quoted 38 lines · Jerry Snitselaar
Quoted 35 lines · Jarkko Sakkinen
Quoted 18 lines · Jerry Snitselaar

With power gating moved out of the tpm_transmit code we need to power on the TPM prior to calling tpm_get_timeouts.

Cc Jarkko Sakkinen <[email protected]>
Cc Peter Huewe <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Fixes a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
 drivers/char/tpm/tpm_tis_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +1 -0
index 270f43acbb77..cb101cec8f8b 100644
+++ b/drivers/char/tpm/tpm_tis_core.c

drivers/char/tpm/tpm_tis_core.c int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, · line 983

Quoted 10 lines
drivers/char/tpm/tpm_tis_core.c +2 -0
@@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
               * to make sure it works. May as well use that command to set the
               * proper timeouts for the driver.
               */
+             tpm_chip_start(chip);
              if (tpm_get_timeouts(chip)) {
                      dev_err(dev, "Could not get TPM timeouts and durations\n");
                      rc = -ENODEV;
+                     tpm_stop_chip(chip);
                      goto out_err;
              }

Couldn't this call just be removed?

/Jarkko

Quoted 8 lines
Quoted 3 lines

Probably. It will eventually get called when tpm_chip_register happens. I don't know what the reason was for trying it prior to the irq probe.

At least tis once needed the timeouts before registration because it was issuing TPM commands to complete its setup.

If timeouts have not been set then no TPM command should be executed.

Not true since you need a TPM command to set them. That is why they have been set initially to maximum possible values.

/Jarkko

#15 lore raw
Quoted 44 lines · Jarkko Sakkinen
Quoted 43 lines · Jason Gunthorpe
Quoted 41 lines · Jerry Snitselaar
Quoted 33 lines · Jarkko Sakkinen
Quoted 18 lines · Jerry Snitselaar

With power gating moved out of the tpm_transmit code we need to power on the TPM prior to calling tpm_get_timeouts.

Cc Jarkko Sakkinen <[email protected]>
Cc Peter Huewe <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Fixes a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
 drivers/char/tpm/tpm_tis_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +1 -0
index 270f43acbb77..cb101cec8f8b 100644
+++ b/drivers/char/tpm/tpm_tis_core.c

drivers/char/tpm/tpm_tis_core.c int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, · line 983

Quoted 10 lines
drivers/char/tpm/tpm_tis_core.c +2 -0
@@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
               * to make sure it works. May as well use that command to set the
               * proper timeouts for the driver.
               */
+             tpm_chip_start(chip);
              if (tpm_get_timeouts(chip)) {
                      dev_err(dev, "Could not get TPM timeouts and durations\n");
                      rc = -ENODEV;
+                     tpm_stop_chip(chip);
                      goto out_err;
              }

Couldn't this call just be removed?

Quoted 2 lines

/Jarkko

Probably. It will eventually get called when tpm_chip_register happens. I don't know what the reason was for trying it prior to the irq probe.

Quoted 7 lines
Quoted 4 lines

At least tis once needed the timeouts before registration because it was issuing TPM commands to complete its setup.

If timeouts have not been set then no TPM command should be executed.

Not true since you need a TPM command to set them. That is why they have been set initially to maximum possible values.

getting timeouts is the exception

Jason

#16 lore raw

PATCH v3 1/1 tpm_tis: turn on TPM before calling tpm_get_timeouts

In reply to Jerry Snitselaar

With power gating moved out of the tpm_transmit code we need to power on the TPM prior to calling tpm_get_timeouts.

Cc Jarkko Sakkinen <[email protected]>
Cc Peter Huewe <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Fixes a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")

---
v3: call tpm_chip_stop in error path
v2: fix stable cc to correct address

 drivers/char/tpm/tpm_tis_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +2 -1
index 270f43acbb77..806acc666696 100644
@@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
 		 * to make sure it works. May as well use that command to set the
 		 * proper timeouts for the driver.
 		 */
+		tpm_chip_start(chip);
 		if (tpm_get_timeouts(chip)) {
 			dev_err(dev, "Could not get TPM timeouts and durations\n");
 			rc = -ENODEV;
+			tpm_chip_stop(chip);
 			goto out_err;
 		}
 
-		tpm_chip_start(chip);
 		chip->flags |= TPM_CHIP_FLAG_IRQ;
 		if (irq) {
 			tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED,
Signature · 1 line
2.24.0
#17 lore raw
Quoted 25 lines · Jerry Snitselaar

With power gating moved out of the tpm_transmit code we need to power on the TPM prior to calling tpm_get_timeouts.

Cc Jarkko Sakkinen <[email protected]>
Cc Peter Huewe <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Fixes a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")

---
v3: call tpm_chip_stop in error path
v2: fix stable cc to correct address

 drivers/char/tpm/tpm_tis_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +0 -0
index 270f43acbb77..806acc666696 100644
@@ -974,13 +974,14 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
 		 * to make sure it works. May as well use that command to set the
 		 * proper timeouts for the driver.

drivers/char/tpm/tpm_tis_core.c int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, · line 983

Quoted 10 lines
drivers/char/tpm/tpm_tis_core.c +2 -1
 		 */
+		tpm_chip_start(chip);
 		if (tpm_get_timeouts(chip)) {
 			dev_err(dev, "Could not get TPM timeouts and durations\n");
 			rc = -ENODEV;
+			tpm_chip_stop(chip);
 			goto out_err;
 		}
 
-		tpm_chip_start(chip);

As the commit describes the call is not there for any other reason than pinging the TPM.

/Jarkko