[RFC][PATCH 8/9] tpm_tis_spi: add delay between wait state retries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There do not seem to be any real limits one the amount/duration of wait
states that the TPM is allowed to generate. So at least give the TPM some
time to clean up the situation that caused the wait states instead of
retrying the transfers as fast as possible.

Signed-off-by: Alexander Steffen <Alexander.Steffen@xxxxxxxxxxxx>
---
 drivers/char/tpm/tpm_tis_spi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/char/tpm/tpm_tis_spi.c b/drivers/char/tpm/tpm_tis_spi.c
index 2cc6aa9..e53c9c3 100644
--- a/drivers/char/tpm/tpm_tis_spi.c
+++ b/drivers/char/tpm/tpm_tis_spi.c
@@ -88,7 +88,7 @@ static int tpm_tis_spi_transfer(struct tpm_tis_data *data, u32 addr, u16 len,
 
 		if ((phy->iobuf[3] & 0x01) == 0) {
 			// handle SPI wait states
-			for (i = 0; i < TPM_RETRY; i++) {
+			for (i = 1; i <= TPM_RETRY; i++) {
 				phy->iobuf[0] = addr;
 				spi_xfer.len = 1;
 				spi_message_init(&m);
@@ -98,9 +98,10 @@ static int tpm_tis_spi_transfer(struct tpm_tis_data *data, u32 addr, u16 len,
 					goto exit;
 				if (phy->iobuf[0] & 0x01)
 					break;
+				tpm_msleep(i * TPM_TIMEOUT);
 			}
 
-			if (i == TPM_RETRY) {
+			if (i > TPM_RETRY) {
 				spi_xfer.tx_buf = NULL;
 				spi_xfer.rx_buf = NULL;
 				spi_xfer.len = 0;
-- 
2.7.4




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux Kernel]     [Linux Kernel Hardening]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux