linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: wanghongzhe <wanghongzhe@huawei.com>
To: <peterhuewe@gmx.de>, <jarkko@kernel.org>, <jgg@ziepe.ca>
Cc: <linux-integrity@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH v2] tpm_tis_spi_main: set cs_change = 0 when timesout
Date: Mon, 8 Feb 2021 10:43:23 +0800	[thread overview]
Message-ID: <1612752203-8996-1-git-send-email-wanghongzhe@huawei.com> (raw)
In-Reply-To: <YCB60CRpdhb7/HZ+@kernel.org>

The cs cannot change back to 'high' when the count is 
TPM_RETRY. So the TPM chips thought this communication 
is not over. And next times communication cannot be 
effective because the communications mixed up with the 
last time.

v1 -> v2:
 - fix spi_xfer.cs_change to spi_xfer->cs_change

Signed-off-by: wanghongzhe <wanghongzhe@huawei.com>
---
 drivers/char/tpm/tpm_tis_spi_main.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm_tis_spi_main.c b/drivers/char/tpm/tpm_tis_spi_main.c
index 3856f6ebcb34..6c52cbb28881 100644
--- a/drivers/char/tpm/tpm_tis_spi_main.c
+++ b/drivers/char/tpm/tpm_tis_spi_main.c
@@ -64,8 +64,18 @@ static int tpm_tis_spi_flow_control(struct tpm_tis_spi_phy *phy,
 				break;
 		}
 
-		if (i == TPM_RETRY)
+		if (i == TPM_RETRY) {
+			/* change back to 'high',
+			 * So the TPM chips thinks the last communication
+			 * is done.
+			 */
+			spi_xfer->cs_change = 0;
+			spi_xfer->len = 1;
+			spi_message_init(&m);
+			spi_message_add_tail(spi_xfer, &m);
+			ret = spi_sync_locked(phy->spi_device, &m);
 			return -ETIMEDOUT;
+		}
 	}
 
 	return 0;
-- 
2.19.1


  reply	other threads:[~2021-02-08  1:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-05  6:42 [PATCH v1] tpm_tis_spi_main: set cs_change = 0 when timesout wanghongzhe
2021-02-05  7:50 ` kernel test robot
2021-02-07 23:42 ` Jarkko Sakkinen
2021-02-08  2:43   ` wanghongzhe [this message]
2021-02-05  8:41 [PATCH v2] " wanghongzhe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1612752203-8996-1-git-send-email-wanghongzhe@huawei.com \
    --to=wanghongzhe@huawei.com \
    --cc=jarkko@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).