]> git.baikalelectronics.ru Git - kernel.git/commit
dmaengine: imx-sdma: fix context cache
authorMartin Fuzzey <martin.fuzzey@flowbird.group>
Wed, 29 Jan 2020 13:40:06 +0000 (14:40 +0100)
committerVinod Koul <vkoul@kernel.org>
Mon, 24 Feb 2020 16:57:05 +0000 (22:27 +0530)
commitf7548f84f0832d86ac36677d8f51b9b87a7b33d4
tree300b54d28b5bf6a3131a709008092736ec6c941b
parent73a39e9dd634ba453e78492e58a26276be22acb7
dmaengine: imx-sdma: fix context cache

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:
8b94c8b: "dmaengine: imx-sdma: refine to load context only once"

This commit adds a "context_loaded" flag used to avoid unnecessary context
setups.
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().

Cc: stable@vger.kernel.org
Signed-off-by: Martin Fuzzey <martin.fuzzey@flowbird.group>
Fixes: 8b94c8b82cd7 ("dmaengine: imx-sdma: refine to load context only once")
Reviewed-by: Fabio Estevam <festevam@gmail.com>
Link: https://lore.kernel.org/r/1580305274-27274-1-git-send-email-martin.fuzzey@flowbird.group
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/imx-sdma.c