CHROMIUM: tpm: always run ContinueSelftest at resume

In a previous patch we moved ContinueSelfTest out of the resume path
to speed it up, and we skip the command if enough time has passed
between the resume and the first following TPM command, on the
assumption that the TPM starts and runs the self test to completion
at resume time.  (This applies only to TPMs that are powered off
between suspend and resume.)

The ST Micro TPM behaves differently and needs ContinueSelfTest
to be called at resume, before the next TPM command can be
successfully executed.  We could make the behavior of the
resume callback depend on the TPM model.  However, ContinueSelftest
completes quickly on all TPM models currently used in Chromebooks,
and it's not on any critical path.  So we prefer to make the
code simpler for everybody.

BUG=chrome-os-partner:15694
TEST=tested manually

Change-Id: I62e12db3506947e757ea251a9f8915ffae6ac106
Signed-off-by: Luigi Semenzato <semenzato@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/37468
Reviewed-by: Darren Krahn <dkrahn@chromium.org>
Tested-by: Darren Krahn <dkrahn@chromium.org>
Reviewed-by: Mandeep Singh Baines <msb@chromium.org>
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index fc33f89..547f5df 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -352,7 +352,6 @@
 static void set_needs_resume(struct tpm_chip *chip)
 {
 	mutex_lock(&chip->resume_mutex);
-	chip->resume_time = jiffies;
 	chip->needs_resume = 1;
 	mutex_unlock(&chip->resume_mutex);
 }
@@ -470,14 +469,8 @@
 {
 	mutex_lock(&chip->resume_mutex);
 	if (chip->needs_resume) {
-		/* If it's been TPM_SELF_TEST_DURATION_MSEC msec since resume,
-		 * then selftest has completed and we don't need to wait.
-		 */
-		if (jiffies - chip->resume_time <
-		    msecs_to_jiffies(TPM_SELF_TEST_DURATION_MSEC)) {
-			dev_info(chip->dev, "waiting for TPM self test\n");
-			tpm_continue_selftest_nocheck(chip);
-		}
+		dev_info(chip->dev, "waiting for TPM self test\n");
+		tpm_continue_selftest_nocheck(chip);
 		chip->needs_resume = 0;
 		dev_info(chip->dev, "TPM delayed resume completed\n");
 	}
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 56bba9b..8c0f38b 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -114,7 +114,6 @@
 	struct mutex buffer_mutex;
 
 	int needs_resume;
-	unsigned long resume_time;
 	struct mutex resume_mutex;
 
 	struct timer_list user_read_timer;	/* user needs to claim result */