[PATCH] mmc: moxart: Stop host before releasing DMA channels
From: Guanxin Li
Date: Wed Oct 21 2026 - 09:08:20 EST
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.
Signed-off-by: Guanxin Li <bruceli20040604@xxxxxxxxx>
---
drivers/mmc/host/moxart-mmc.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c
index 28aed13549a6..bece33f4792d 100644
--- a/drivers/mmc/host/moxart-mmc.c
+++ b/drivers/mmc/host/moxart-mmc.c
@@ -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