From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758299AbcKDHV3 (ORCPT ); Fri, 4 Nov 2016 03:21:29 -0400 Received: from mga06.intel.com ([134.134.136.31]:34044 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752433AbcKDHVZ (ORCPT ); Fri, 4 Nov 2016 03:21:25 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,442,1473145200"; d="scan'208";a="1080479220" Date: Fri, 4 Nov 2016 01:21:23 -0600 From: Jarkko Sakkinen To: Jason Gunthorpe Cc: tpmdd-devel@lists.sourceforge.net, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [tpmdd-devel] [PATCH 1/3] tpm tis: Do not print timeout messages twice Message-ID: <20161104072123.yyibcyrpt43vc4bw@intel.com> References: <1477520926-32594-1-git-send-email-jgunthorpe@obsidianresearch.com> <20161102102617.sxobs4madzsusgmt@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161102102617.sxobs4madzsusgmt@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.6.2-neo (2016-08-21) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 02, 2016 at 04:26:17AM -0600, Jarkko Sakkinen wrote: > On Wed, Oct 26, 2016 at 04:28:44PM -0600, Jason Gunthorpe wrote: > > 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 > > Thanks for improving the comment. It makes a lot more sense now. > > Reviewed-by: Jarkko Sakkinen > > /Jarkko Applied. /Jarkko > > > --- > > drivers/char/tpm/tpm-interface.c | 7 +++++++ > > drivers/char/tpm/tpm.h | 1 + > > 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 aef20ee2331a..d0285faa4f1b 100644 > > --- a/drivers/char/tpm/tpm-interface.c > > +++ b/drivers/char/tpm/tpm-interface.c > > @@ -505,6 +505,9 @@ int tpm_get_timeouts(struct tpm_chip *chip) > > struct duration_t *duration_cap; > > ssize_t rc; > > > > + if (chip->flags & TPM_CHIP_FLAG_HAVE_TIMEOUTS) > > + return 0; > > + > > if (chip->flags & TPM_CHIP_FLAG_TPM2) { > > /* Fixed timeouts for TPM2 */ > > chip->timeout_a = msecs_to_jiffies(TPM2_TIMEOUT_A); > > @@ -517,6 +520,8 @@ int tpm_get_timeouts(struct tpm_chip *chip) > > msecs_to_jiffies(TPM2_DURATION_MEDIUM); > > chip->duration[TPM_LONG] = > > msecs_to_jiffies(TPM2_DURATION_LONG); > > + > > + chip->flags |= TPM_CHIP_FLAG_HAVE_TIMEOUTS; > > return 0; > > } > > > > @@ -630,6 +635,8 @@ duration: > > chip->duration_adjusted = true; > > dev_info(&chip->dev, "Adjusting TPM timeout parameters."); > > } > > + > > + chip->flags |= TPM_CHIP_FLAG_HAVE_TIMEOUTS; > > return 0; > > } > > EXPORT_SYMBOL_GPL(tpm_get_timeouts); > > diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h > > index b0585e99da49..2611459271e5 100644 > > --- a/drivers/char/tpm/tpm.h > > +++ b/drivers/char/tpm/tpm.h > > @@ -143,6 +143,7 @@ enum tpm_chip_flags { > > TPM_CHIP_FLAG_TPM2 = BIT(1), > > TPM_CHIP_FLAG_IRQ = BIT(2), > > TPM_CHIP_FLAG_VIRTUAL = BIT(3), > > + TPM_CHIP_FLAG_HAVE_TIMEOUTS = BIT(4), > > }; > > > > struct tpm_chip { > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c > > index d66f51b3648e..193bee4d70e0 100644 > > --- a/drivers/char/tpm/tpm_tis_core.c > > +++ b/drivers/char/tpm/tpm_tis_core.c > > @@ -749,20 +749,20 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, > > if (intfcaps & TPM_INTF_DATA_AVAIL_INT) > > dev_dbg(dev, "\tData Avail Int Support\n"); > > > > - /* Very early on issue a command to the TPM in polling mode to make > > - * sure it works. May as well use that command to set the proper > > - * timeouts for the driver. > > - */ > > - if (tpm_get_timeouts(chip)) { > > - dev_err(dev, "Could not get TPM timeouts and durations\n"); > > - rc = -ENODEV; > > - goto out_err; > > - } > > - > > /* INTERRUPT Setup */ > > init_waitqueue_head(&priv->read_queue); > > init_waitqueue_head(&priv->int_queue); > > if (irq != -1) { > > + /* Before doing irq testing issue a command to the TPM in polling mode > > + * to make sure it works. May as well use that command to set the > > + * proper timeouts for the driver. > > + */ > > + if (tpm_get_timeouts(chip)) { > > + dev_err(dev, "Could not get TPM timeouts and durations\n"); > > + rc = -ENODEV; > > + goto out_err; > > + } > > + > > if (irq) { > > tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED, > > irq); > > -- > > 2.1.4 > > > > ------------------------------------------------------------------------------ > Developer Access Program for Intel Xeon Phi Processors > Access to Intel Xeon Phi processor-based developer platforms. > With one year of Intel Parallel Studio XE. > Training and support from Colfax. > Order your platform today. http://sdm.link/xeonphi > _______________________________________________ > tpmdd-devel mailing list > tpmdd-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/tpmdd-devel