From 7a4ded00a2e54c39a0472e77af8c43b3043171f5 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 7 Jun 2018 11:39:25 +0200 Subject: [PATCH] 4.4-stable patches added patches: tpm-do-not-suspend-resume-if-power-stays-on.patch tpm-self-test-failure-should-not-cause-suspend-to-fail.patch --- queue-4.4/series | 2 + ...not-suspend-resume-if-power-stays-on.patch | 72 +++++++++++++++++++ ...ure-should-not-cause-suspend-to-fail.patch | 60 ++++++++++++++++ queue-4.9/series | 2 + 4 files changed, 136 insertions(+) create mode 100644 queue-4.4/series create mode 100644 queue-4.4/tpm-do-not-suspend-resume-if-power-stays-on.patch create mode 100644 queue-4.4/tpm-self-test-failure-should-not-cause-suspend-to-fail.patch create mode 100644 queue-4.9/series diff --git a/queue-4.4/series b/queue-4.4/series new file mode 100644 index 00000000000..41927bca577 --- /dev/null +++ b/queue-4.4/series @@ -0,0 +1,2 @@ +tpm-do-not-suspend-resume-if-power-stays-on.patch +tpm-self-test-failure-should-not-cause-suspend-to-fail.patch diff --git a/queue-4.4/tpm-do-not-suspend-resume-if-power-stays-on.patch b/queue-4.4/tpm-do-not-suspend-resume-if-power-stays-on.patch new file mode 100644 index 00000000000..b28030ccd7b --- /dev/null +++ b/queue-4.4/tpm-do-not-suspend-resume-if-power-stays-on.patch @@ -0,0 +1,72 @@ +From b5d0ebc99bf5d0801a5ecbe958caa3d68b8eaee8 Mon Sep 17 00:00:00 2001 +From: Enric Balletbo i Serra +Date: Tue, 27 Jun 2017 12:27:24 +0200 +Subject: tpm: do not suspend/resume if power stays on + +From: Enric Balletbo i Serra + +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. + +Signed-off-by: Sonny Rao +Signed-off-by: Enric Balletbo i Serra +Reviewed-by: Jason Gunthorpe +Reviewed-by: Jarkko Sakkinen +Signed-off-by: Jarkko Sakkinen +Signed-off-by: James Morris +Signed-off-by: Greg Kroah-Hartman + +--- + 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(+) + +--- a/drivers/char/tpm/tpm-chip.c ++++ b/drivers/char/tpm/tpm-chip.c +@@ -324,8 +324,20 @@ static void tpm1_chip_unregister(struct + */ + 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 ++ + rc = tpm1_chip_register(chip); + if (rc) + return rc; +--- a/drivers/char/tpm/tpm-interface.c ++++ b/drivers/char/tpm/tpm-interface.c +@@ -931,6 +931,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; +--- a/drivers/char/tpm/tpm.h ++++ b/drivers/char/tpm/tpm.h +@@ -168,6 +168,7 @@ struct tpm_vendor_specific { + enum tpm_chip_flags { + TPM_CHIP_FLAG_REGISTERED = BIT(0), + TPM_CHIP_FLAG_TPM2 = BIT(1), ++ TPM_CHIP_FLAG_ALWAYS_POWERED = BIT(5), + }; + + struct tpm_chip { diff --git a/queue-4.4/tpm-self-test-failure-should-not-cause-suspend-to-fail.patch b/queue-4.4/tpm-self-test-failure-should-not-cause-suspend-to-fail.patch new file mode 100644 index 00000000000..a0bd96e79a5 --- /dev/null +++ b/queue-4.4/tpm-self-test-failure-should-not-cause-suspend-to-fail.patch @@ -0,0 +1,60 @@ +From 0803d7befa15cab5717d667a97a66214d2a4c083 Mon Sep 17 00:00:00 2001 +From: Chris Chiu +Date: Tue, 20 Mar 2018 15:36:40 +0800 +Subject: tpm: self test failure should not cause suspend to fail + +From: Chris Chiu + +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. +>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. + +Cc: stable@vger.kernel.org +Signed-off-by: Chris Chiu +Signed-off-by: Daniel Drake +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 +Reviewed-by: Jarkko Sakkinen +Signed-off-by: Jarkko Sakkinen +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/char/tpm/tpm-interface.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/drivers/char/tpm/tpm-interface.c ++++ b/drivers/char/tpm/tpm-interface.c +@@ -787,6 +787,10 @@ int tpm_do_selftest(struct tpm_chip *chi + 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) + */ diff --git a/queue-4.9/series b/queue-4.9/series new file mode 100644 index 00000000000..41927bca577 --- /dev/null +++ b/queue-4.9/series @@ -0,0 +1,2 @@ +tpm-do-not-suspend-resume-if-power-stays-on.patch +tpm-self-test-failure-should-not-cause-suspend-to-fail.patch -- 2.47.3