mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mmc: moxart: Stop host before releasing DMA channels
@ 2026-10-21 13:06 Guanxin Li
  0 siblings, 0 replies; only message in thread
From: Guanxin Li @ 2026-10-21 13:06 UTC (permalink / raw)
  To: Ulf Hansson, Guanxin Li, Pengpeng Hou, Rosen Penev, linux-mmc,
	linux-kernel

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@gmail.com>
---
 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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-21 13:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-21 13:06 [PATCH] mmc: moxart: Stop host before releasing DMA channels Guanxin Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®