From patchwork Mon Apr 16 06:46:40 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: 10342255 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 0B52E60365 for ; Mon, 16 Apr 2018 06:47:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC97227D0C for ; Mon, 16 Apr 2018 06:47:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDD1927EED; Mon, 16 Apr 2018 06:47: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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,MAILING_LIST_MULTI,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 185A127D0C for ; Mon, 16 Apr 2018 06:47:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753456AbeDPGro (ORCPT ); Mon, 16 Apr 2018 02:47:44 -0400 Received: from m12-18.163.com ([220.181.12.18]:44408 "EHLO m12-18.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751199AbeDPGrn (ORCPT ); Mon, 16 Apr 2018 02:47:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=fdKdDPGWFZeD2wMAu3 7agLER2rI/rVUF4Ab7wHIgPJk=; b=AL22h24dhAFcS1KSarqMxSAj9qygKt5XvX 9CKrr4m+qvE/XcnGDRKzz8/ab2WA22H7rFGHoPjhzuY0XpZEe5Glz9+aJ0UNn5/7 a1hJMQJ8dlQxDN1ZVOCSFBjlWORwCzTqC6PqSVhD+Kj6cvXJ9A4uKq8KwYXiUhlj /TTg3Esiw= Received: from localhost.localdomain (unknown [113.140.17.238]) by smtp14 (Coremail) with SMTP id EsCowAAn5EXvRtRaPtkLFg--.12687S3; Mon, 16 Apr 2018 14:47:12 +0800 (CST) From: sxauwsk To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, wangshikai@inno-instrument.cn, sxauwsk , guojian Subject: [PATCH] [PATCH v1] spi: cadence: Add usleep_range() for cdns_spi_fill_tx_fifo() Date: Mon, 16 Apr 2018 14:46:40 +0800 Message-Id: <1523861200-34130-1-git-send-email-sxauwsk@163.com> X-Mailer: git-send-email 1.7.9.5 X-CM-TRANSID: EsCowAAn5EXvRtRaPtkLFg--.12687S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrKF43Xw1DZw4DtryUAFWfAFb_yoWkKrbEvF 18Aw1DGw45KF9rA3W29FsxAFWv9an5Cr1kuFWqqa9xJw47Z3Z2vr95Zr1DuwsxCa1UWF9x ZrnYkayUArnxKjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRRJ3ktUUUUU== X-Originating-IP: [113.140.17.238] X-CM-SenderInfo: 5v0d34lvn6il2tof0z/1tbiQBAqJlSIVnL2AAAAsS 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 Signed-off-by: guojian Signed-off-by: wangshikai --- drivers/spi/spi-cadence.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c index 66ae055..9694042 100644 --- a/drivers/spi/spi-cadence.c +++ b/drivers/spi/spi-cadence.c @@ -315,9 +315,11 @@ static void cdns_spi_fill_tx_fifo(struct cdns_spi *xspi) (xspi->tx_bytes > 0)) { /* When xspi in busy condition, bytes may send failed, - * caused communication failure so add one byte delay + * then spi control did't work thoroughly, add one byte delay */ - usleep_range(10, 20); + if (cdns_spi_read(xspi, CDNS_SPI_ISR_OFFSET) & + CDNS_SPI_IXR_TXFULL_MASK) + usleep_range(10, 20); if (xspi->txbuf) cdns_spi_write(xspi, CDNS_SPI_TXD, *xspi->txbuf++);