From patchwork Fri Dec 8 18:46:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Steffen X-Patchwork-Id: 10103167 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2D336602A0 for ; Fri, 8 Dec 2017 18:53:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C86328697 for ; Fri, 8 Dec 2017 18:53:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FF9228E40; Fri, 8 Dec 2017 18:53:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B32128697 for ; Fri, 8 Dec 2017 18:53:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752609AbdLHSxq (ORCPT ); Fri, 8 Dec 2017 13:53:46 -0500 Received: from smtp2.infineon.com ([217.10.52.18]:58397 "EHLO smtp2.infineon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752003AbdLHSxp (ORCPT ); Fri, 8 Dec 2017 13:53:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=infineon.com; i=@infineon.com; q=dns/txt; s=IFXMAIL; t=1512759225; x=1544295225; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=x/MZmGDKjqnrTgXFz8aJO7lalFm4ZBlOPU1DoQQMC18=; b=iuGXf4olO3w/ZNGNzF78XDK2xQawASl1K82vjJfApY5u2f2HoVEphJ+e uYw2AzjxEvrp/4uSfPoJndFoVRDudxRxo5cRbMdPE5sBYL7a5SBP51ckM uzAiL6u0KbPLitKF9gXcfQE9Axuzs7Xes2BA7QTyrzBn3XqZY2gO/TNY0 A=; X-SBRS: None Received: from unknown (HELO mucxv002.muc.infineon.com) ([172.23.11.17]) by smtp2.infineon.com with ESMTP/TLS/AES256-GCM-SHA384; 08 Dec 2017 19:53:44 +0100 Received: from MUCSE708.infineon.com (mucse708.infineon.com [172.23.7.82]) by mucxv002.muc.infineon.com (Postfix) with ESMTPS; Fri, 8 Dec 2017 19:53:44 +0100 (CET) Received: from ABGN5CG4522MQD.eu.infineon.com (172.23.8.247) by MUCSE708.infineon.com (172.23.7.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.669.32; Fri, 8 Dec 2017 19:53:44 +0100 From: Alexander Steffen To: , , , CC: Alexander Steffen Subject: [RFC][PATCH 8/9] tpm_tis_spi: add delay between wait state retries Date: Fri, 8 Dec 2017 19:46:57 +0100 Message-ID: <20171208184658.9588-9-Alexander.Steffen@infineon.com> X-Mailer: git-send-email 2.11.1.windows.1 In-Reply-To: <20171208184658.9588-1-Alexander.Steffen@infineon.com> References: <20171208184658.9588-1-Alexander.Steffen@infineon.com> MIME-Version: 1.0 X-Originating-IP: [172.23.8.247] X-ClientProxiedBy: MUCSE706.infineon.com (172.23.7.80) To MUCSE708.infineon.com (172.23.7.82) Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;