From c6320b2101085263c8c85159f08039db41a5f310 Mon Sep 17 00:00:00 2001 From: Luigi Semenzato Date: Tue, 6 Nov 2012 14:47:46 -0800 Subject: [PATCH] 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 Reviewed-on: https://gerrit.chromium.org/gerrit/37468 Reviewed-by: Darren Krahn Tested-by: Darren Krahn Reviewed-by: Mandeep Singh Baines --- drivers/char/tpm/tpm.c | 11 ++--------- drivers/char/tpm/tpm.h | 1 - 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c index fc33f890f2a9..547f5df847c7 100644 --- a/drivers/char/tpm/tpm.c +++ b/drivers/char/tpm/tpm.c @@ -352,7 +352,6 @@ static void timeout_work(struct work_struct *work) 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 @@ static void resume_if_needed(struct tpm_chip *chip) { 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 56bba9bdc29f..8c0f38bdb991 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -114,7 +114,6 @@ struct tpm_chip { 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 */ -- 2.20.1