mmc: moxart: Stop host before releasing DMA channels
PATCH 1/1 mmc: moxart: Stop host before releasing DMA channels
moxart_remove() currently releases the TX and RX DMA channels before calling mmc_remove_host(). This allows the MMC host to remain active while the DMA channels are being torn down.
Call mmc_remove_host() before masking controller interrupts and releasing the DMA channels. Terminate any active DMA transfers before releasing their channels.
Keep the power and clock shutdown after DMA teardown. Do not call mmc_free_host(), since the host is allocated with devm_mmc_alloc_host() and is released automatically by devres.
--- drivers/mmc/host/moxart-mmc.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/mmc/host/moxart-mmc.c +16 -4
@@ -684,13 +684,25 @@ static void moxart_remove(struct platform_device *pdev)struct mmc_host *mmc =dev_get_drvdata (&pdev->dev);struct moxart_host *host =mmc_priv (mmc); -if (!IS_ERR_OR_NULL (host->dma_chan_tx)) -dma_release_channel (host->dma_chan_tx); -if (!IS_ERR_OR_NULL (host->dma_chan_rx)) -dma_release_channel (host->dma_chan_rx); +/* +* Stop the MMC host before releasing DMA channels. +* Keep controller interrupts enabled during MMC teardown. +*/ mmc_remove_host (mmc);writel (0 , host->base +REG_INTERRUPT_MASK ); + +if (!IS_ERR_OR_NULL (host->dma_chan_tx)) { +dmaengine_terminate_sync (host->dma_chan_tx); +dma_release_channel (host->dma_chan_tx); + host->dma_chan_tx =NULL ; + } +if (!IS_ERR_OR_NULL (host->dma_chan_rx)) { +dmaengine_terminate_sync (host->dma_chan_rx); +dma_release_channel (host->dma_chan_rx); + host->dma_chan_rx =NULL ; + } +writel (0 , host->base +REG_POWER_CONTROL );writel (readl (host->base +REG_CLOCK_CONTROL ) |CLK_OFF , host->base +REG_CLOCK_CONTROL );
Signature · 1 line
2.43.0
Quoted 9 lines · Guanxin Li
moxart_remove()currently releases the TX and RX DMA channels before callingmmc_remove_host(). This allows the MMC host to remain active while the DMA channels are being torn down.Call
mmc_remove_host()before masking controller interrupts and releasing the DMA channels. Terminate any active DMA transfers before releasing their channels.
Quoted 5 lines
Keep the power and clock shutdown after DMA teardown. Do not call
mmc_free_host(), since the host is allocated withdevm_mmc_alloc_host()and is released automatically by devres.Signed-off-by Guanxin Li <[email protected]>
Applied for next, thanks!
Kind regards
Uffe
Quoted 41 lines
--- drivers/mmc/host/moxart-mmc.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)drivers/mmc/host/moxart-mmc.c +16
-5@@ -684,13 +684,25 @@ static void moxart_remove(struct platform_device *pdev)struct mmc_host *mmc =dev_get_drvdata (&pdev->dev);struct moxart_host *host =mmc_priv (mmc); -if (!IS_ERR_OR_NULL (host->dma_chan_tx)) -dma_release_channel (host->dma_chan_tx); -if (!IS_ERR_OR_NULL (host->dma_chan_rx)) -dma_release_channel (host->dma_chan_rx); +/* +* Stop the MMC host before releasing DMA channels. +* Keep controller interrupts enabled during MMC teardown. +*/ mmc_remove_host (mmc);writel (0 , host->base +REG_INTERRUPT_MASK ); + +if (!IS_ERR_OR_NULL (host->dma_chan_tx)) { +dmaengine_terminate_sync (host->dma_chan_tx); +dma_release_channel (host->dma_chan_tx); + host->dma_chan_tx =NULL ; + } +if (!IS_ERR_OR_NULL (host->dma_chan_rx)) { +dmaengine_terminate_sync (host->dma_chan_rx); +dma_release_channel (host->dma_chan_rx); + host->dma_chan_rx =NULL ; + } +writel (0 , host->base +REG_POWER_CONTROL );writel (readl (host->base +REG_CLOCK_CONTROL ) |CLK_OFF , host->base +REG_CLOCK_CONTROL ); --2.43.0