diff options
author | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> | 2016-10-26 18:28:44 -0400 |
---|---|---|
committer | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> | 2016-11-27 18:31:30 -0500 |
commit | d1d253cff74fb866bce69c5052764ed571383ea8 (patch) | |
tree | d84782dd69b550d41168b5699fb79431004bb99d | |
parent | 26a137e31ffe6fbfdb008554a8d9b3d55bd5c86e (diff) |
tpm tis: Do not print timeout messages twice
The tis driver does a tpm_get_timeouts out side of tpm_chip_register,
and tpm_get_timeouts can print a message, resulting in two prints, eg:
tpm tpm0: [Hardware Error]: Adjusting reported timeouts: A 10000->750000us B 10000->2000000us C 10000->750000us D 10000->750000us
Keep track and prevent tpm_get_timeouts from running a second time, and
clarify the purpose of the call in tpm_tis_core to only be connected to
irq testing.
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
-rw-r--r-- | drivers/char/tpm/tpm-interface.c | 7 | ||||
-rw-r--r-- | drivers/char/tpm/tpm.h | 1 | ||||
-rw-r--r-- | drivers/char/tpm/tpm_tis_core.c | 20 |
3 files changed, 18 insertions, 10 deletions
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c index ffdae1daa138..ef0fcdb40cc3 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c | |||
@@ -501,6 +501,9 @@ int tpm_get_timeouts(struct tpm_chip *chip) | |||
501 | unsigned long old_timeout[4]; | 501 | unsigned long old_timeout[4]; |
502 | ssize_t rc; | 502 | ssize_t rc; |
503 | 503 | ||
504 | if (chip->flags & TPM_CHIP_FLAG_HAVE_TIMEOUTS) | ||
505 | return 0; | ||
506 | |||
504 | if (chip->flags & TPM_CHIP_FLAG_TPM2) { | 507 | if (chip->flags & TPM_CHIP_FLAG_TPM2) { |
505 | /* Fixed timeouts for TPM2 */ | 508 | /* Fixed timeouts for TPM2 */ |
506 | chip->timeout_a = msecs_to_jiffies(TPM2_TIMEOUT_A); | 509 | chip->timeout_a = msecs_to_jiffies(TPM2_TIMEOUT_A); |
@@ -513,6 +516,8 @@ int tpm_get_timeouts(struct tpm_chip *chip) | |||
513 | msecs_to_jiffies(TPM2_DURATION_MEDIUM); | 516 | msecs_to_jiffies(TPM2_DURATION_MEDIUM); |
514 | chip->duration[TPM_LONG] = | 517 | chip->duration[TPM_LONG] = |
515 | msecs_to_jiffies(TPM2_DURATION_LONG); | 518 | msecs_to_jiffies(TPM2_DURATION_LONG); |
519 | |||
520 | chip->flags |= TPM_CHIP_FLAG_HAVE_TIMEOUTS; | ||
516 | return 0; | 521 | return 0; |
517 | } | 522 | } |
518 | 523 | ||
@@ -596,6 +601,8 @@ int tpm_get_timeouts(struct tpm_chip *chip) | |||
596 | chip->duration_adjusted = true; | 601 | chip->duration_adjusted = true; |
597 | dev_info(&chip->dev, "Adjusting TPM timeout parameters."); | 602 | dev_info(&chip->dev, "Adjusting TPM timeout parameters."); |
598 | } | 603 | } |
604 | |||
605 | chip->flags |= TPM_CHIP_FLAG_HAVE_TIMEOUTS; | ||
599 | return 0; | 606 | return 0; |
600 | } | 607 | } |
601 | EXPORT_SYMBOL_GPL(tpm_get_timeouts); | 608 | EXPORT_SYMBOL_GPL(tpm_get_timeouts); |
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index 186493234c52..21c3dbe8c89c 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h | |||
@@ -143,6 +143,7 @@ enum tpm_chip_flags { | |||
143 | TPM_CHIP_FLAG_TPM2 = BIT(1), | 143 | TPM_CHIP_FLAG_TPM2 = BIT(1), |
144 | TPM_CHIP_FLAG_IRQ = BIT(2), | 144 | TPM_CHIP_FLAG_IRQ = BIT(2), |
145 | TPM_CHIP_FLAG_VIRTUAL = BIT(3), | 145 | TPM_CHIP_FLAG_VIRTUAL = BIT(3), |
146 | TPM_CHIP_FLAG_HAVE_TIMEOUTS = BIT(4), | ||
146 | }; | 147 | }; |
147 | 148 | ||
148 | struct tpm_chip { | 149 | struct tpm_chip { |
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index 2d1e451fb1b3..7993678954a2 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c | |||
@@ -777,20 +777,20 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, | |||
777 | if (intfcaps & TPM_INTF_DATA_AVAIL_INT) | 777 | if (intfcaps & TPM_INTF_DATA_AVAIL_INT) |
778 | dev_dbg(dev, "\tData Avail Int Support\n"); | 778 | dev_dbg(dev, "\tData Avail Int Support\n"); |
779 | 779 | ||
780 | /* Very early on issue a command to the TPM in polling mode to make | ||
781 | * sure it works. May as well use that command to set the proper | ||
782 | * timeouts for the driver. | ||
783 | */ | ||
784 | if (tpm_get_timeouts(chip)) { | ||
785 | dev_err(dev, "Could not get TPM timeouts and durations\n"); | ||
786 | rc = -ENODEV; | ||
787 | goto out_err; | ||
788 | } | ||
789 | |||
790 | /* INTERRUPT Setup */ | 780 | /* INTERRUPT Setup */ |
791 | init_waitqueue_head(&priv->read_queue); | 781 | init_waitqueue_head(&priv->read_queue); |
792 | init_waitqueue_head(&priv->int_queue); | 782 | init_waitqueue_head(&priv->int_queue); |
793 | if (irq != -1) { | 783 | if (irq != -1) { |
784 | /* Before doing irq testing issue a command to the TPM in polling mode | ||
785 | * to make sure it works. May as well use that command to set the | ||
786 | * proper timeouts for the driver. | ||
787 | */ | ||
788 | if (tpm_get_timeouts(chip)) { | ||
789 | dev_err(dev, "Could not get TPM timeouts and durations\n"); | ||
790 | rc = -ENODEV; | ||
791 | goto out_err; | ||
792 | } | ||
793 | |||
794 | if (irq) { | 794 | if (irq) { |
795 | tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED, | 795 | tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED, |
796 | irq); | 796 | irq); |