blob: b853dc78e32aadb07f9dacb7cf96078ea4babb3b [file] [log] [blame]
From e17a38f4d61b11f87a95009974bc50b89bd83011 Mon Sep 17 00:00:00 2001
From: Martin Fuzzey <>
Date: Wed, 29 Jan 2020 14:40:06 +0100
Subject: [PATCH] dmaengine: imx-sdma: fix context cache
commit d288bddd8374e0a043ac9dde64a1ae6a09411d74 upstream.
There is a DMA problem with the serial ports on i.MX6.
When the following sequence is performed:
1) Open a port
2) Write some data
3) Close the port
4) Open a *different* port
5) Write some data
6) Close the port
The second write sends nothing and the second close hangs.
If the first close() is omitted it works.
Adding logs to the the UART driver shows that the DMA is being setup but
the callback is never invoked for the second write.
This used to work in 4.19.
Git bisect leads to:
ad0d92d: "dmaengine: imx-sdma: refine to load context only once"
This commit adds a "context_loaded" flag used to avoid unnecessary context
However the flag is only reset in sdma_channel_terminate_work(),
which is only invoked in a worker triggered by sdma_terminate_all() IF
there is an active descriptor.
So, if no active descriptor remains when the channel is terminated, the
flag is not reset and, when the channel is later reused the old context
is used.
Fix the problem by always resetting the flag in sdma_free_chan_resources().
Signed-off-by: Martin Fuzzey <>
Fixes: ad0d92d7ba6a ("dmaengine: imx-sdma: refine to load context only once")
Reviewed-by: Fabio Estevam <>
Signed-off-by: Vinod Koul <>
Signed-off-by: Paul Gortmaker <>
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 3ba0e9499c37..713f4a7dbe96 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -1335,6 +1335,7 @@ static void sdma_free_chan_resources(struct dma_chan *chan)
sdmac->event_id0 = 0;
sdmac->event_id1 = 0;
+ sdmac->context_loaded = false;
sdma_set_channel_priority(sdmac, 0);