Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c4ff4b82 authored by Rajiv Andrade's avatar Rajiv Andrade Committed by James Morris
Browse files

TPM: Long default timeout fix



If duration variable value is 0 at this point, it's because
chip->vendor.duration wasn't filled by tpm_get_timeouts() yet.
This patch sets then the lowest timeout just to give enough
time for tpm_get_timeouts() to further succeed.

This fix avoids long boot times in case another entity attempts
to send commands to the TPM when the TPM isn't accessible.

Signed-off-by: default avatarRajiv Andrade <srajiv@linux.vnet.ibm.com>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent 54031109
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -364,12 +364,14 @@ unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip,
		    tpm_protected_ordinal_duration[ordinal &
						   TPM_PROTECTED_ORDINAL_MASK];

	if (duration_idx != TPM_UNDEFINED)
	if (duration_idx != TPM_UNDEFINED) {
		duration = chip->vendor.duration[duration_idx];
	if (duration <= 0)
		/* if duration is 0, it's because chip->vendor.duration wasn't */
		/* filled yet, so we set the lowest timeout just to give enough */
		/* time for tpm_get_timeouts() to succeed */
		return (duration <= 0 ? HZ : duration);
	} else
		return 2 * 60 * HZ;
	else
		return duration;
}
EXPORT_SYMBOL_GPL(tpm_calc_ordinal_duration);