From: Guanxin Li <bruceli20040604@gmail.com>
To: Ulf Hansson <ulfh@kernel.org>,
Guanxin Li <bruceli20040604@gmail.com>,
Pengpeng Hou <pengpeng@iscas.ac.cn>,
Rosen Penev <rosenp@gmail.com>,
linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] mmc: moxart: Stop host before releasing DMA channels
Date: Wed, 21 Oct 2026 21:06:25 +0800 [thread overview]
Message-ID: <20261021130625.1616753-1-bruceli20040604@gmail.com> (raw)
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
reply other threads:[~2026-10-21 13:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261021130625.1616753-1-bruceli20040604@gmail.com \
--to=bruceli20040604@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=pengpeng@iscas.ac.cn \
--cc=rosenp@gmail.com \
--cc=ulfh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®