From patchwork Wed Sep 6 07:05:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Behme X-Patchwork-Id: 9940001 X-Patchwork-Delegate: geert@linux-m68k.org 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 69F16604D5 for ; Wed, 6 Sep 2017 07:05:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58A5B28AFA for ; Wed, 6 Sep 2017 07:05:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D6B028B01; Wed, 6 Sep 2017 07:05: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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, 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 0633628AFA for ; Wed, 6 Sep 2017 07:05:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751614AbdIFHFR (ORCPT ); Wed, 6 Sep 2017 03:05:17 -0400 Received: from smtp6-v.fe.bosch.de ([139.15.237.11]:55536 "EHLO smtp6-v.fe.bosch.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751566AbdIFHFN (ORCPT ); Wed, 6 Sep 2017 03:05:13 -0400 Received: from vsmta12.fe.internet.bosch.com (unknown [10.4.98.52]) by imta23.fe.bosch.de (Postfix) with ESMTP id E50E315801E8; Wed, 6 Sep 2017 09:04:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=de.bosch.com; s=2015-01-21; t=1504681483; bh=JbLYvlyOc+H/3b2ur7aNFVMicCuJNJVOtVEm8wJtcNA=; l=10; h=From:From:Reply-To:Sender; b=wZ4iHHv5eF0Xx7g2BBX+d7HfctaXzM858HP4+iWVyKGSBYlYBc73lxl9YsZfOiPqP LEZ8kERgKq7JaGNvMApTOvxvbUH51M3FBXIZR20mO0X33OH6+WOBi//ICPdVwBxxz9 +vbyWNa1mqCjgfO+oB2yYMHCCDoaf4I/xd2i2/Ys= Received: from FE-HUB1001.de.bosch.com (vsgw22.fe.internet.bosch.com [10.4.98.11]) by vsmta12.fe.internet.bosch.com (Postfix) with ESMTP id 4427D1B807DB; Wed, 6 Sep 2017 09:05:12 +0200 (CEST) Received: from HI-Z0EVG.hi.de.bosch.com (10.34.218.219) by FE-HUB1001.de.bosch.com (10.4.103.109) with Microsoft SMTP Server id 14.3.319.2; Wed, 6 Sep 2017 09:05:11 +0200 Received: from HI-Z0EVG.hi.de.bosch.com (localhost [IPv6:::1]) by HI-Z0EVG.hi.de.bosch.com (Postfix) with ESMTP id CFC781B46B12; Wed, 6 Sep 2017 09:05:10 +0200 (CEST) From: Dirk Behme To: , , Geert Uytterhoeven CC: Hiromitsu Yamasaki , Dirk Behme Subject: [PATCH 5/8] spi: sh-msiof: Wait for Tx FIFO empty after DMA Date: Wed, 6 Sep 2017 09:05:04 +0200 Message-ID: <20170906070507.26223-6-dirk.behme@de.bosch.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170906070507.26223-1-dirk.behme@de.bosch.com> References: <20170906070507.26223-1-dirk.behme@de.bosch.com> MIME-Version: 1.0 X-TM-AS-MML: disable X-TM-AS-Product-Ver: IMSS-7.1.0.1679-8.1.0.1062-23304.006 X-TMASE-MatchedRID: UHN19ZU8rvkhRFK3mPl3fqTfLKfi4+0tvgj97y8eilZcU0dNErOD+vlY oV6p/cSxIGx7wsiI50H4mELJ2oxBl9eV00rMo+W9HPYwOJi6PLmjkoGZwmjMNpsoi2XrUn/Jn6K dMrRsL14qtq5d3cxkNfDs6gMISJ3lwvZc6tupWeUSVvKa2gmhcLxU7sFCYbWZn8VDW3OpsWsM7D B6AhYxq3ZGZilOpLrTiPPTaELVcd1g9Vsa3M0JQMWFcyN1Agmm Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hiromitsu Yamasaki When Tx DMA is only used, Tx FIFO is still not empty after DMA callback. This patch waits for sweeping data out of the Tx FIFO. Signed-off-by: Hiromitsu Yamasaki [adjust context] Signed-off-by: Dirk Behme --- drivers/spi/spi-sh-msiof.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c index 660b03ed6770..a960e8da123d 100644 --- a/drivers/spi/spi-sh-msiof.c +++ b/drivers/spi/spi-sh-msiof.c @@ -638,6 +638,17 @@ static int sh_msiof_wait_for_completion(struct sh_msiof_spi_priv *p, dev_err(&p->pdev->dev, "Tx DMA timeout\n"); return -ETIMEDOUT; } + if (!rx) { + sh_msiof_write(p, IER, IER_TEOFE); + + /* wait for tx fifo to be emptied */ + if (!wait_for_completion_timeout(&p->done, + HZ)) { + dev_err(&p->pdev->dev, + "Tx fifo to be emptied timeout\n"); + return -ETIMEDOUT; + } + } } if (rx) { if (!wait_for_completion_timeout(&p->done_dma_rx, @@ -805,7 +816,7 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx, goto stop_dma; } - /* wait for tx fifo to be emptied / rx fifo to be filled */ + /* wait for Tx/Rx DMA completion */ ret = sh_msiof_wait_for_completion(p, tx, rx); if (ret) goto stop_reset;