diff mbox

tpm: self test failure should not cause suspend to fail

Message ID 20180320073640.17062-1-drake@endlessm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Drake March 20, 2018, 7:36 a.m. UTC
From: Chris Chiu <chiu@endlessm.com>

The Acer Acer Veriton X4110G has a TPM device detected as:
  tpm_tis 00:0b: 1.2 TPM (device-id 0xFE, rev-id 71)

After the first S3 suspend, the following error appears during resume:
  tpm tpm0: A TPM error(38) occured continue selftest

Any following S3 suspend attempts will now fail with this error:
  tpm tpm0: Error (38) sending savestate before suspend
  PM: Device 00:0b failed to suspend: error 38

Error 38 is TPM_ERR_INVALID_POSTINIT which means the TPM is
not in the correct state. This indicates that the platform BIOS
is not sending the usual TPM_Startup command during S3 resume.
From this point onwards, all TPM commands will fail.

The same issue was previously reported on Foxconn 6150BK8MC and
Sony Vaio TX3.

The platform behaviour seems broken here, but we should not break
suspend/resume because of this.

When the unexpected TPM state is encountered, set a flag to skip the
affected TPM_SaveState command on later suspends.

Signed-off-by: Chris Chiu <chiu@endlessm.com>
Signed-off-by: Daniel Drake <drake@endlessm.com>
Link: http://lkml.kernel.org/r/CAB4CAwfSCvj1cudi+MWaB5g2Z67d9DwY1o475YOZD64ma23UiQ@mail.gmail.com
Link: https://lkml.org/lkml/2011/3/28/192
Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=591031
---
 drivers/char/tpm/tpm-interface.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Jarkko Sakkinen March 22, 2018, 2:02 p.m. UTC | #1
On Tue, 2018-03-20 at 15:36 +0800, Daniel Drake wrote:
> From: Chris Chiu <chiu@endlessm.com>
> 
> The Acer Acer Veriton X4110G has a TPM device detected as:
>   tpm_tis 00:0b: 1.2 TPM (device-id 0xFE, rev-id 71)
> 
> After the first S3 suspend, the following error appears during resume:
>   tpm tpm0: A TPM error(38) occured continue selftest
> 
> Any following S3 suspend attempts will now fail with this error:
>   tpm tpm0: Error (38) sending savestate before suspend
>   PM: Device 00:0b failed to suspend: error 38
> 
> Error 38 is TPM_ERR_INVALID_POSTINIT which means the TPM is
> not in the correct state. This indicates that the platform BIOS
> is not sending the usual TPM_Startup command during S3 resume.
> From this point onwards, all TPM commands will fail.
> 
> The same issue was previously reported on Foxconn 6150BK8MC and
> Sony Vaio TX3.
> 
> The platform behaviour seems broken here, but we should not break
> suspend/resume because of this.
> 
> When the unexpected TPM state is encountered, set a flag to skip the
> affected TPM_SaveState command on later suspends.
> 
> Signed-off-by: Chris Chiu <chiu@endlessm.com>
> Signed-off-by: Daniel Drake <drake@endlessm.com>
> Link: http://lkml.kernel.org/r/CAB4CAwfSCvj1cudi+MWaB5g2Z67d9DwY1o475YOZD64ma2
> 3UiQ@mail.gmail.com
> Link: https://lkml.org/lkml/2011/3/28/192
> Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=591031

Thank you.

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

/Jarkko
Jarkko Sakkinen March 22, 2018, 2:05 p.m. UTC | #2
On Thu, 2018-03-22 at 16:02 +0200, Jarkko Sakkinen wrote:
> On Tue, 2018-03-20 at 15:36 +0800, Daniel Drake wrote:
> > From: Chris Chiu <chiu@endlessm.com>
> > 
> > The Acer Acer Veriton X4110G has a TPM device detected as:
> >   tpm_tis 00:0b: 1.2 TPM (device-id 0xFE, rev-id 71)
> > 
> > After the first S3 suspend, the following error appears during resume:
> >   tpm tpm0: A TPM error(38) occured continue selftest
> > 
> > Any following S3 suspend attempts will now fail with this error:
> >   tpm tpm0: Error (38) sending savestate before suspend
> >   PM: Device 00:0b failed to suspend: error 38
> > 
> > Error 38 is TPM_ERR_INVALID_POSTINIT which means the TPM is
> > not in the correct state. This indicates that the platform BIOS
> > is not sending the usual TPM_Startup command during S3 resume.
> > From this point onwards, all TPM commands will fail.
> > 
> > The same issue was previously reported on Foxconn 6150BK8MC and
> > Sony Vaio TX3.
> > 
> > The platform behaviour seems broken here, but we should not break
> > suspend/resume because of this.
> > 
> > When the unexpected TPM state is encountered, set a flag to skip the
> > affected TPM_SaveState command on later suspends.
> > 
> > Signed-off-by: Chris Chiu <chiu@endlessm.com>
> > Signed-off-by: Daniel Drake <drake@endlessm.com>
> > Link: http://lkml.kernel.org/r/CAB4CAwfSCvj1cudi+MWaB5g2Z67d9DwY1o475YOZD64m
> > a2
> > 3UiQ@mail.gmail.com
> > Link: https://lkml.org/lkml/2011/3/28/192
> > Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=591031
> 
> Thank you.
> 
> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

Applied. I also added:

Cc: stable@vger.kernel.org

/Jarkko
diff mbox

Patch

diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 9e80a953d693..248c04090dea 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -969,6 +969,10 @@  int tpm_do_selftest(struct tpm_chip *chip)
 	loops = jiffies_to_msecs(duration) / delay_msec;
 
 	rc = tpm_continue_selftest(chip);
+	if (rc == TPM_ERR_INVALID_POSTINIT) {
+		chip->flags |= TPM_CHIP_FLAG_ALWAYS_POWERED;
+		dev_info(&chip->dev, "TPM not ready (%d)\n", rc);
+	}
 	/* This may fail if there was no TPM driver during a suspend/resume
 	 * cycle; some may return 10 (BAD_ORDINAL), others 28 (FAILEDSELFTEST)
 	 */