Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jason Gunthorpe and committed by
Jarkko Sakkinen
d1d253cf 26a137e3

+18 -10
+7
drivers/char/tpm/tpm-interface.c
··· 501 501 unsigned long old_timeout[4]; 502 502 ssize_t rc; 503 503 504 + if (chip->flags & TPM_CHIP_FLAG_HAVE_TIMEOUTS) 505 + return 0; 506 + 504 507 if (chip->flags & TPM_CHIP_FLAG_TPM2) { 505 508 /* Fixed timeouts for TPM2 */ 506 509 chip->timeout_a = msecs_to_jiffies(TPM2_TIMEOUT_A); ··· 516 513 msecs_to_jiffies(TPM2_DURATION_MEDIUM); 517 514 chip->duration[TPM_LONG] = 518 515 msecs_to_jiffies(TPM2_DURATION_LONG); 516 + 517 + chip->flags |= TPM_CHIP_FLAG_HAVE_TIMEOUTS; 519 518 return 0; 520 519 } 521 520 ··· 601 596 chip->duration_adjusted = true; 602 597 dev_info(&chip->dev, "Adjusting TPM timeout parameters."); 603 598 } 599 + 600 + chip->flags |= TPM_CHIP_FLAG_HAVE_TIMEOUTS; 604 601 return 0; 605 602 } 606 603 EXPORT_SYMBOL_GPL(tpm_get_timeouts);
+1
drivers/char/tpm/tpm.h
··· 143 143 TPM_CHIP_FLAG_TPM2 = BIT(1), 144 144 TPM_CHIP_FLAG_IRQ = BIT(2), 145 145 TPM_CHIP_FLAG_VIRTUAL = BIT(3), 146 + TPM_CHIP_FLAG_HAVE_TIMEOUTS = BIT(4), 146 147 }; 147 148 148 149 struct tpm_chip {
+10 -10
drivers/char/tpm/tpm_tis_core.c
··· 777 777 if (intfcaps & TPM_INTF_DATA_AVAIL_INT) 778 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 780 /* INTERRUPT Setup */ 791 781 init_waitqueue_head(&priv->read_queue); 792 782 init_waitqueue_head(&priv->int_queue); 793 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 794 if (irq) { 795 795 tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED, 796 796 irq);