Chuck Ebbert e9ce60f
Fix TPM timeouts on boot (#530393)
Chuck Ebbert e9ce60f
Chuck Ebbert e9ce60f
--- a/drivers/char/tpm/tpm.c	
Chuck Ebbert e9ce60f
+++ a/drivers/char/tpm/tpm.c	
Chuck Ebbert e9ce60f
@@ -354,12 +354,14 @@ unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip,
Chuck Ebbert e9ce60f
 		    tpm_protected_ordinal_duration[ordinal &
Chuck Ebbert e9ce60f
 						   TPM_PROTECTED_ORDINAL_MASK];
Chuck Ebbert e9ce60f
 
Chuck Ebbert e9ce60f
-	if (duration_idx != TPM_UNDEFINED)
Chuck Ebbert e9ce60f
+	if (duration_idx != TPM_UNDEFINED) {
Chuck Ebbert e9ce60f
 		duration = chip->vendor.duration[duration_idx];
Chuck Ebbert e9ce60f
-	if (duration <= 0)
Chuck Ebbert e9ce60f
+		/* if duration is 0, it's because chip->vendor.duration wasn't */
Chuck Ebbert e9ce60f
+		/* filled yet, so we set the lowest timeout just to give enough */
Chuck Ebbert e9ce60f
+		/* time to tpm_get_timeouts() succeed */
Chuck Ebbert e9ce60f
+		return (duration <= 0 ? HZ : duration);
Chuck Ebbert e9ce60f
+	} else 
Chuck Ebbert e9ce60f
 		return 2 * 60 * HZ;
Chuck Ebbert e9ce60f
-	else
Chuck Ebbert e9ce60f
-		return duration;
Chuck Ebbert e9ce60f
 }
Chuck Ebbert e9ce60f
 EXPORT_SYMBOL_GPL(tpm_calc_ordinal_duration);
Chuck Ebbert e9ce60f
 
Chuck Ebbert e9ce60f