Skip to contentSkip to conversation

tpm: moves the delay_msec increment after sleep in tpm_transmit()

PATCH In review Nayna Jain 3 participants 7 messages Apr 2, 2018 – Apr 20, 2018

Subsystems (3)
lore
Share & tools
lore

Nayna Jain

author
#0 lore raw

PATCH 1/1 tpm: moves the delay_msec increment after sleep in tpm_transmit()

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")
---
 drivers/char/tpm/tpm-interface.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm-interface.c +2 -1
index c43a9e28995e..6201aab374e6 100644
@@ -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;
Signature · 6 lines
2.13.6

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw
Quoted 5 lines · 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.

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

Quoted 13 lines
Fixes commit e2fb992d82c6 ("tpm: add retry logic")
---
 drivers/char/tpm/tpm-interface.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm-interface.c +0 -0
index c43a9e28995e..6201aab374e6 100644

drivers/char/tpm/tpm-interface.c ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space, · line 590

Quoted 5 lines
drivers/char/tpm/tpm-interface.c +1 -1
@@ -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

Quoted 14 lines
drivers/char/tpm/tpm-interface.c +1 -0
 		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;
Signature · 1 line
2.13.6

/Jarkko
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#2 lore raw
Quoted 8 lines · Jarkko Sakkinen
Quoted 5 lines · 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.

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.

Quoted 8 lines
Quoted 8 lines
Fixes commit e2fb992d82c6 ("tpm: add retry logic")
---
  drivers/char/tpm/tpm-interface.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 11 lines

drivers/char/tpm/tpm-interface.c ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space, · line 590

Quoted 10 lines
drivers/char/tpm/tpm-interface.c +1 -1
index c43a9e28995e..6201aab374e6 100644
@@ -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

Quoted 17 lines
Quoted 15 lines
drivers/char/tpm/tpm-interface.c +1 -0
  		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;
Signature · 1 line
2.13.6

/Jarkko

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 11 lines · Nayna Jain
Quoted 8 lines · Jarkko Sakkinen
Quoted 5 lines · 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.

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
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 8 lines · Jarkko Sakkinen
Quoted 7 lines · Nayna Jain
Quoted 6 lines · Jarkko Sakkinen
Quoted 5 lines · 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.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

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

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
Quoted 19 lines · Mimi Zohar
Quoted 9 lines · Jarkko Sakkinen
Quoted 8 lines · Nayna Jain
Quoted 7 lines · Jarkko Sakkinen
Quoted 5 lines · 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.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

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.

Quoted 6 lines

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
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Tested-by Reviewed-by
#6 lore raw
Quoted 5 lines · Jarkko Sakkinen
Quoted 2 lines · Mimi Zohar

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
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html