From patchwork Mon Apr 16 12:07:31 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: 10344201 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 CE29360216 for ; Tue, 17 Apr 2018 02:09:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE52228981 for ; Tue, 17 Apr 2018 02:09:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B17A4289A7; Tue, 17 Apr 2018 02:09:20 +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.7 required=2.0 tests=BAYES_00, DATE_IN_PAST_12_24, 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 2F8EC28981 for ; Tue, 17 Apr 2018 02:09:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752040AbeDQCI7 (ORCPT ); Mon, 16 Apr 2018 22:08:59 -0400 Received: from m12-18.163.com ([220.181.12.18]:48405 "EHLO m12-18.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751970AbeDQCI6 (ORCPT ); Mon, 16 Apr 2018 22:08:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=zLiHyNkYR9oksJ1Loe 8ByCiVA/j8+P87/IBMZOdRkY8=; b=qdxYLf26a+8/yvhp3686ELHsGG5WG9czU5 V3V0fpTKPqJFOMbJ8w0hhOsJEtZ++qUtr8/BCdl6dWdy+6M4pqGxrGtjZeHyq3Rc /VyY/d7juvZtIKVwFrnkfro33dAdOWUP5Gga1a+yn/gBfMggKwTP4+aq0jqRsKvw CAby6C2Hg= Received: from localhost.localdomain (unknown [113.140.17.238]) by smtp14 (Coremail) with SMTP id EsCowADHZicwV9VahLSRFg--.23040S3; Tue, 17 Apr 2018 10:08:50 +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: Mon, 16 Apr 2018 20:07:31 +0800 Message-Id: <1523880451-37748-1-git-send-email-sxauwsk@163.com> X-Mailer: git-send-email 1.7.9.5 X-CM-TRANSID: EsCowADHZicwV9VahLSRFg--.23040S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrKr1rCF43GryrJw1rGr15urg_yoWDtwbEvr 18Crs7Gay5GF9FyFy29Fs7AFyjvF4kGr1v9a90q39xJanrAFn2vFy8ZF1Du3srAw4UuFn3 urn5Gas7Ar13KjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRiTmh3UUUUU== X-Originating-IP: [113.140.17.238] X-CM-SenderInfo: 5v0d34lvn6il2tof0z/1tbiDhIrJlXlm7L7awAAsY 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 then caused communication failure. once something wrong, spi controller did't work any more. My test found this situation appear in both of read/write operation. 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..9694042 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_OFFSET) & + CDNS_SPI_IXR_TXFULL_MASK) + usleep_range(10, 20); + if (xspi->txbuf) cdns_spi_write(xspi, CDNS_SPI_TXD, *xspi->txbuf++); else