Re: [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]

 



Hi Alexander,

On Fri, 2017-12-08 at 19:46 +0100, Alexander Steffen wrote:
> 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.

Without this patch, the TPM performance on the pi is amazing!  A
thousand extends takes ~6.5 seconds.  Unfortunately, the same thousand
extends with this patch takes > 2+ minutes.  TPM_TIMEOUT (5 msecs) is
a really long time.  Why so long?

Mimi
  

> 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;




[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