[PATCH 5/8] spi: sh-msiof: Wait for Tx FIFO empty after DMA

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Hiromitsu Yamasaki <hiromitsu.yamasaki.ym@xxxxxxxxxxx>

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 <hiromitsu.yamasaki.ym@xxxxxxxxxxx>
[adjust context]
Signed-off-by: Dirk Behme <dirk.behme@xxxxxxxxxxxx>
---
 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;
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux