Skip to content

Commit d6313fe

Browse files
Enric Balletbo i Serragregkh
authored andcommitted
tpm: do not suspend/resume if power stays on
commit b5d0ebc 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. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3c3d05f commit d6313fe

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

drivers/char/tpm/tpm-chip.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/spinlock.h>
2727
#include <linux/freezer.h>
2828
#include <linux/major.h>
29+
#include <linux/of.h>
2930
#include "tpm.h"
3031
#include "tpm_eventlog.h"
3132

@@ -388,8 +389,20 @@ static int tpm_add_legacy_sysfs(struct tpm_chip *chip)
388389
*/
389390
int tpm_chip_register(struct tpm_chip *chip)
390391
{
392+
#ifdef CONFIG_OF
393+
struct device_node *np;
394+
#endif
391395
int rc;
392396

397+
#ifdef CONFIG_OF
398+
np = of_find_node_by_name(NULL, "vtpm");
399+
if (np) {
400+
if (of_property_read_bool(np, "powered-while-suspended"))
401+
chip->flags |= TPM_CHIP_FLAG_ALWAYS_POWERED;
402+
}
403+
of_node_put(np);
404+
#endif
405+
393406
if (chip->ops->flags & TPM_OPS_AUTO_STARTUP) {
394407
if (chip->flags & TPM_CHIP_FLAG_TPM2)
395408
rc = tpm2_auto_startup(chip);

drivers/char/tpm/tpm-interface.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,9 @@ int tpm_pm_suspend(struct device *dev)
969969
if (chip == NULL)
970970
return -ENODEV;
971971

972+
if (chip->flags & TPM_CHIP_FLAG_ALWAYS_POWERED)
973+
return 0;
974+
972975
if (chip->flags & TPM_CHIP_FLAG_TPM2) {
973976
tpm2_shutdown(chip, TPM2_SU_STATE);
974977
return 0;

drivers/char/tpm/tpm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ enum tpm_chip_flags {
143143
TPM_CHIP_FLAG_TPM2 = BIT(1),
144144
TPM_CHIP_FLAG_IRQ = BIT(2),
145145
TPM_CHIP_FLAG_VIRTUAL = BIT(3),
146+
TPM_CHIP_FLAG_ALWAYS_POWERED = BIT(5),
146147
};
147148

148149
struct tpm_chip {

0 commit comments

Comments
 (0)