Received: by 10.192.165.156 with SMTP id m28csp1321945imm; Mon, 16 Apr 2018 19:10:23 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/sSrE07hDLEmZS8jCucj8tP2mCNHCygh+2Obfxd9/QjRajuTvNbH188kk3+FTeFoI6fQ2D X-Received: by 2002:a17:902:ba94:: with SMTP id k20-v6mr205966pls.193.1523931023196; Mon, 16 Apr 2018 19:10:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523931023; cv=none; d=google.com; s=arc-20160816; b=mKV6nRxhdAfA3DPC2PR071PK78KKwX+uo7vJFFU6hrx8DWzcTGXO3YhURy3b0uyxPl YSM4EmvhbXKaggK+f8kc+hxx2iwYUZ+jAZJUm3eTvtrvZLjJHOr7xYo8Vv7b5VpXd4aP 673JbUPveaNqiejqPIhk7nai+XT0uzAplTBlfvjoIgfdn7Z+48xdKhXlKgxSzWN1RlbQ BWhCj1TlcVcaka+OGEExj9zliae8nkdYdamBwOhBMKAHA3VfBcv86GhKV43PhIai2LCI WUpzxIoe9x1TDdgLakH65w5GFU3euIAK6OEa6T9SLiLw724GQdWmJ44G5QnKiy63HrDA ZdDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=zLiHyNkYR9oksJ1Loe8ByCiVA/j8+P87/IBMZOdRkY8=; b=0Ar00zpaLqh/dPhGd1Mc/F97B3K8iGSo/KhlqCdQ0fpfMF6tyIzr+DlN1UyxJm/15Q DDrUuV8Zqjd+DOZp0Xyncgh1lZiOtXIf2B75bDqE0W/DOszS4tADLAaCgTi3FosROFKf IRcgUXaRrABAKa9bXVg+FU90Ibv6RVpQT3oPBqQIjqCe9eHUEQC2jJhJUKTISNnW0BM5 XhbaPYZt4u8GmokIJlCjlOnPDtWez/nAqKOdYqwyK0PIWRVFPWZSL92wXlEd65KoMolm 1RIj9GYvLpZckaYpJjeF7i49YUEyRNCXPkBr7gXqGlDhJdTW0myOCml1hc0eNcpciCdd G12A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=qdxYLf26; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t11si12043570pfl.55.2018.04.16.19.10.09; Mon, 16 Apr 2018 19:10:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=qdxYLf26; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753060AbeDQCJA (ORCPT + 99 others); Mon, 16 Apr 2018 22:09:00 -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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(+) 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 -- 1.7.9.5