public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tpm_tis: fix iTPM probe via probe_itpm() function
@ 2017-01-12 18:12 Maciej S. Szmigiero
  2017-01-12 18:50 ` Jason Gunthorpe
  2017-01-12 20:29 ` Jarkko Sakkinen
  0 siblings, 2 replies; 4+ messages in thread
From: Maciej S. Szmigiero @ 2017-01-12 18:12 UTC (permalink / raw)
  To: tpmdd-devel
  Cc: linux-kernel, Peter Huewe, Marcel Selhorst, Jarkko Sakkinen,
	Christophe Ricard, Jason Gunthorpe

probe_itpm() function is supposed to send command without an itpm flag set
and if this fails to repeat it, this time with the itpm flag set.

However, commit 41a5e1cf1fe15 ("tpm/tpm_tis: Split tpm_tis driver into a
core and TCG TIS compliant phy") moved the itpm flag from an "itpm"
variable to a TPM_TIS_ITPM_POSSIBLE chip flag, so setting the
(now function-local) itpm variable no longer had any effect.

Finally, this function-local itpm variable was removed by
commit 56af322156dbe9 ("tpm/tpm_tis: remove unused itpm variable")

Tested only on non-iTPM TIS TPM.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>

Fixes: 41a5e1cf1fe15 ("Split tpm_tis driver into a core and TCG TIS compliant phy")
Cc: stable@vger.kernel.org
---
 drivers/char/tpm/tpm_tis_core.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index e42e5a6a3c2f..401f1228547c 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -467,6 +467,9 @@ static int probe_itpm(struct tpm_chip *chip)
 	size_t len = sizeof(cmd_getticks);
 	u16 vendor;
 
+	if (priv->flags & TPM_TIS_ITPM_POSSIBLE)
+		return 0;
+
 	rc = tpm_tis_read16(priv, TPM_DID_VID(0), &vendor);
 	if (rc < 0)
 		return rc;
@@ -482,12 +485,15 @@ static int probe_itpm(struct tpm_chip *chip)
 	tpm_tis_ready(chip);
 	release_locality(chip, priv->locality, 0);
 
+	priv->flags |= TPM_TIS_ITPM_POSSIBLE;
+
 	rc = tpm_tis_send_data(chip, cmd_getticks, len);
-	if (rc == 0) {
+	if (rc == 0)
 		dev_info(&chip->dev, "Detected an iTPM.\n");
-		rc = 1;
-	} else
+	else {
+		priv->flags &= ~TPM_TIS_ITPM_POSSIBLE;
 		rc = -EFAULT;
+	}
 
 out:
 	tpm_tis_ready(chip);
@@ -743,15 +749,10 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
 		 (chip->flags & TPM_CHIP_FLAG_TPM2) ? "2.0" : "1.2",
 		 vendor >> 16, rid);
 
-	if (!(priv->flags & TPM_TIS_ITPM_POSSIBLE)) {
-		probe = probe_itpm(chip);
-		if (probe < 0) {
-			rc = -ENODEV;
-			goto out_err;
-		}
-
-		if (!!probe)
-			priv->flags |= TPM_TIS_ITPM_POSSIBLE;
+	probe = probe_itpm(chip);
+	if (probe < 0) {
+		rc = -ENODEV;
+		goto out_err;
 	}
 
 	/* Figure out the capabilities */

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] tpm_tis: fix iTPM probe via probe_itpm() function
  2017-01-12 18:12 [PATCH] tpm_tis: fix iTPM probe via probe_itpm() function Maciej S. Szmigiero
@ 2017-01-12 18:50 ` Jason Gunthorpe
  2017-01-12 20:10   ` Maciej S. Szmigiero
  2017-01-12 20:29 ` Jarkko Sakkinen
  1 sibling, 1 reply; 4+ messages in thread
From: Jason Gunthorpe @ 2017-01-12 18:50 UTC (permalink / raw)
  To: Maciej S. Szmigiero
  Cc: tpmdd-devel, linux-kernel, Peter Huewe, Marcel Selhorst,
	Jarkko Sakkinen, Christophe Ricard

On Thu, Jan 12, 2017 at 07:12:06PM +0100, Maciej S. Szmigiero wrote:
> probe_itpm() function is supposed to send command without an itpm flag set
> and if this fails to repeat it, this time with the itpm flag set.
> 
> However, commit 41a5e1cf1fe15 ("tpm/tpm_tis: Split tpm_tis driver into a
> core and TCG TIS compliant phy") moved the itpm flag from an "itpm"
> variable to a TPM_TIS_ITPM_POSSIBLE chip flag, so setting the
> (now function-local) itpm variable no longer had any effect.
> 
> Finally, this function-local itpm variable was removed by
> commit 56af322156dbe9 ("tpm/tpm_tis: remove unused itpm variable")
> 
> Tested only on non-iTPM TIS TPM.
> 
> Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>

could you also change the name of TPM_TIS_ITPM_POSSIBLE
to TPM_TIS_ITPM_WORKAROUND ?

Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tpm_tis: fix iTPM probe via probe_itpm() function
  2017-01-12 18:50 ` Jason Gunthorpe
@ 2017-01-12 20:10   ` Maciej S. Szmigiero
  0 siblings, 0 replies; 4+ messages in thread
From: Maciej S. Szmigiero @ 2017-01-12 20:10 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: tpmdd-devel, linux-kernel, Peter Huewe, Marcel Selhorst,
	Jarkko Sakkinen, Christophe Ricard

On 12.01.2017 19:50, Jason Gunthorpe wrote:
> On Thu, Jan 12, 2017 at 07:12:06PM +0100, Maciej S. Szmigiero wrote:
>> probe_itpm() function is supposed to send command without an itpm flag set
>> and if this fails to repeat it, this time with the itpm flag set.
>>
>> However, commit 41a5e1cf1fe15 ("tpm/tpm_tis: Split tpm_tis driver into a
>> core and TCG TIS compliant phy") moved the itpm flag from an "itpm"
>> variable to a TPM_TIS_ITPM_POSSIBLE chip flag, so setting the
>> (now function-local) itpm variable no longer had any effect.
>>
>> Finally, this function-local itpm variable was removed by
>> commit 56af322156dbe9 ("tpm/tpm_tis: remove unused itpm variable")
>>
>> Tested only on non-iTPM TIS TPM.
>>
>> Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
> 
> could you also change the name of TPM_TIS_ITPM_POSSIBLE
> to TPM_TIS_ITPM_WORKAROUND ?

I will prepare such patch.

> Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
> Jason

Maciej

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tpm_tis: fix iTPM probe via probe_itpm() function
  2017-01-12 18:12 [PATCH] tpm_tis: fix iTPM probe via probe_itpm() function Maciej S. Szmigiero
  2017-01-12 18:50 ` Jason Gunthorpe
@ 2017-01-12 20:29 ` Jarkko Sakkinen
  1 sibling, 0 replies; 4+ messages in thread
From: Jarkko Sakkinen @ 2017-01-12 20:29 UTC (permalink / raw)
  To: Maciej S. Szmigiero
  Cc: tpmdd-devel, linux-kernel, Peter Huewe, Marcel Selhorst,
	Christophe Ricard, Jason Gunthorpe

On Thu, Jan 12, 2017 at 07:12:06PM +0100, Maciej S. Szmigiero wrote:
> probe_itpm() function is supposed to send command without an itpm flag set
> and if this fails to repeat it, this time with the itpm flag set.
> 
> However, commit 41a5e1cf1fe15 ("tpm/tpm_tis: Split tpm_tis driver into a
> core and TCG TIS compliant phy") moved the itpm flag from an "itpm"
> variable to a TPM_TIS_ITPM_POSSIBLE chip flag, so setting the
> (now function-local) itpm variable no longer had any effect.
> 
> Finally, this function-local itpm variable was removed by
> commit 56af322156dbe9 ("tpm/tpm_tis: remove unused itpm variable")
> 
> Tested only on non-iTPM TIS TPM.
> 
> Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
> 
> Fixes: 41a5e1cf1fe15 ("Split tpm_tis driver into a core and TCG TIS compliant phy")
> Cc: stable@vger.kernel.org

Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

/Jarkko

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-01-12 20:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-12 18:12 [PATCH] tpm_tis: fix iTPM probe via probe_itpm() function Maciej S. Szmigiero
2017-01-12 18:50 ` Jason Gunthorpe
2017-01-12 20:10   ` Maciej S. Szmigiero
2017-01-12 20:29 ` Jarkko Sakkinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox