From patchwork Thu Mar 2 13:03:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter.Huewe@infineon.com X-Patchwork-Id: 734600 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vYt143S1Bz9s7x for ; Fri, 3 Mar 2017 00:08:40 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1cjQTD-00024y-1W; Thu, 02 Mar 2017 13:08:35 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1cjQTC-00024s-1s for tpmdd-devel@lists.sourceforge.net; Thu, 02 Mar 2017 13:08:34 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of infineon.com designates 217.10.52.18 as permitted sender) client-ip=217.10.52.18; envelope-from=peter.huewe@infineon.com; helo=smtp2.infineon.com; Received: from smtp2.infineon.com ([217.10.52.18]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1cjQTB-00052W-3U for tpmdd-devel@lists.sourceforge.net; Thu, 02 Mar 2017 13:08:34 +0000 X-SBRS: None Received: from unknown (HELO mucxv003.muc.infineon.com) ([172.23.11.20]) by smtp2.infineon.com with ESMTP/TLS/AES256-GCM-SHA384; 02 Mar 2017 14:08:26 +0100 Received: from MUCSE607.infineon.com (unknown [172.23.7.108]) by mucxv003.muc.infineon.com (Postfix) with ESMTPS; Thu, 2 Mar 2017 14:08:26 +0100 (CET) Received: from MUCSE612.infineon.com (172.23.7.113) by MUCSE607.infineon.com (172.23.7.108) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Thu, 2 Mar 2017 14:08:25 +0100 Received: from osboxes.agb.infineon.com (172.29.170.131) by MUCSE612.infineon.com (172.23.7.113) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Thu, 2 Mar 2017 14:08:25 +0100 From: Peter Huewe To: Date: Thu, 2 Mar 2017 13:03:15 +0000 Message-ID: <1488459879-24349-6-git-send-email-peter.huewe@infineon.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488459879-24349-1-git-send-email-peter.huewe@infineon.com> References: <1488459879-24349-1-git-send-email-peter.huewe@infineon.com> MIME-Version: 1.0 X-Originating-IP: [172.29.170.131] X-ClientProxiedBy: MUCSE601.infineon.com (172.23.7.102) To MUCSE612.infineon.com (172.23.7.113) X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1cjQTB-00052W-3U Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Peter Huewe Subject: [tpmdd-devel] [PATCH v2 5/5] tpm_tis_spi: Add small delay after last transfer X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tpmdd-devel-bounces@lists.sourceforge.net Testing the implementation with a Raspberry Pi 2 showed that under some circumstances its SPI master erroneously releases the CS line before the transfer is complete, i.e. before the end of the last clock. In this case the TPM ignores the transfer and misses for example the GO command. The driver is unable to detect this communication problem and will wait for a command response that is never going to arrive, timing out eventually. As a workaround, the small delay ensures that the CS line is held long enough, even with a faulty SPI master. Other SPI masters are not affected, except for a negligible performance penalty. Cc: Fixes: 0edbfea537d1 ("tpm/tpm_tis_spi: Add support for spi phy") Signed-off-by: Alexander Steffen Signed-off-by: Peter Huewe Reviewed-by: Jarkko Sakkinen Tested-by: Benoit Houyere --- drivers/char/tpm/tpm_tis_spi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/char/tpm/tpm_tis_spi.c b/drivers/char/tpm/tpm_tis_spi.c index 3015c8b65f18..88fe72ae967f 100644 --- a/drivers/char/tpm/tpm_tis_spi.c +++ b/drivers/char/tpm/tpm_tis_spi.c @@ -111,6 +111,7 @@ static int tpm_tis_spi_transfer(struct tpm_tis_data *data, u32 addr, u16 len, spi_xfer.cs_change = 0; spi_xfer.len = transfer_len; + spi_xfer.delay_usecs = 5; if (direction) { spi_xfer.tx_buf = NULL;