Fixes for v4.9
Subsystems (2)
v3 cover Fixes for v4.9
Chris Chiu (1):
tpm: self test failure should not cause suspend to fail
Enric Balletbo i Serra (1):
tpm: do not suspend/resume if power stays on
drivers/char/tpm/tpm-chip.c | 12 ++++++++++++ drivers/char/tpm/tpm-interface.c | 7 +++++++ drivers/char/tpm/tpm.h | 1 + 3 files changed, 20 insertions(+)
Signature · 5 lines
v3: use CONFIG_OF flag v2: moved the check from tpm_of.c to tpm-chip.c as in v4.4 chip is unreachable otherwise. I did compilation test now with BuildRoot for power arch. 2.17.0
PATCH v3 1/2 tpm: do not suspend/resume if power stays on
From: Enric Balletbo i Serra <[email protected]>
commit b5d0ebc99bf5d0801a5ecbe958caa3d68b8eaee8 upstream
The suspend/resume behavior of the TPM can be controlled by setting "powered-while-suspended" in the DTS. This is useful for the cases when hardware does not power-off the TPM.
--- drivers/char/tpm/tpm-chip.c | 12 ++++++++++++ drivers/char/tpm/tpm-interface.c | 3 +++ drivers/char/tpm/tpm.h | 1 + 3 files changed, 16 insertions(+)
drivers/char/tpm/tpm-chip.c +12 -0
@@ -388,8 +388,20 @@ static int tpm_add_legacy_sysfs(struct tpm_chip *chip)*/ int tpm_chip_register (struct tpm_chip *chip) { +#ifdef CONFIG_OF +struct device_node *np; +#endif int rc; +#ifdef CONFIG_OF + np =of_find_node_by_name (NULL ,"vtpm" ); +if (np) { +if (of_property_read_bool (np,"powered-while-suspended" )) + chip->flags |=TPM_CHIP_FLAG_ALWAYS_POWERED ; + } +of_node_put (np); +#endif +if (chip->ops->flags &TPM_OPS_AUTO_STARTUP ) {if (chip->flags &TPM_CHIP_FLAG_TPM2 ) rc =tpm2_auto_startup (chip);
drivers/char/tpm/tpm-interface.c +3 -0
@@ -969,6 +969,9 @@ int tpm_pm_suspend(struct device *dev)if (chip ==NULL )return -ENODEV ; +if (chip->flags &TPM_CHIP_FLAG_ALWAYS_POWERED ) +return 0 ; +if (chip->flags &TPM_CHIP_FLAG_TPM2 ) {tpm2_shutdown (chip,TPM2_SU_STATE );return 0 ;
drivers/char/tpm/tpm.h +1 -0
@@ -143,6 +143,7 @@ enum tpm_chip_flags {TPM_CHIP_FLAG_TPM2 =BIT (1 ),TPM_CHIP_FLAG_IRQ =BIT (2 ),TPM_CHIP_FLAG_VIRTUAL =BIT (3 ), + TPM_CHIP_FLAG_ALWAYS_POWERED = BIT(5), }; struct tpm_chip {
Signature · 1 line
2.17.0
PATCH v3 2/2 tpm: self test failure should not cause suspend to fail
In reply to Jarkko SakkinenFrom: Chris Chiu <[email protected]>
commit 0803d7befa15cab5717d667a97a66214d2a4c083 upstream
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) occurred 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.
Quoted 1 line
Quoted 1 line
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.
--- drivers/char/tpm/tpm-interface.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/char/tpm/tpm-interface.c +4 -0
@@ -803,6 +803,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) */
Signature · 1 line
2.17.0
Re: [PATCH v3 1/2] tpm: do not suspend/resume if power stays on
In reply to Jarkko SakkinenQuoted 35 lines · Jarkko Sakkinen
From: Enric Balletbo i Serra <[email protected]>
commit
b5d0ebc99bf5d0801a5ecbe958caa3d68b8eaee8upstreamThe suspend/resume behavior of the TPM can be controlled by setting "powered-while-suspended" in the DTS. This is useful for the cases when hardware does not power-off the TPM.
Signed-off-by Sonny Rao <[email protected]>Signed-off-by Enric Balletbo i Serra <[email protected]>Reviewed-by Jason Gunthorpe <[email protected]>Reviewed-by Jarkko Sakkinen <[email protected]>Signed-off-by Jarkko Sakkinen <[email protected]>Signed-off-by James Morris <[email protected]>--- drivers/char/tpm/tpm-chip.c | 12 ++++++++++++ drivers/char/tpm/tpm-interface.c | 3 +++ drivers/char/tpm/tpm.h | 1 + 3 files changed, 16 insertions(+)drivers/char/tpm/tpm-chip.c +5
-0@@ -388,8 +388,20 @@ static int tpm_add_legacy_sysfs(struct tpm_chip *chip)*/ int tpm_chip_register (struct tpm_chip *chip) { +#ifdef CONFIG_OF +struct device_node *np; +#endif int rc; +#ifdef CONFIG_OF + np =of_find_node_by_name (NULL ,"vtpm" );
drivers/char/tpm/tpm-chip.c static int tpm_add_legacy_sysfs(struct tpm_chip *chip) · line 407
Quoted 10 lines
drivers/char/tpm/tpm-chip.c +7
-0+if (np) { +if (of_property_read_bool (np,"powered-while-suspended" )) + chip->flags |=TPM_CHIP_FLAG_ALWAYS_POWERED ; + } +of_node_put (np); +#endif +if (chip->ops->flags &TPM_OPS_AUTO_STARTUP ) {if (chip->flags &TPM_CHIP_FLAG_TPM2 ) rc =tpm2_auto_startup (chip);
This part of the patch blows up the build, please test-build your patches :(
I've fixed it up now by properly including the needed .h file...
greg k-h