Skip to contentSkip to conversation

mmc: mediatek: add wait dma stop done flow

PATCH Superseded Derong Liu 2 participants 2 messages Aug 9, 2021 – Aug 16, 2021

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Derong Liu

author
#0 lore raw

PATCH v2 1/1 mmc: mediatek: add wait dma stop done flow

We found this issue on a 5G platform, during CMDQ error handling, if DMA status is active when it call msdc_reset_hw, it means mmc host hw reset and DMA transfer will be parallel, mmc host may access sram region unexpectedly.

According to the programming guide of mtk mmc host,it needs to wait for dma stop done after set dma stop. This change should be applied to all SoCs.

---
 drivers/mmc/host/mtk-sd.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mmc/host/mtk-sd.c +2 -0
index 4dfc246c5f95..1dfd2842471b 100644
@@ -2339,6 +2339,8 @@ static void msdc_cqe_disable(struct mmc_host *mmc, bool recovery)
 	if (recovery) {
 		sdr_set_field(host->base + MSDC_DMA_CTRL,
 			      MSDC_DMA_CTRL_STOP, 1);
+		while (readl(host->base + MSDC_DMA_CFG) & MSDC_DMA_CFG_STS)
+			cpu_relax();
 		msdc_reset_hw(host);
 	}
 }
Signature · 1 line
2.18.0
#1 lore raw
Quoted 16 lines · Derong Liu

We found this issue on a 5G platform, during CMDQ error handling, if DMA status is active when it call msdc_reset_hw, it means mmc host hw reset and DMA transfer will be parallel, mmc host may access sram region unexpectedly.

According to the programming guide of mtk mmc host,it needs to wait for dma stop done after set dma stop. This change should be applied to all SoCs.

---
 drivers/mmc/host/mtk-sd.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mmc/host/mtk-sd.c +0 -0
index 4dfc246c5f95..1dfd2842471b 100644

drivers/mmc/host/mtk-sd.c static void msdc_cqe_disable(struct mmc_host *mmc, bool recovery) · line 2343

Quoted 5 lines
drivers/mmc/host/mtk-sd.c +2 -0
@@ -2339,6 +2339,8 @@ static void msdc_cqe_disable(struct mmc_host *mmc, bool recovery)
        if (recovery) {
                sdr_set_field(host->base + MSDC_DMA_CTRL,
                              MSDC_DMA_CTRL_STOP, 1);
+               while (readl(host->base + MSDC_DMA_CFG) & MSDC_DMA_CFG_STS)
+                       cpu_relax();

I suggest you look into using readl_poll_timeout() - as we don't want to hang indefinitely, no matter what.

Quoted 5 lines
drivers/mmc/host/mtk-sd.c +0 -1
                msdc_reset_hw(host);
        }
 }
--

2.18.0

Kind regards
Uffe