From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932421AbdBPQJX (ORCPT ); Thu, 16 Feb 2017 11:09:23 -0500 Received: from smtp2.infineon.com ([217.10.52.18]:63778 "EHLO smtp2.infineon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932516AbdBPQJV (ORCPT ); Thu, 16 Feb 2017 11:09:21 -0500 X-SBRS: None From: Peter Huewe To: Jarkko Sakkinen CC: Jason Gunthorpe , , , , Christophe Ricard , "Peter Huewe" , , Alexander Steffen Subject: [PATCH 2/5] tpm_tis_spi: Abort transfer when too many wait states are signaled Date: Thu, 16 Feb 2017 16:08:23 +0000 Message-ID: <1487261306-2494-3-git-send-email-peter.huewe@infineon.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487261306-2494-1-git-send-email-peter.huewe@infineon.com> References: <1487261306-2494-1-git-send-email-peter.huewe@infineon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.29.170.145] X-ClientProxiedBy: MUCSE601.infineon.com (172.23.7.102) To MUCSE612.infineon.com (172.23.7.113) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Abort the transfer with ETIMEDOUT when the TPM signals more than TPM_RETRY wait states. Continuing with the transfer in this state will only lead to arbitrary failures in other parts of the code. Cc: Fixes: 0edbfea537d1 ("tpm/tpm_tis_spi: Add support for spi phy") Signed-off-by: Alexander Steffen Signed-off-by: Peter Huewe --- drivers/char/tpm/tpm_tis_spi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/char/tpm/tpm_tis_spi.c b/drivers/char/tpm/tpm_tis_spi.c index 6e1a3c43f621..d782b9974c14 100644 --- a/drivers/char/tpm/tpm_tis_spi.c +++ b/drivers/char/tpm/tpm_tis_spi.c @@ -101,6 +101,11 @@ static int tpm_tis_spi_transfer(struct tpm_tis_data *data, u32 addr, u8 len, goto exit; } + if (i == TPM_RETRY) { + ret = -ETIMEDOUT; + goto exit; + } + spi_xfer.cs_change = 0; spi_xfer.len = len; -- 2.7.4 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Huewe Subject: [PATCH 2/5] tpm_tis_spi: Abort transfer when too many wait states are signaled Date: Thu, 16 Feb 2017 16:08:23 +0000 Message-ID: <1487261306-2494-3-git-send-email-peter.huewe@infineon.com> References: <1487261306-2494-1-git-send-email-peter.huewe@infineon.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1487261306-2494-1-git-send-email-peter.huewe-d0qZbvYSIPpWk0Htik3J/w@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tpmdd-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org To: Jarkko Sakkinen Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, Christophe Ricard , Peter Huewe , Alexander List-Id: tpmdd-devel@lists.sourceforge.net Abort the transfer with ETIMEDOUT when the TPM signals more than TPM_RETRY wait states. Continuing with the transfer in this state will only lead to arbitrary failures in other parts of the code. Cc: Fixes: 0edbfea537d1 ("tpm/tpm_tis_spi: Add support for spi phy") Signed-off-by: Alexander Steffen Signed-off-by: Peter Huewe --- drivers/char/tpm/tpm_tis_spi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/char/tpm/tpm_tis_spi.c b/drivers/char/tpm/tpm_tis_spi.c index 6e1a3c43f621..d782b9974c14 100644 --- a/drivers/char/tpm/tpm_tis_spi.c +++ b/drivers/char/tpm/tpm_tis_spi.c @@ -101,6 +101,11 @@ static int tpm_tis_spi_transfer(struct tpm_tis_data *data, u32 addr, u8 len, goto exit; } + if (i == TPM_RETRY) { + ret = -ETIMEDOUT; + goto exit; + } + spi_xfer.cs_change = 0; spi_xfer.len = len; -- 2.7.4 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot