All of lore.kernel.org
 help / color / mirror / Atom feed
* TPM driver breaks S3 suspend
@ 2017-12-21  8:04 Chris Chiu
  2017-12-21  9:22   ` Paul Menzel
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Chris Chiu @ 2017-12-21  8:04 UTC (permalink / raw)
  To: peterhuewe, jarkko.sakkinen, jgg, linux-integrity, Linux Kernel,
	Linux Upstreaming Team

Hi,
    We have a desktop which has S3 suspend (to RAM) problem due to
error messages as follows.
[  198.908282] tpm tpm0: Error (38) sending savestate before suspend
[  198.908289] __pnp_bus_suspend(): tpm_pm_suspend+0x0/0x160 returns 38
[  198.908293] dpm_run_callback(): pnp_bus_suspend+0x0/0x20 returns 38
[  198.908298] PM: Device 00:0b failed to suspend: error 38

    However, the first suspend after boot is working although it still
shows an interesting message during resume.
[  155.789945] tpm tpm0: A TPM error (38) occurred continue selftest

    The error code 38 in definition is TPM_ERR_INVALID_POSTINIT. I
found some explanations which said this error code means that this
command was received in the wrong sequence relative to a TPM_Startup
command. Don't really know what happens here and how should I deal
with this? Any suggestions? Please let me know what else information
should I provide. Thanks

Chris

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

* Re: TPM driver breaks S3 suspend
  2017-12-21  8:04 TPM driver breaks S3 suspend Chris Chiu
@ 2017-12-21  9:22   ` Paul Menzel
  2017-12-21 10:19 ` Alexander.Steffen
  2017-12-24 20:33 ` Jarkko Sakkinen
  2 siblings, 0 replies; 16+ messages in thread
From: Paul Menzel @ 2017-12-21  9:22 UTC (permalink / raw)
  To: Chris Chiu, linux-kernel, Linux Upstreaming Team, Alexander Steffen
  Cc: Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe, linux-integrity

[-- Attachment #1: Type: text/plain, Size: 1198 bytes --]

Dear Chris,


Thank you for bringin gup the issue.

>      We have a desktop which has S3 suspend (to RAM) problem due to
> error messages as follows.
> [  198.908282] tpm tpm0: Error (38) sending savestate before suspend
> [  198.908289] __pnp_bus_suspend(): tpm_pm_suspend+0x0/0x160 returns 38
> [  198.908293] dpm_run_callback(): pnp_bus_suspend+0x0/0x20 returns 38
> [  198.908298] PM: Device 00:0b failed to suspend: error 38
> 
>      However, the first suspend after boot is working although it still
> shows an interesting message during resume.
> [  155.789945] tpm tpm0: A TPM error (38) occurred continue selftest
> 
>      The error code 38 in definition is TPM_ERR_INVALID_POSTINIT. I
> found some explanations which said this error code means that this
> command was received in the wrong sequence relative to a TPM_Startup
> command. Don't really know what happens here and how should I deal
> with this? Any suggestions? Please let me know what else information
> should I provide.

Please provide more information. Tell us your Linux version, attach your 
config and tell us the system name and if you know it the TPM version.


Kind regards,

Paul


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5174 bytes --]

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

* Re: TPM driver breaks S3 suspend
@ 2017-12-21  9:22   ` Paul Menzel
  0 siblings, 0 replies; 16+ messages in thread
From: Paul Menzel @ 2017-12-21  9:22 UTC (permalink / raw)
  To: Chris Chiu, linux-kernel, Linux Upstreaming Team, Alexander Steffen
  Cc: Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe, linux-integrity

[-- Attachment #1: Type: multipart/signed, Size: 1317 bytes --]

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

* Re: TPM driver breaks S3 suspend
  2017-12-21  9:22   ` Paul Menzel
  (?)
@ 2017-12-21  9:43   ` Chris Chiu
  2017-12-24 20:35     ` Jarkko Sakkinen
  -1 siblings, 1 reply; 16+ messages in thread
From: Chris Chiu @ 2017-12-21  9:43 UTC (permalink / raw)
  To: Paul Menzel
  Cc: Linux Kernel, Linux Upstreaming Team, Alexander Steffen,
	Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe, linux-integrity

On Thu, Dec 21, 2017 at 5:22 PM, Paul Menzel <pmenzel@molgen.mpg.de> wrote:
> Dear Chris,
>
>
> Thank you for bringin gup the issue.
>
>>      We have a desktop which has S3 suspend (to RAM) problem due to
>> error messages as follows.
>> [  198.908282] tpm tpm0: Error (38) sending savestate before suspend
>> [  198.908289] __pnp_bus_suspend(): tpm_pm_suspend+0x0/0x160 returns 38
>> [  198.908293] dpm_run_callback(): pnp_bus_suspend+0x0/0x20 returns 38
>> [  198.908298] PM: Device 00:0b failed to suspend: error 38
>>
>>      However, the first suspend after boot is working although it still
>> shows an interesting message during resume.
>> [  155.789945] tpm tpm0: A TPM error (38) occurred continue selftest
>>
>>      The error code 38 in definition is TPM_ERR_INVALID_POSTINIT. I
>> found some explanations which said this error code means that this
>> command was received in the wrong sequence relative to a TPM_Startup
>> command. Don't really know what happens here and how should I deal
>> with this? Any suggestions? Please let me know what else information
>> should I provide.
>
>
> Please provide more information. Tell us your Linux version, attach your
> config and tell us the system name and if you know it the TPM version.

Sorry for the missing information. This is reproducible in kernel 4.14
and latest
4.15-rc2 with all TPM drivers selected. What system name do you need? It's
Acer Desktop Veriton 4410G. The TPM version shows in dmesg is
[    0.640244] tpm_tis 00:0b: 1.2 TPM (device-id 0xFE, rev-id 71)

Chris

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

* RE: TPM driver breaks S3 suspend
  2017-12-21  8:04 TPM driver breaks S3 suspend Chris Chiu
  2017-12-21  9:22   ` Paul Menzel
@ 2017-12-21 10:19 ` Alexander.Steffen
  2017-12-21 16:17   ` Jason Gunthorpe
                     ` (3 more replies)
  2017-12-24 20:33 ` Jarkko Sakkinen
  2 siblings, 4 replies; 16+ messages in thread
From: Alexander.Steffen @ 2017-12-21 10:19 UTC (permalink / raw)
  To: chiu, peterhuewe, jarkko.sakkinen, jgg, linux-integrity,
	linux-kernel, linux

> Hi,
>     We have a desktop which has S3 suspend (to RAM) problem due to
> error messages as follows.
> [  198.908282] tpm tpm0: Error (38) sending savestate before suspend
> [  198.908289] __pnp_bus_suspend(): tpm_pm_suspend+0x0/0x160 returns
> 38
> [  198.908293] dpm_run_callback(): pnp_bus_suspend+0x0/0x20 returns 38
> [  198.908298] PM: Device 00:0b failed to suspend: error 38
> 
>     However, the first suspend after boot is working although it still
> shows an interesting message during resume.
> [  155.789945] tpm tpm0: A TPM error (38) occurred continue selftest
> 
>     The error code 38 in definition is TPM_ERR_INVALID_POSTINIT. I
> found some explanations which said this error code means that this
> command was received in the wrong sequence relative to a TPM_Startup
> command. Don't really know what happens here and how should I deal
> with this? Any suggestions? Please let me know what else information
> should I provide. Thanks
> 
> Chris

Just from looking at the code, this seems to be an issue in tpm_tis_resume.

When the device is not a TPM 2.0, it tries to execute the selftests, but ignores the results. In your case the selftests fail during resume, but since the error is ignored, the TPM device is still present (though non-functional) and so breaks the subsequent suspend.

In addition, from the error code we can tell that it is not actually a selftest failure. INVALID_POSTINIT for a command other than TPM_Startup means that no TPM_Startup has been executed for that power cycle yet, so the TPM has to reject all other commands. Usually, the platform sends the TPM_Startup command, but not in your case apparently.

The correct solution should be something like tpm2_auto_startup (execute selftests, if they fail because of the missing startup command, execute that and retry the selftests). Interestingly, tpm1_auto_startup (same purpose as tpm2_auto_startup, but for TPM 1.2 instead) does not use the same sequence, the startup-retry part is missing. Is there any reason this is done differently for TPM 1.2? Otherwise I'd propose to make tpm1_auto_startup follow the same sequence as tpm2_auto_startup and then call both from tpm_tis_resume, similar to what tpm_chip_register does.

Alexander

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

* Re: TPM driver breaks S3 suspend
  2017-12-21 10:19 ` Alexander.Steffen
@ 2017-12-21 16:17   ` Jason Gunthorpe
  2017-12-22  2:05   ` Chris Chiu
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 16+ messages in thread
From: Jason Gunthorpe @ 2017-12-21 16:17 UTC (permalink / raw)
  To: Alexander.Steffen
  Cc: chiu, peterhuewe, jarkko.sakkinen, linux-integrity, linux-kernel, linux

On Thu, Dec 21, 2017 at 10:19:09AM +0000, Alexander.Steffen@infineon.com wrote:

> The correct solution should be something like tpm2_auto_startup
> (execute selftests, if they fail because of the missing startup
> command, execute that and retry the selftests). Interestingly,
> tpm1_auto_startup (same purpose as tpm2_auto_startup, but for TPM
> 1.2 instead) does not use the same sequence, the startup-retry part
> is missing. Is there any reason this is done differently for TPM
> 1.2?

No TPM 1.2 has needed the retry loop so far.. don't see any problem
with adding it if the spec supports it.

Jason

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

* Re: TPM driver breaks S3 suspend
  2017-12-21 10:19 ` Alexander.Steffen
  2017-12-21 16:17   ` Jason Gunthorpe
@ 2017-12-22  2:05   ` Chris Chiu
  2017-12-22 13:34     ` Alexander.Steffen
  2017-12-22 19:32   ` Ken Goldman
  2017-12-24 20:37   ` Jarkko Sakkinen
  3 siblings, 1 reply; 16+ messages in thread
From: Chris Chiu @ 2017-12-22  2:05 UTC (permalink / raw)
  To: Alexander Steffen
  Cc: Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe, linux-integrity,
	Linux Kernel, Linux Upstreaming Team

On Thu, Dec 21, 2017 at 6:19 PM,  <Alexander.Steffen@infineon.com> wrote:
>> Hi,
>>     We have a desktop which has S3 suspend (to RAM) problem due to
>> error messages as follows.
>> [  198.908282] tpm tpm0: Error (38) sending savestate before suspend
>> [  198.908289] __pnp_bus_suspend(): tpm_pm_suspend+0x0/0x160 returns
>> 38
>> [  198.908293] dpm_run_callback(): pnp_bus_suspend+0x0/0x20 returns 38
>> [  198.908298] PM: Device 00:0b failed to suspend: error 38
>>
>>     However, the first suspend after boot is working although it still
>> shows an interesting message during resume.
>> [  155.789945] tpm tpm0: A TPM error (38) occurred continue selftest
>>
>>     The error code 38 in definition is TPM_ERR_INVALID_POSTINIT. I
>> found some explanations which said this error code means that this
>> command was received in the wrong sequence relative to a TPM_Startup
>> command. Don't really know what happens here and how should I deal
>> with this? Any suggestions? Please let me know what else information
>> should I provide. Thanks
>>
>> Chris
>
> Just from looking at the code, this seems to be an issue in tpm_tis_resume.
>
> When the device is not a TPM 2.0, it tries to execute the selftests, but ignores the results. In your case the selftests fail during resume, but since the error is ignored, the TPM device is still present (though non-functional) and so breaks the subsequent suspend.
>
> In addition, from the error code we can tell that it is not actually a selftest failure. INVALID_POSTINIT for a command other than TPM_Startup means that no TPM_Startup has been executed for that power cycle yet, so the TPM has to reject all other commands. Usually, the platform sends the TPM_Startup command, but not in your case apparently.
>
> The correct solution should be something like tpm2_auto_startup (execute selftests, if they fail because of the missing startup command, execute that and retry the selftests). Interestingly, tpm1_auto_startup (same purpose as tpm2_auto_startup, but for TPM 1.2 instead) does not use the same sequence, the startup-retry part is missing. Is there any reason this is done differently for TPM 1.2? Otherwise I'd propose to make tpm1_auto_startup follow the same sequence as tpm2_auto_startup and then call both from tpm_tis_resume, similar to what tpm_chip_register does.
>
> Alexander

You mean do tpm1(or 2)_auto_startup when I fail selftest with error
code 38? Then it should retry until the TPM state back to correct
state?

Chris

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

* RE: TPM driver breaks S3 suspend
  2017-12-22  2:05   ` Chris Chiu
@ 2017-12-22 13:34     ` Alexander.Steffen
  0 siblings, 0 replies; 16+ messages in thread
From: Alexander.Steffen @ 2017-12-22 13:34 UTC (permalink / raw)
  To: chiu
  Cc: peterhuewe, jarkko.sakkinen, jgg, linux-integrity, linux-kernel, linux

> On Thu, Dec 21, 2017 at 6:19 PM,  <Alexander.Steffen@infineon.com> wrote:
> >> Hi,
> >>     We have a desktop which has S3 suspend (to RAM) problem due to
> >> error messages as follows.
> >> [  198.908282] tpm tpm0: Error (38) sending savestate before suspend
> >> [  198.908289] __pnp_bus_suspend(): tpm_pm_suspend+0x0/0x160
> returns
> >> 38
> >> [  198.908293] dpm_run_callback(): pnp_bus_suspend+0x0/0x20 returns
> 38
> >> [  198.908298] PM: Device 00:0b failed to suspend: error 38
> >>
> >>     However, the first suspend after boot is working although it still
> >> shows an interesting message during resume.
> >> [  155.789945] tpm tpm0: A TPM error (38) occurred continue selftest
> >>
> >>     The error code 38 in definition is TPM_ERR_INVALID_POSTINIT. I
> >> found some explanations which said this error code means that this
> >> command was received in the wrong sequence relative to a TPM_Startup
> >> command. Don't really know what happens here and how should I deal
> >> with this? Any suggestions? Please let me know what else information
> >> should I provide. Thanks
> >>
> >> Chris
> >
> > Just from looking at the code, this seems to be an issue in tpm_tis_resume.
> >
> > When the device is not a TPM 2.0, it tries to execute the selftests, but
> ignores the results. In your case the selftests fail during resume, but since
> the error is ignored, the TPM device is still present (though non-functional)
> and so breaks the subsequent suspend.
> >
> > In addition, from the error code we can tell that it is not actually a selftest
> failure. INVALID_POSTINIT for a command other than TPM_Startup means
> that no TPM_Startup has been executed for that power cycle yet, so the
> TPM has to reject all other commands. Usually, the platform sends the
> TPM_Startup command, but not in your case apparently.
> >
> > The correct solution should be something like tpm2_auto_startup (execute
> selftests, if they fail because of the missing startup command, execute that
> and retry the selftests). Interestingly, tpm1_auto_startup (same purpose as
> tpm2_auto_startup, but for TPM 1.2 instead) does not use the same
> sequence, the startup-retry part is missing. Is there any reason this is done
> differently for TPM 1.2? Otherwise I'd propose to make tpm1_auto_startup
> follow the same sequence as tpm2_auto_startup and then call both from
> tpm_tis_resume, similar to what tpm_chip_register does.
> >
> > Alexander
> 
> You mean do tpm1(or 2)_auto_startup when I fail selftest with error
> code 38? Then it should retry until the TPM state back to correct
> state?

Yes, but that will only help once we've taught tpm1_auto_startup to handle error code 38 similar to tpm2_auto_startup.

But you can try whether that approach solves your problem without rebuilding the kernel, by sending the TPM_Startup command from user space:

python3 -c 'f=open("/dev/tpm0", "r+b", buffering=0); f.write(b"\x00\xc1\x00\x00\x00\x0c\x00\x00\x00\x99\x00\x01"
); print(f.readall())'

Could you try the following sequence?
1. Boot your system.
2. Suspend and resume your system. 
3. Send TPM_Startup manually.
4. Go to step 2.

If my theory is correct, the TPM should no longer fail during suspend, though you'll still get the same error message when resuming.

Alexander

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

* Re: TPM driver breaks S3 suspend
  2017-12-21 10:19 ` Alexander.Steffen
  2017-12-21 16:17   ` Jason Gunthorpe
  2017-12-22  2:05   ` Chris Chiu
@ 2017-12-22 19:32   ` Ken Goldman
  2017-12-24 20:37   ` Jarkko Sakkinen
  3 siblings, 0 replies; 16+ messages in thread
From: Ken Goldman @ 2017-12-22 19:32 UTC (permalink / raw)
  To: linux-integrity

On 12/21/2017 5:19 AM, Alexander.Steffen@infineon.com wrote:

>> 
>> The error code 38 in definition is TPM_ERR_INVALID_POSTINIT. I 
>> found some explanations which said this error code means that this 
>> command was received in the wrong sequence relative to a
>> TPM_Startup command. Don't really know what happens here and how
>> should I deal with this? Any suggestions? Please let me know what
>> else information should I provide. Thanks
>> 
>> Chris
> 
> In addition, from the error code we can tell that it is not actually
> a selftest failure. INVALID_POSTINIT for a command other than
> TPM_Startup means that no TPM_Startup has been executed for that
> power cycle yet, so the TPM has to reject all other commands.
> Usually, the platform sends the TPM_Startup command, but not in your
> case apparently.

I offer another possibility, based on this:

1 - There are two ways to get TPM_ERR_INVALID_POSTINIT. One is what 
Alexander said.  The other is a second TPM_Startup without a TPM_Init 
(reboot).

2 - Chris said that he gets this when doing an S3 suspend.  S3 does
not do a reboot, and thus there should __not__ be a TPM_Startup.

Could it be that the device driver is issuing a TPM_Startup when
resuming from S3?

However, Chris indicated that the TPM_ERR_INVALID_POSTINIT is returned 
from 'savestate'.  This could only happen if the TPM never got a
TPM_Startup at its first boot, which seems unlikely.

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

* Re: TPM driver breaks S3 suspend
  2017-12-21  8:04 TPM driver breaks S3 suspend Chris Chiu
  2017-12-21  9:22   ` Paul Menzel
  2017-12-21 10:19 ` Alexander.Steffen
@ 2017-12-24 20:33 ` Jarkko Sakkinen
  2017-12-25  2:43   ` Chris Chiu
  2 siblings, 1 reply; 16+ messages in thread
From: Jarkko Sakkinen @ 2017-12-24 20:33 UTC (permalink / raw)
  To: Chris Chiu
  Cc: peterhuewe, jgg, linux-integrity, Linux Kernel, Linux Upstreaming Team

On Thu, Dec 21, 2017 at 04:04:56PM +0800, Chris Chiu wrote:
> Hi,
>     We have a desktop which has S3 suspend (to RAM) problem due to
> error messages as follows.
> [  198.908282] tpm tpm0: Error (38) sending savestate before suspend
> [  198.908289] __pnp_bus_suspend(): tpm_pm_suspend+0x0/0x160 returns 38
> [  198.908293] dpm_run_callback(): pnp_bus_suspend+0x0/0x20 returns 38
> [  198.908298] PM: Device 00:0b failed to suspend: error 38
> 
>     However, the first suspend after boot is working although it still
> shows an interesting message during resume.
> [  155.789945] tpm tpm0: A TPM error (38) occurred continue selftest
> 
>     The error code 38 in definition is TPM_ERR_INVALID_POSTINIT. I
> found some explanations which said this error code means that this
> command was received in the wrong sequence relative to a TPM_Startup
> command. Don't really know what happens here and how should I deal
> with this? Any suggestions? Please let me know what else information
> should I provide. Thanks
> 
> Chris

The sequences for initializing TPM 1.x devices has been fairly static
for a long time. Has this occured after a kernel update? Is there a
kernel version where it used to work and a version where it doesn't?
Thanks.

/Jarkko

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

* Re: TPM driver breaks S3 suspend
  2017-12-21  9:43   ` Chris Chiu
@ 2017-12-24 20:35     ` Jarkko Sakkinen
  0 siblings, 0 replies; 16+ messages in thread
From: Jarkko Sakkinen @ 2017-12-24 20:35 UTC (permalink / raw)
  To: Chris Chiu
  Cc: Paul Menzel, Linux Kernel, Linux Upstreaming Team,
	Alexander Steffen, Peter Huewe, Jason Gunthorpe, linux-integrity

On Thu, Dec 21, 2017 at 05:43:35PM +0800, Chris Chiu wrote:
> On Thu, Dec 21, 2017 at 5:22 PM, Paul Menzel <pmenzel@molgen.mpg.de> wrote:
> > Dear Chris,
> >
> >
> > Thank you for bringin gup the issue.
> >
> >>      We have a desktop which has S3 suspend (to RAM) problem due to
> >> error messages as follows.
> >> [  198.908282] tpm tpm0: Error (38) sending savestate before suspend
> >> [  198.908289] __pnp_bus_suspend(): tpm_pm_suspend+0x0/0x160 returns 38
> >> [  198.908293] dpm_run_callback(): pnp_bus_suspend+0x0/0x20 returns 38
> >> [  198.908298] PM: Device 00:0b failed to suspend: error 38
> >>
> >>      However, the first suspend after boot is working although it still
> >> shows an interesting message during resume.
> >> [  155.789945] tpm tpm0: A TPM error (38) occurred continue selftest
> >>
> >>      The error code 38 in definition is TPM_ERR_INVALID_POSTINIT. I
> >> found some explanations which said this error code means that this
> >> command was received in the wrong sequence relative to a TPM_Startup
> >> command. Don't really know what happens here and how should I deal
> >> with this? Any suggestions? Please let me know what else information
> >> should I provide.
> >
> >
> > Please provide more information. Tell us your Linux version, attach your
> > config and tell us the system name and if you know it the TPM version.
> 
> Sorry for the missing information. This is reproducible in kernel 4.14
> and latest
> 4.15-rc2 with all TPM drivers selected. What system name do you need? It's
> Acer Desktop Veriton 4410G. The TPM version shows in dmesg is
> [    0.640244] tpm_tis 00:0b: 1.2 TPM (device-id 0xFE, rev-id 71)
> 
> Chris

Can you put lsmod|grep tpm output?

/Jarkko

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

* Re: TPM driver breaks S3 suspend
  2017-12-21 10:19 ` Alexander.Steffen
                     ` (2 preceding siblings ...)
  2017-12-22 19:32   ` Ken Goldman
@ 2017-12-24 20:37   ` Jarkko Sakkinen
  3 siblings, 0 replies; 16+ messages in thread
From: Jarkko Sakkinen @ 2017-12-24 20:37 UTC (permalink / raw)
  To: Alexander.Steffen
  Cc: chiu, peterhuewe, jgg, linux-integrity, linux-kernel, linux

> The correct solution should be something like tpm2_auto_startup
> (execute selftests, if they fail because of the missing startup
> command, execute that and retry the selftests). Interestingly,
> tpm1_auto_startup (same purpose as tpm2_auto_startup, but for TPM 1.2
> instead) does not use the same sequence, the startup-retry part is
> missing. Is there any reason this is done differently for TPM 1.2?
> Otherwise I'd propose to make tpm1_auto_startup follow the same
> sequence as tpm2_auto_startup and then call both from tpm_tis_resume,
> similar to what tpm_chip_register does.

I think the reason for that is that such regression has never reported
on TPM 1.2 platform. No other reason.

/Jarkko

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

* Re: TPM driver breaks S3 suspend
  2017-12-24 20:33 ` Jarkko Sakkinen
@ 2017-12-25  2:43   ` Chris Chiu
  2018-01-02 14:43     ` Jarkko Sakkinen
  0 siblings, 1 reply; 16+ messages in thread
From: Chris Chiu @ 2017-12-25  2:43 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: Peter Huewe, Jason Gunthorpe, linux-integrity, Linux Kernel,
	Linux Upstreaming Team

On Mon, Dec 25, 2017 at 4:33 AM, Jarkko Sakkinen
<jarkko.sakkinen@linux.intel.com> wrote:
> On Thu, Dec 21, 2017 at 04:04:56PM +0800, Chris Chiu wrote:
>> Hi,
>>     We have a desktop which has S3 suspend (to RAM) problem due to
>> error messages as follows.
>> [  198.908282] tpm tpm0: Error (38) sending savestate before suspend
>> [  198.908289] __pnp_bus_suspend(): tpm_pm_suspend+0x0/0x160 returns 38
>> [  198.908293] dpm_run_callback(): pnp_bus_suspend+0x0/0x20 returns 38
>> [  198.908298] PM: Device 00:0b failed to suspend: error 38
>>
>>     However, the first suspend after boot is working although it still
>> shows an interesting message during resume.
>> [  155.789945] tpm tpm0: A TPM error (38) occurred continue selftest
>>
>>     The error code 38 in definition is TPM_ERR_INVALID_POSTINIT. I
>> found some explanations which said this error code means that this
>> command was received in the wrong sequence relative to a TPM_Startup
>> command. Don't really know what happens here and how should I deal
>> with this? Any suggestions? Please let me know what else information
>> should I provide. Thanks
>>
>> Chris
>
> The sequences for initializing TPM 1.x devices has been fairly static
> for a long time. Has this occured after a kernel update? Is there a
> kernel version where it used to work and a version where it doesn't?
> Thanks.
>
> /Jarkko
Hi Jarkko,

Actually, it's a new Acer machine which I never tried an older kernel. I only
tried versions >= 4.13. The output of "lsmod | grep tpm" is none. I think it's
not built as a module.

Chris

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

* Re: TPM driver breaks S3 suspend
  2017-12-25  2:43   ` Chris Chiu
@ 2018-01-02 14:43     ` Jarkko Sakkinen
  2018-03-15 10:11       ` Daniel Drake
  0 siblings, 1 reply; 16+ messages in thread
From: Jarkko Sakkinen @ 2018-01-02 14:43 UTC (permalink / raw)
  To: Chris Chiu
  Cc: Peter Huewe, Jason Gunthorpe, linux-integrity, Linux Kernel,
	Linux Upstreaming Team

On Mon, Dec 25, 2017 at 10:43:40AM +0800, Chris Chiu wrote:
> On Mon, Dec 25, 2017 at 4:33 AM, Jarkko Sakkinen
> <jarkko.sakkinen@linux.intel.com> wrote:
> > On Thu, Dec 21, 2017 at 04:04:56PM +0800, Chris Chiu wrote:
> >> Hi,
> >>     We have a desktop which has S3 suspend (to RAM) problem due to
> >> error messages as follows.
> >> [  198.908282] tpm tpm0: Error (38) sending savestate before suspend
> >> [  198.908289] __pnp_bus_suspend(): tpm_pm_suspend+0x0/0x160 returns 38
> >> [  198.908293] dpm_run_callback(): pnp_bus_suspend+0x0/0x20 returns 38
> >> [  198.908298] PM: Device 00:0b failed to suspend: error 38
> >>
> >>     However, the first suspend after boot is working although it still
> >> shows an interesting message during resume.
> >> [  155.789945] tpm tpm0: A TPM error (38) occurred continue selftest
> >>
> >>     The error code 38 in definition is TPM_ERR_INVALID_POSTINIT. I
> >> found some explanations which said this error code means that this
> >> command was received in the wrong sequence relative to a TPM_Startup
> >> command. Don't really know what happens here and how should I deal
> >> with this? Any suggestions? Please let me know what else information
> >> should I provide. Thanks
> >>
> >> Chris
> >
> > The sequences for initializing TPM 1.x devices has been fairly static
> > for a long time. Has this occured after a kernel update? Is there a
> > kernel version where it used to work and a version where it doesn't?
> > Thanks.
> >
> > /Jarkko
> Hi Jarkko,
> 
> Actually, it's a new Acer machine which I never tried an older kernel. I only
> tried versions >= 4.13. The output of "lsmod | grep tpm" is none. I think it's
> not built as a module.
> 
> Chris

Can you try it on git://git.infradead.org/users/jjs/linux-tpmdd.git ?

Maybe it is related to the LPC #CLKRUN issues we've had.

/Jarkko

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

* Re: TPM driver breaks S3 suspend
  2018-01-02 14:43     ` Jarkko Sakkinen
@ 2018-03-15 10:11       ` Daniel Drake
  2018-03-16 13:44         ` Jarkko Sakkinen
  0 siblings, 1 reply; 16+ messages in thread
From: Daniel Drake @ 2018-03-15 10:11 UTC (permalink / raw)
  To: jarkko.sakkinen
  Cc: chiu, linux, peterhuewe, jgg, linux-integrity, linux-kernel

Hi,

Sorry for the delayed response.

Unfortunately we had to return the affected machine to the vendor
(Acer Veriton X4110G) although given we have a fairly complete
understanding of the problem, perhaps we can find and push a fix
anyway.

Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> wrote:
> Can you try it on git://git.infradead.org/users/jjs/linux-tpmdd.git ?
> Maybe it is related to the LPC #CLKRUN issues we've had.

I don't see anything relevant in that git tree, and it seems like
a distant issue from the CLKRUN changes that have been made.

To recap, the first suspend works OK, and then the TPM shows shows the
following message on the first resume:
  tpm tpm0: A TPM error(38) occured continue selftest
And error(38) is TPM_ERR_INVALID_POSTINIT which means the TPM is
not in the correct state. Then the following suspend will always
fail with the following messages.
  tpm tpm0: Error (38) sending savestate before suspend
  PM: Device 00:0b failed to suspend: error 38

tpm_crb is the driver here (not tpm2).

This exact problem was also discussed in depth years ago at
https://lists.gt.net/linux/kernel/1358716

The patch that we used to avoid the issue is below. What do you think?

Thanks
Daniel


---
 drivers/char/tpm/tpm-interface.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 1d6729be4cd6..444ae2df4a06 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -953,6 +953,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)
 	 */
-- 
2.14.1

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

* Re: TPM driver breaks S3 suspend
  2018-03-15 10:11       ` Daniel Drake
@ 2018-03-16 13:44         ` Jarkko Sakkinen
  0 siblings, 0 replies; 16+ messages in thread
From: Jarkko Sakkinen @ 2018-03-16 13:44 UTC (permalink / raw)
  To: Daniel Drake; +Cc: chiu, linux, peterhuewe, jgg, linux-integrity, linux-kernel

On Thu, Mar 15, 2018 at 06:11:19PM +0800, Daniel Drake wrote:
> Hi,
> 
> Sorry for the delayed response.
> 
> Unfortunately we had to return the affected machine to the vendor
> (Acer Veriton X4110G) although given we have a fairly complete
> understanding of the problem, perhaps we can find and push a fix
> anyway.
> 
> Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> wrote:
> > Can you try it on git://git.infradead.org/users/jjs/linux-tpmdd.git ?
> > Maybe it is related to the LPC #CLKRUN issues we've had.
> 
> I don't see anything relevant in that git tree, and it seems like
> a distant issue from the CLKRUN changes that have been made.
> 
> To recap, the first suspend works OK, and then the TPM shows shows the
> following message on the first resume:
>   tpm tpm0: A TPM error(38) occured continue selftest
> And error(38) is TPM_ERR_INVALID_POSTINIT which means the TPM is
> not in the correct state. Then the following suspend will always
> fail with the following messages.
>   tpm tpm0: Error (38) sending savestate before suspend
>   PM: Device 00:0b failed to suspend: error 38
> 
> tpm_crb is the driver here (not tpm2).
> 
> This exact problem was also discussed in depth years ago at
> https://lists.gt.net/linux/kernel/1358716
> 
> The patch that we used to avoid the issue is below. What do you think?

I think this would work for me.

/Jarkko

> 
> Thanks
> Daniel
> 
> 
> ---
>  drivers/char/tpm/tpm-interface.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
> index 1d6729be4cd6..444ae2df4a06 100644
> --- a/drivers/char/tpm/tpm-interface.c
> +++ b/drivers/char/tpm/tpm-interface.c
> @@ -953,6 +953,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)
>  	 */
> -- 
> 2.14.1
> 

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

end of thread, other threads:[~2018-03-16 13:44 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-21  8:04 TPM driver breaks S3 suspend Chris Chiu
2017-12-21  9:22 ` Paul Menzel
2017-12-21  9:22   ` Paul Menzel
2017-12-21  9:43   ` Chris Chiu
2017-12-24 20:35     ` Jarkko Sakkinen
2017-12-21 10:19 ` Alexander.Steffen
2017-12-21 16:17   ` Jason Gunthorpe
2017-12-22  2:05   ` Chris Chiu
2017-12-22 13:34     ` Alexander.Steffen
2017-12-22 19:32   ` Ken Goldman
2017-12-24 20:37   ` Jarkko Sakkinen
2017-12-24 20:33 ` Jarkko Sakkinen
2017-12-25  2:43   ` Chris Chiu
2018-01-02 14:43     ` Jarkko Sakkinen
2018-03-15 10:11       ` Daniel Drake
2018-03-16 13:44         ` Jarkko Sakkinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.