[PATCH] mmc: renesas_sdhi: sys_dmac: abort DMA synced to avoid timeouts

Wolfram Sang
2021-06-21T07:00:38Z

When aborting DMA, we terminate the transfer without waiting for it to
succeed. This may lead to races which can e.g. lead to timeout problems
when tuning. Remove the deprecated dmaengine_terminate_all() function
and use the explicit dmaengine_terminate_sync().

Fixes: e3de2be7368d ("mmc: tmio_mmc: fix card eject during IO with DMA")
Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

Geert, this fixes the issue you have seen on your Koelsch board on my
Lager board. Can you test again with this patch please?

I noticed that Renesas driver are quite an active user of this
deprecated dmaengine function. I will audit and improve the other
drivers meanwhile.

drivers/mmc/host/renesas_sdhi_sys_dmac.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/renesas_sdhi_sys_dmac.c b/drivers/mmc/host/renesas_sdhi_sys_dmac.c
index ffa64211f4de..6956b83469c8 100644
--- a/drivers/mmc/host/renesas_sdhi_sys_dmac.c
+++ b/drivers/mmc/host/renesas_sdhi_sys_dmac.c
@@ -108,9 +108,9 @@ static void renesas_sdhi_sys_dmac_abort_dma(struct tmio_mmc_host *host)
renesas_sdhi_sys_dmac_enable_dma(host, false);

if (host->chan_rx)
- dmaengine_terminate_all(host->chan_rx);
+ dmaengine_terminate_sync(host->chan_rx);
if (host->chan_tx)
- dmaengine_terminate_all(host->chan_tx);
+ dmaengine_terminate_sync(host->chan_tx);

renesas_sdhi_sys_dmac_enable_dma(host, true);
}
--
2.30.2