* [PATCH] Refuse activation of tpm_tis driver if TPM is not working correctly
@ 2011-10-10 12:16 Stefan Berger
2011-10-10 13:04 ` Rajiv Andrade
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Berger @ 2011-10-10 12:16 UTC (permalink / raw)
To: tpmdd-devel, James Morris, linux-kernel, Rajiv Andrade, m.selhorst
Cc: a.miskiewicz
Refuse activation of tpm_tis driver if the TPM is found not to be
working correctly. This prevents suspend/resume problems for me on
Lenovo W500 and T61p.
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
---
drivers/char/tpm/tpm_tis.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 3f4051a..7f2761d 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -549,6 +549,7 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
u32 vendor, intfcaps, intmask;
int rc, i, irq_s, irq_e;
struct tpm_chip *chip;
+ u8 digest[TPM_DIGEST_SIZE];
if (!(chip = tpm_register_hardware(dev, &tpm_tis)))
return -ENODEV;
@@ -616,6 +617,18 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
/* get the timeouts before testing for irqs */
tpm_get_timeouts(chip);
+ /* test for correctly working TPM; refuse driver if not working
+ to prevent suspend/resume problems */
+ rc = tpm_pcr_read(chip->dev_num, 0, digest);
+ if (rc != 0) {
+ dev_err(dev, "Could not read PCR 0. "
+ "TPM is not working correctly.\n");
+ dev_err(dev, "Was machine previously suspended without TPM "
+ "driver present?\n");
+ rc = -ENODEV;
+ goto out_err;
+ }
+
/* INTERRUPT Setup */
init_waitqueue_head(&chip->vendor.read_queue);
init_waitqueue_head(&chip->vendor.int_queue);
--
1.7.6.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Refuse activation of tpm_tis driver if TPM is not working correctly
2011-10-10 12:16 [PATCH] Refuse activation of tpm_tis driver if TPM is not working correctly Stefan Berger
@ 2011-10-10 13:04 ` Rajiv Andrade
2011-10-10 15:07 ` [tpmdd-devel] " Rajiv Andrade
0 siblings, 1 reply; 3+ messages in thread
From: Rajiv Andrade @ 2011-10-10 13:04 UTC (permalink / raw)
To: Stefan Berger
Cc: tpmdd-devel, James Morris, linux-kernel, m.selhorst, a.miskiewicz
On 10/10/11 09:16, Stefan Berger wrote:
> Refuse activation of tpm_tis driver if the TPM is found not to be
> working correctly. This prevents suspend/resume problems for me on
> Lenovo W500 and T61p.
>
> Signed-off-by: Stefan Berger<stefanb@linux.vnet.ibm.com>
Testing and trying to reproduce it here.
Rajiv
>
> ---
> drivers/char/tpm/tpm_tis.c | 13 +++++++++++++
> 1 files changed, 13 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
> index 3f4051a..7f2761d 100644
> --- a/drivers/char/tpm/tpm_tis.c
> +++ b/drivers/char/tpm/tpm_tis.c
> @@ -549,6 +549,7 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
> u32 vendor, intfcaps, intmask;
> int rc, i, irq_s, irq_e;
> struct tpm_chip *chip;
> + u8 digest[TPM_DIGEST_SIZE];
>
> if (!(chip = tpm_register_hardware(dev,&tpm_tis)))
> return -ENODEV;
> @@ -616,6 +617,18 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
> /* get the timeouts before testing for irqs */
> tpm_get_timeouts(chip);
>
> + /* test for correctly working TPM; refuse driver if not working
> + to prevent suspend/resume problems */
> + rc = tpm_pcr_read(chip->dev_num, 0, digest);
> + if (rc != 0) {
> + dev_err(dev, "Could not read PCR 0. "
> + "TPM is not working correctly.\n");
> + dev_err(dev, "Was machine previously suspended without TPM "
> + "driver present?\n");
> + rc = -ENODEV;
> + goto out_err;
> + }
> +
> /* INTERRUPT Setup */
> init_waitqueue_head(&chip->vendor.read_queue);
> init_waitqueue_head(&chip->vendor.int_queue);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [tpmdd-devel] [PATCH] Refuse activation of tpm_tis driver if TPM is not working correctly
2011-10-10 13:04 ` Rajiv Andrade
@ 2011-10-10 15:07 ` Rajiv Andrade
0 siblings, 0 replies; 3+ messages in thread
From: Rajiv Andrade @ 2011-10-10 15:07 UTC (permalink / raw)
To: Stefan Berger
Cc: a.miskiewicz, m.selhorst, tpmdd-devel, James Morris, linux-kernel
On 10/10/11 10:04, Rajiv Andrade wrote:
> On 10/10/11 09:16, Stefan Berger wrote:
>> Refuse activation of tpm_tis driver if the TPM is found not to be
>> working correctly. This prevents suspend/resume problems for me on
>> Lenovo W500 and T61p.
>>
>> Signed-off-by: Stefan Berger<stefanb@linux.vnet.ibm.com>
> Testing and trying to reproduce it here.
Yes, for some yet unknown reason the TPM doesn't respond after a
suspend/resume in case
it wasn't loaded before that. With this change/check, suspends work fine
in this scenario
for me as well. Applied to:
github.com/srajiv/tpm.git next-tpm-fixes
Thanks for the fix Stefan.
Rajiv
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-10-10 15:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-10 12:16 [PATCH] Refuse activation of tpm_tis driver if TPM is not working correctly Stefan Berger
2011-10-10 13:04 ` Rajiv Andrade
2011-10-10 15:07 ` [tpmdd-devel] " Rajiv Andrade
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).