Skip to contentSkip to conversation

tpm: fix (ACPI S3) suspend regression

PATCH In review Stefan Berger 2 participants 2 messages Jan 18, 2012 TPM device driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tpm: fix (ACPI S3) suspend regression

This patch fixes an (ACPI S3) suspend regression introduced in commit 68d6e6713fcb2ea6278661aaaf5f1c9c821b3751 and occurring with an Infineon TPM and tpm_tis and tpm_infineon drivers active. Further, the suspend problem occurred if the TPM was disabled and/or deactivated and therefore the TPM_PCRRead checking the result of the (asynchronous) self test returned an error code which then caused the tpm_tis driver to become inactive and this then seemed to have negatively influenced the suspend support by the tpm_infineon driver...
Besides that the tpm_tis drive may stay active even if the TPM is disabled and/or deactivated.

---
 drivers/char/tpm/tpm.c |    9 +++++++++
 drivers/char/tpm/tpm.h |    3 +++
 2 files changed, 12 insertions(+)
drivers/char/tpm/tpm.c +9 -0
Index: linux-2.6/drivers/char/tpm/tpm.c
===================================================================
@@ -846,6 +846,15 @@ int tpm_do_selftest(struct tpm_chip *chi
 
 	do {
 		rc = __tpm_pcr_read(chip, 0, digest);
+		if (rc == TPM_ERR_DISABLED || rc == TPM_ERR_DEACTIVATED) {
+			dev_info(chip->dev,
+				 "TPM is disabled/deactivated (0x%X)\n", rc);
+			/* TPM is disabled and/or deactivated; driver can
+			 * proceed and TPM does handle commands for
+			 * suspend/resume correctly
+			 */
+			return 0;
+		}
 		if (rc != TPM_WARN_DOING_SELFTEST)
 			return rc;
 		msleep(delay_msec);
drivers/char/tpm/tpm.h +3 -0
Index: linux-2.6/drivers/char/tpm/tpm.h
===================================================================
@@ -39,6 +39,9 @@ enum tpm_addr {
 };
 
 #define TPM_WARN_DOING_SELFTEST 0x802
+#define TPM_ERR_DEACTIVATED     0x6
+#define TPM_ERR_DISABLED        0x7
+
 #define TPM_HEADER_SIZE		10
 extern ssize_t tpm_show_pubek(struct device *, struct device_attribute *attr,
 				char *);
Acked-by on v1 1/1
#1 lore raw

Thanks Stefan,

Quoted 55 lines · Stefan Berger

This patch fixes an (ACPI S3) suspend regression introduced in commit 68d6e6713fcb2ea6278661aaaf5f1c9c821b3751 and occurring with an Infineon TPM and tpm_tis and tpm_infineon drivers active. Further, the suspend problem occurred if the TPM was disabled and/or deactivated and therefore the TPM_PCRRead checking the result of the (asynchronous) self test returned an error code which then caused the tpm_tis driver to become inactive and this then seemed to have negatively influenced the suspend support by the tpm_infineon driver...
Besides that the tpm_tis drive may stay active even if the TPM is disabled and/or deactivated.

---
 drivers/char/tpm/tpm.c |    9 +++++++++
 drivers/char/tpm/tpm.h |    3 +++
 2 files changed, 12 insertions(+)

Index: linux-2.6/drivers/char/tpm/tpm.c
===================================================================

drivers/char/tpm/tpm.c +9 -0
@@ -846,6 +846,15 @@ int tpm_do_selftest(struct tpm_chip *chi
 
 	do {
 		rc = __tpm_pcr_read(chip, 0, digest);
+		if (rc == TPM_ERR_DISABLED || rc == TPM_ERR_DEACTIVATED) {
+			dev_info(chip->dev,
+				 "TPM is disabled/deactivated (0x%X)\n", rc);
+			/* TPM is disabled and/or deactivated; driver can
+			 * proceed and TPM does handle commands for
+			 * suspend/resume correctly
+			 */
+			return 0;
+		}
 		if (rc != TPM_WARN_DOING_SELFTEST)
 			return rc;
 		msleep(delay_msec);

Index: linux-2.6/drivers/char/tpm/tpm.h
===================================================================

drivers/char/tpm/tpm.h +3 -0
@@ -39,6 +39,9 @@ enum tpm_addr {
 };
 
 #define TPM_WARN_DOING_SELFTEST 0x802
+#define TPM_ERR_DEACTIVATED     0x6
+#define TPM_ERR_DISABLED        0x7
+
 #define TPM_HEADER_SIZE		10
 extern ssize_t tpm_show_pubek(struct device *, struct device_attribute *attr,
 				char *);
Signature · 3 lines
Rajiv Andrade
Security Development
IBM Linux Technology Center