Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751308AbdCQTDv (ORCPT ); Fri, 17 Mar 2017 15:03:51 -0400 Received: from mga02.intel.com ([134.134.136.20]:46181 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751116AbdCQTDi (ORCPT ); Fri, 17 Mar 2017 15:03:38 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,177,1486454400"; d="scan'208";a="68441457" Date: Fri, 17 Mar 2017 21:02:40 +0200 From: Jarkko Sakkinen To: Nayna Jain Cc: tpmdd-devel@lists.sourceforge.net, peterhuewe@gmx.de, tpmdd@selhorst.net, jgunthorpe@obsidianresearch.com, dan.morav@nuvoton.com, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, "linux-4.8" Subject: Re: [PATCH 2/2] tpm: add sleep only for retry in i2c_nuvoton_write_status() Message-ID: <20170317190240.yn5ifl5ozvi2lxqf@intel.com> References: <1489171554-6844-1-git-send-email-nayna@linux.vnet.ibm.com> <1489171554-6844-2-git-send-email-nayna@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1489171554-6844-2-git-send-email-nayna@linux.vnet.ibm.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 Content-Length: 1627 Lines: 44 On Fri, Mar 10, 2017 at 01:45:54PM -0500, Nayna Jain wrote: > Currently, there is an unnecessary 1 msec delay added in > i2c_nuvoton_write_status() for the successful case. This > function is called multiple times during send() and recv(), > which implies adding multiple extra delays for every TPM > operation. > > This patch calls usleep_range() only if retry is to be done. > > Signed-off-by: Nayna Jain > Cc: stable@vger.kernel.org (linux-4.8) > Reviewed-by: Mimi Zohar I applied this too. /Jarkko > --- > drivers/char/tpm/tpm_i2c_nuvoton.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c > index 0c98c42..c642877 100644 > --- a/drivers/char/tpm/tpm_i2c_nuvoton.c > +++ b/drivers/char/tpm/tpm_i2c_nuvoton.c > @@ -124,8 +124,9 @@ static s32 i2c_nuvoton_write_status(struct i2c_client *client, u8 data) > /* this causes the current command to be aborted */ > for (i = 0, status = -1; i < TPM_I2C_RETRY_COUNT && status < 0; i++) { > status = i2c_nuvoton_write_buf(client, TPM_STS, 1, &data); > - usleep_range(TPM_I2C_BUS_DELAY, TPM_I2C_BUS_DELAY > - + TPM_I2C_DELAY_RANGE); > + if (status < 0) > + usleep_range(TPM_I2C_BUS_DELAY, TPM_I2C_BUS_DELAY > + + TPM_I2C_DELAY_RANGE); > } > return status; > } > -- > 2.9.3 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-security-module" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html