LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] tpm: moves the delay_msec increment after sleep in tpm_transmit() 
@ 2018-04-02 16:20 Nayna Jain
  2018-04-05 10:12 ` Jarkko Sakkinen
  0 siblings, 1 reply; 7+ messages in thread
From: Nayna Jain @ 2018-04-02 16:20 UTC (permalink / raw)
  To: linux-integrity
  Cc: zohar, linux-security-module, linux-kernel, peterhuewe,
	jarkko.sakkinen, tpmdd, jgunthorpe, Nayna Jain

Commit e2fb992d82c6 ("tpm: add retry logic") introduced a new loop to
handle the TPM2_RC_RETRY error. The loop retries the command after
sleeping for the specified time, which is incremented exponentially in
every iteration. This patch fixes the initial sleep to be the default
sleep time.

Fixes: commit e2fb992d82c6 ("tpm: add retry logic")
Signed-off-by: Nayna Jain <nayna@linux.vnet.ibm.com>
Reviewed-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
---
 drivers/char/tpm/tpm-interface.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index c43a9e28995e..6201aab374e6 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -587,7 +587,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space,
 		 */
 		if (rc == TPM2_RC_TESTING && cc == TPM2_CC_SELF_TEST)
 			break;
-		delay_msec *= 2;
+
 		if (delay_msec > TPM2_DURATION_LONG) {
 			if (rc == TPM2_RC_RETRY)
 				dev_err(&chip->dev, "in retry loop\n");
@@ -597,6 +597,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space,
 			break;
 		}
 		tpm_msleep(delay_msec);
+		delay_msec *= 2;
 		memcpy(buf, save, save_size);
 	}
 	return ret;
-- 
2.13.6

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tpm: moves the delay_msec increment after sleep in tpm_transmit()
  2018-04-02 16:20 [PATCH] tpm: moves the delay_msec increment after sleep in tpm_transmit() Nayna Jain
@ 2018-04-05 10:12 ` Jarkko Sakkinen
  2018-04-06  8:33   ` Nayna Jain
  0 siblings, 1 reply; 7+ messages in thread
From: Jarkko Sakkinen @ 2018-04-05 10:12 UTC (permalink / raw)
  To: Nayna Jain
  Cc: linux-integrity, zohar, linux-security-module, linux-kernel,
	peterhuewe, tpmdd, jgunthorpe

On Mon, Apr 02, 2018 at 09:50:06PM +0530, Nayna Jain wrote:
> Commit e2fb992d82c6 ("tpm: add retry logic") introduced a new loop to
> handle the TPM2_RC_RETRY error. The loop retries the command after
> sleeping for the specified time, which is incremented exponentially in
> every iteration. This patch fixes the initial sleep to be the default
> sleep time.

I think I understand the code change but do not understand what the
long description.

> 
> Fixes: commit e2fb992d82c6 ("tpm: add retry logic")
> Signed-off-by: Nayna Jain <nayna@linux.vnet.ibm.com>
> Reviewed-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
> ---
>  drivers/char/tpm/tpm-interface.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
> index c43a9e28995e..6201aab374e6 100644
> --- a/drivers/char/tpm/tpm-interface.c
> +++ b/drivers/char/tpm/tpm-interface.c
> @@ -587,7 +587,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space,
>  		 */
>  		if (rc == TPM2_RC_TESTING && cc == TPM2_CC_SELF_TEST)
>  			break;
> -		delay_msec *= 2;
> +

Extra whitespace

>  		if (delay_msec > TPM2_DURATION_LONG) {
>  			if (rc == TPM2_RC_RETRY)
>  				dev_err(&chip->dev, "in retry loop\n");
> @@ -597,6 +597,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space,
>  			break;
>  		}
>  		tpm_msleep(delay_msec);
> +		delay_msec *= 2;
>  		memcpy(buf, save, save_size);
>  	}
>  	return ret;
> -- 
> 2.13.6
> 

/Jarkko

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tpm: moves the delay_msec increment after sleep in tpm_transmit()
  2018-04-05 10:12 ` Jarkko Sakkinen
@ 2018-04-06  8:33   ` Nayna Jain
  2018-04-07 10:36     ` Jarkko Sakkinen
  0 siblings, 1 reply; 7+ messages in thread
From: Nayna Jain @ 2018-04-06  8:33 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: linux-integrity, zohar, linux-security-module, linux-kernel,
	peterhuewe, tpmdd, jgunthorpe



On 04/05/2018 03:42 PM, Jarkko Sakkinen wrote:
> On Mon, Apr 02, 2018 at 09:50:06PM +0530, Nayna Jain wrote:
>> Commit e2fb992d82c6 ("tpm: add retry logic") introduced a new loop to
>> handle the TPM2_RC_RETRY error. The loop retries the command after
>> sleeping for the specified time, which is incremented exponentially in
>> every iteration. This patch fixes the initial sleep to be the default
>> sleep time.
> I think I understand the code change but do not understand what the
> long description.

It tells that the first sleep is delay_msec * 2 and not delay_msec.

>
>> Fixes: commit e2fb992d82c6 ("tpm: add retry logic")
>> Signed-off-by: Nayna Jain <nayna@linux.vnet.ibm.com>
>> Reviewed-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
>> ---
>>   drivers/char/tpm/tpm-interface.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
>> index c43a9e28995e..6201aab374e6 100644
>> --- a/drivers/char/tpm/tpm-interface.c
>> +++ b/drivers/char/tpm/tpm-interface.c
>> @@ -587,7 +587,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space,
>>   		 */
>>   		if (rc == TPM2_RC_TESTING && cc == TPM2_CC_SELF_TEST)
>>   			break;
>> -		delay_msec *= 2;
>> +
> Extra whitespace

I left just for clarity, but if not needed then I can remove it.

Thanks & Regards,
    - Nayna

>
>>   		if (delay_msec > TPM2_DURATION_LONG) {
>>   			if (rc == TPM2_RC_RETRY)
>>   				dev_err(&chip->dev, "in retry loop\n");
>> @@ -597,6 +597,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space,
>>   			break;
>>   		}
>>   		tpm_msleep(delay_msec);
>> +		delay_msec *= 2;
>>   		memcpy(buf, save, save_size);
>>   	}
>>   	return ret;
>> -- 
>> 2.13.6
>>
> /Jarkko
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tpm: moves the delay_msec increment after sleep in tpm_transmit()
  2018-04-06  8:33   ` Nayna Jain
@ 2018-04-07 10:36     ` Jarkko Sakkinen
  2018-04-09 14:29       ` Mimi Zohar
  0 siblings, 1 reply; 7+ messages in thread
From: Jarkko Sakkinen @ 2018-04-07 10:36 UTC (permalink / raw)
  To: Nayna Jain
  Cc: linux-integrity, zohar, linux-security-module, linux-kernel,
	peterhuewe, tpmdd, jgunthorpe

On Fri, Apr 06, 2018 at 02:03:37PM +0530, Nayna Jain wrote:
> On 04/05/2018 03:42 PM, Jarkko Sakkinen wrote:
> > On Mon, Apr 02, 2018 at 09:50:06PM +0530, Nayna Jain wrote:
> > > Commit e2fb992d82c6 ("tpm: add retry logic") introduced a new loop to
> > > handle the TPM2_RC_RETRY error. The loop retries the command after
> > > sleeping for the specified time, which is incremented exponentially in
> > > every iteration. This patch fixes the initial sleep to be the default
> > > sleep time.
> > I think I understand the code change but do not understand what the
> > long description.
> 
> It tells that the first sleep is delay_msec * 2 and not delay_msec.

So the problem is that the loop doubles the time before sleeping
for the first time. This is missing from the description. Please
refine it in some way.

/Jarkko

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tpm: moves the delay_msec increment after sleep in tpm_transmit()
  2018-04-07 10:36     ` Jarkko Sakkinen
@ 2018-04-09 14:29       ` Mimi Zohar
  2018-04-10 12:31         ` Jarkko Sakkinen
  0 siblings, 1 reply; 7+ messages in thread
From: Mimi Zohar @ 2018-04-09 14:29 UTC (permalink / raw)
  To: Jarkko Sakkinen, Nayna Jain
  Cc: linux-integrity, linux-security-module, linux-kernel, peterhuewe,
	tpmdd, jgunthorpe

On Sat, 2018-04-07 at 13:36 +0300, Jarkko Sakkinen wrote:
> On Fri, Apr 06, 2018 at 02:03:37PM +0530, Nayna Jain wrote:
> > On 04/05/2018 03:42 PM, Jarkko Sakkinen wrote:
> > > On Mon, Apr 02, 2018 at 09:50:06PM +0530, Nayna Jain wrote:
> > > > Commit e2fb992d82c6 ("tpm: add retry logic") introduced a new loop to
> > > > handle the TPM2_RC_RETRY error. The loop retries the command after
> > > > sleeping for the specified time, which is incremented exponentially in
> > > > every iteration. This patch fixes the initial sleep to be the default
> > > > sleep time.
> > > I think I understand the code change but do not understand what the
> > > long description.
> > 
> > It tells that the first sleep is delay_msec * 2 and not delay_msec.
> 
> So the problem is that the loop doubles the time before sleeping
> for the first time. This is missing from the description. Please
> refine it in some way.

Sure, how about replacing the last line of the patch description with:
    Unfortunately, the loop doubles the time before sleeping, causing the
    initial sleep to be doubled.  This patch fixes the initial sleep time.

If this change is acceptable, do you want to make the change or should Nayna repost the patch?

thanks,

Mimi

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tpm: moves the delay_msec increment after sleep in tpm_transmit()
  2018-04-09 14:29       ` Mimi Zohar
@ 2018-04-10 12:31         ` Jarkko Sakkinen
  2018-04-20  4:48           ` Jarkko Sakkinen
  0 siblings, 1 reply; 7+ messages in thread
From: Jarkko Sakkinen @ 2018-04-10 12:31 UTC (permalink / raw)
  To: Mimi Zohar, Nayna Jain
  Cc: linux-integrity, linux-security-module, linux-kernel, peterhuewe,
	tpmdd, jgunthorpe

On Mon, 2018-04-09 at 10:29 -0400, Mimi Zohar wrote:
> On Sat, 2018-04-07 at 13:36 +0300, Jarkko Sakkinen wrote:
> > On Fri, Apr 06, 2018 at 02:03:37PM +0530, Nayna Jain wrote:
> > > On 04/05/2018 03:42 PM, Jarkko Sakkinen wrote:
> > > > On Mon, Apr 02, 2018 at 09:50:06PM +0530, Nayna Jain wrote:
> > > > > Commit e2fb992d82c6 ("tpm: add retry logic") introduced a new loop to
> > > > > handle the TPM2_RC_RETRY error. The loop retries the command after
> > > > > sleeping for the specified time, which is incremented exponentially in
> > > > > every iteration. This patch fixes the initial sleep to be the default
> > > > > sleep time.
> > > > 
> > > > I think I understand the code change but do not understand what the
> > > > long description.
> > > 
> > > It tells that the first sleep is delay_msec * 2 and not delay_msec.
> > 
> > So the problem is that the loop doubles the time before sleeping
> > for the first time. This is missing from the description. Please
> > refine it in some way.
> 
> Sure, how about replacing the last line of the patch description with:
>     Unfortunately, the loop doubles the time before sleeping, causing the
>     initial sleep to be doubled.  This patch fixes the initial sleep time.
> 
> If this change is acceptable, do you want to make the change or should Nayna
> repost the patch?

No need. I'll move on to testing.

/Jarkko

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tpm: moves the delay_msec increment after sleep in tpm_transmit()
  2018-04-10 12:31         ` Jarkko Sakkinen
@ 2018-04-20  4:48           ` Jarkko Sakkinen
  0 siblings, 0 replies; 7+ messages in thread
From: Jarkko Sakkinen @ 2018-04-20  4:48 UTC (permalink / raw)
  To: Mimi Zohar, Nayna Jain
  Cc: linux-integrity, linux-security-module, linux-kernel, peterhuewe,
	tpmdd, jgunthorpe

On Tue, Apr 10, 2018 at 03:31:09PM +0300, Jarkko Sakkinen wrote:
> On Mon, 2018-04-09 at 10:29 -0400, Mimi Zohar wrote:
> > If this change is acceptable, do you want to make the change or should Nayna
> > repost the patch?
> 
> No need. I'll move on to testing.

Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

/Jarkko

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-04-20  4:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-02 16:20 [PATCH] tpm: moves the delay_msec increment after sleep in tpm_transmit() Nayna Jain
2018-04-05 10:12 ` Jarkko Sakkinen
2018-04-06  8:33   ` Nayna Jain
2018-04-07 10:36     ` Jarkko Sakkinen
2018-04-09 14:29       ` Mimi Zohar
2018-04-10 12:31         ` Jarkko Sakkinen
2018-04-20  4:48           ` Jarkko Sakkinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).