From patchwork Mon Apr 16 20:01:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "sxauwsk@163.com" X-Patchwork-Id: 10347109 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 87F5560244 for ; Wed, 18 Apr 2018 01:17:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92D782239C for ; Wed, 18 Apr 2018 01:17:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8776028399; Wed, 18 Apr 2018 01:17:18 +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.3 required=2.0 tests=BAYES_00, DATE_IN_PAST_24_48, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, RCVD_IN_SBL, 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 CE0282239C for ; Wed, 18 Apr 2018 01:17:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752679AbeDRBRR (ORCPT ); Tue, 17 Apr 2018 21:17:17 -0400 Received: from m12-13.163.com ([220.181.12.13]:56319 "EHLO m12-13.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751248AbeDRBRQ (ORCPT ); Tue, 17 Apr 2018 21:17:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=HlRv8ghV/jRJzSqtDz fpnRJQtyaoEvTBnoO5Y4lG2cY=; b=Mk2r6o6VzAOH7WJLUEFDT/b6xVM7gNEfR3 GvRSH0oGcUR7HRK9ZCScMo59qk3bmSJAh3KSJXi0HmIv3qzRvYITiWihB6fIQyTN pBwlcpMSWdUdwm+HFb+9wexZfeScKHveRGQkadZyuUoDIjD4pE2cQTrgfmo8mKcd lO3wlu/Lk= Received: from localhost.localdomain (unknown [113.140.17.238]) by smtp9 (Coremail) with SMTP id DcCowAC3_feWnNZaRTViBQ--.15953S3; Wed, 18 Apr 2018 09:17:11 +0800 (CST) From: sxauwsk To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, sxauwsk Subject: [PATCH] spi: cadence: Add usleep_range() for cdns_spi_fill_tx_fifo() Date: Tue, 17 Apr 2018 04:01:27 +0800 Message-Id: <1523908887-48616-1-git-send-email-sxauwsk@163.com> X-Mailer: git-send-email 1.7.9.5 X-CM-TRANSID: DcCowAC3_feWnNZaRTViBQ--.15953S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrKF43Xw1DZw4DtryUZFy3twb_yoWDArXEvF 18Cr4kGay5CF9Fy3W29rsrAFWjvF4kGr1v9ayqq39xGrsrAFn2v34rZr1q9w17Aw4UuFn3 urn5Wa4xZr13KjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRiTmh3UUUUU== X-Originating-IP: [113.140.17.238] X-CM-SenderInfo: 5v0d34lvn6il2tof0z/xtbBZxcsJletpeD5aQAAsV Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In case of xspi work in busy condition, may send bytes failed. once something wrong, spi controller did't work any more My test found this situation appear in both of read/write process. so when TX FIFO is full, add one byte delay before send data; Signed-off-by: sxauwsk --- drivers/spi/spi-cadence.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c index 5c9516a..4a00163 100644 --- a/drivers/spi/spi-cadence.c +++ b/drivers/spi/spi-cadence.c @@ -313,6 +313,14 @@ static void cdns_spi_fill_tx_fifo(struct cdns_spi *xspi) while ((trans_cnt < CDNS_SPI_FIFO_DEPTH) && (xspi->tx_bytes > 0)) { + + /* When xspi in busy condition, bytes may send failed, + * then spi control did't work thoroughly, add one byte delay + */ + if (cdns_spi_read(xspi, CDNS_SPI_ISR) & + CDNS_SPI_IXR_TXFULL) + usleep_range(10, 20); + if (xspi->txbuf) cdns_spi_write(xspi, CDNS_SPI_TXD, *xspi->txbuf++); else