From patchwork Mon Jul 1 15:37:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Schaefer X-Patchwork-Id: 1125450 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kontron.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45cs3j4TD7z9s00 for ; Tue, 2 Jul 2019 01:38:56 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id EA0B0C21DFB; Mon, 1 Jul 2019 15:38:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 6452AC21DB6; Mon, 1 Jul 2019 15:38:39 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9FD8DC21DFB; Mon, 1 Jul 2019 15:38:20 +0000 (UTC) Received: from skedge03.snt-world.com (skedge03.snt-world.com [91.208.41.68]) by lists.denx.de (Postfix) with ESMTPS id E53ABC21E4F for ; Mon, 1 Jul 2019 15:38:16 +0000 (UTC) Received: from sntmail14r.snt-is.com (unknown [10.203.32.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by skedge03.snt-world.com (Postfix) with ESMTPS id 577AC67AB41; Mon, 1 Jul 2019 17:37:52 +0200 (CEST) Received: from DDESAB0033.kontron.local (10.228.0.137) by sntmail14r.snt-is.com (10.203.32.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 1 Jul 2019 17:37:51 +0200 From: Thomas Schaefer To: , , , , Date: Mon, 1 Jul 2019 17:37:34 +0200 Message-ID: <20190701153735.170-2-thomas.schaefer@kontron.com> X-Mailer: git-send-email 2.22.0.windows.1 In-Reply-To: <20190701153735.170-1-thomas.schaefer@kontron.com> References: <20190701153735.170-1-thomas.schaefer@kontron.com> MIME-Version: 1.0 X-Originating-IP: [10.228.0.137] X-ClientProxiedBy: sntmail14r.snt-is.com (10.203.32.184) To sntmail14r.snt-is.com (10.203.32.184) X-C2ProcessedOrg: 51b406b7-48a2-4d03-b652-521f56ac89f3 X-SnT-MailScanner-Information: Please contact the ISP for more information X-SnT-MailScanner-ID: 577AC67AB41.AB654 X-SnT-MailScanner: Not scanned: please contact your Internet E-Mail Service Provider for details X-SnT-MailScanner-SpamCheck: X-SnT-MailScanner-From: thomas.schaefer@kontron.com X-SnT-MailScanner-To: festevam@gmail.com, jagan@amarulasolutions.com, sbabic@denx.de, trini@konsulko.com, u-boot@lists.denx.de Cc: Thomas Schaefer Subject: [U-Boot] [PATCH 1/2] drivers/spi: fsl_qspi: fix read timeout X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" During QSPI reads, current is_controller_busy function sporadically fails with -ETIMEDOUT due to fixed number of 5 test loops. Using timer functions to wait 1000 us instead will fix this. Signed-off-by: Thomas Schaefer Reviewed-by: Fabio Estevam --- drivers/spi/fsl_qspi.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/spi/fsl_qspi.c b/drivers/spi/fsl_qspi.c index 1598c4f698..2c5937509f 100644 --- a/drivers/spi/fsl_qspi.c +++ b/drivers/spi/fsl_qspi.c @@ -152,7 +152,7 @@ static inline int is_controller_busy(const struct fsl_qspi_priv *priv) u32 val; const u32 mask = QSPI_SR_BUSY_MASK | QSPI_SR_AHB_ACC_MASK | QSPI_SR_IP_ACC_MASK; - unsigned int retry = 5; + unsigned long timeout = timer_get_us() + 1000; do { val = qspi_read32(priv->flags, &priv->regs->sr); @@ -160,10 +160,9 @@ static inline int is_controller_busy(const struct fsl_qspi_priv *priv) if ((~val & mask) == mask) return 0; - udelay(1); - } while (--retry); - - return -ETIMEDOUT; + if (timer_get_us() > timeout ) + return -ETIMEDOUT; + } while (1); } /* QSPI support swapping the flash read/write data