All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] mmc: mediatek: add wait dma stop done flow
@ 2021-08-27  7:15 Derong Liu
  2021-09-06 17:09   ` Ulf Hansson
  0 siblings, 1 reply; 4+ messages in thread
From: Derong Liu @ 2021-08-27  7:15 UTC (permalink / raw)
  To: Chaotian Jing, Ulf Hansson, Matthias Brugger
  Cc: linux-mmc, linux-arm-kernel, linux-mediatek, linux-kernel,
	wsp_upstream, Peng Zhou, 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.

Change-Id: I9b87523f19b24ca73958bbcb83bb418413c5a180
Signed-off-by: Derong Liu <derong.liu@mediatek.com>
---
 drivers/mmc/host/mtk-sd.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
index 4dfc246c5f95..b99330bad6a5 100644
--- a/drivers/mmc/host/mtk-sd.c
+++ b/drivers/mmc/host/mtk-sd.c
@@ -8,6 +8,7 @@
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
+#include <linux/iopoll.h>
 #include <linux/ioport.h>
 #include <linux/irq.h>
 #include <linux/of_address.h>
@@ -2330,6 +2331,7 @@ static void msdc_cqe_enable(struct mmc_host *mmc)
 static void msdc_cqe_disable(struct mmc_host *mmc, bool recovery)
 {
 	struct msdc_host *host = mmc_priv(mmc);
+	unsigned int val = 0;
 
 	/* disable cmdq irq */
 	sdr_clr_bits(host->base + MSDC_INTEN, MSDC_INT_CMDQ);
@@ -2339,6 +2341,9 @@ 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);
+		if (WARN_ON(readl_poll_timeout(host->base + MSDC_DMA_CFG, val,
+			!(val & MSDC_DMA_CFG_STS), 1, 3000)))
+			return;
 		msdc_reset_hw(host);
 	}
 }
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] mmc: mediatek: add wait dma stop done flow
  2021-08-27  7:15 [PATCH v3] mmc: mediatek: add wait dma stop done flow Derong Liu
  2021-09-06 17:09   ` Ulf Hansson
@ 2021-09-06 17:09   ` Ulf Hansson
  0 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2021-09-06 17:09 UTC (permalink / raw)
  To: Derong Liu
  Cc: Chaotian Jing, Matthias Brugger, linux-mmc, Linux ARM,
	moderated list:ARM/Mediatek SoC support,
	Linux Kernel Mailing List, wsp_upstream, Peng Zhou

On Fri, 27 Aug 2021 at 09:15, Derong Liu <derong.liu@mediatek.com> wrote:
>
> 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.
>
> Change-Id: I9b87523f19b24ca73958bbcb83bb418413c5a180

I am dropping this tag.

> Signed-off-by: Derong Liu <derong.liu@mediatek.com>

Applied for next, thanks! I guess we should also tag this for stable
kernels, right?

Kind regards
Uffe


> ---
>  drivers/mmc/host/mtk-sd.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
> index 4dfc246c5f95..b99330bad6a5 100644
> --- a/drivers/mmc/host/mtk-sd.c
> +++ b/drivers/mmc/host/mtk-sd.c
> @@ -8,6 +8,7 @@
>  #include <linux/clk.h>
>  #include <linux/delay.h>
>  #include <linux/dma-mapping.h>
> +#include <linux/iopoll.h>
>  #include <linux/ioport.h>
>  #include <linux/irq.h>
>  #include <linux/of_address.h>
> @@ -2330,6 +2331,7 @@ static void msdc_cqe_enable(struct mmc_host *mmc)
>  static void msdc_cqe_disable(struct mmc_host *mmc, bool recovery)
>  {
>         struct msdc_host *host = mmc_priv(mmc);
> +       unsigned int val = 0;
>
>         /* disable cmdq irq */
>         sdr_clr_bits(host->base + MSDC_INTEN, MSDC_INT_CMDQ);
> @@ -2339,6 +2341,9 @@ 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);
> +               if (WARN_ON(readl_poll_timeout(host->base + MSDC_DMA_CFG, val,
> +                       !(val & MSDC_DMA_CFG_STS), 1, 3000)))
> +                       return;
>                 msdc_reset_hw(host);
>         }
>  }
> --
> 2.18.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] mmc: mediatek: add wait dma stop done flow
@ 2021-09-06 17:09   ` Ulf Hansson
  0 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2021-09-06 17:09 UTC (permalink / raw)
  To: Derong Liu
  Cc: Chaotian Jing, Matthias Brugger, linux-mmc, Linux ARM,
	moderated list:ARM/Mediatek SoC support,
	Linux Kernel Mailing List, wsp_upstream, Peng Zhou

On Fri, 27 Aug 2021 at 09:15, Derong Liu <derong.liu@mediatek.com> wrote:
>
> 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.
>
> Change-Id: I9b87523f19b24ca73958bbcb83bb418413c5a180

I am dropping this tag.

> Signed-off-by: Derong Liu <derong.liu@mediatek.com>

Applied for next, thanks! I guess we should also tag this for stable
kernels, right?

Kind regards
Uffe


> ---
>  drivers/mmc/host/mtk-sd.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
> index 4dfc246c5f95..b99330bad6a5 100644
> --- a/drivers/mmc/host/mtk-sd.c
> +++ b/drivers/mmc/host/mtk-sd.c
> @@ -8,6 +8,7 @@
>  #include <linux/clk.h>
>  #include <linux/delay.h>
>  #include <linux/dma-mapping.h>
> +#include <linux/iopoll.h>
>  #include <linux/ioport.h>
>  #include <linux/irq.h>
>  #include <linux/of_address.h>
> @@ -2330,6 +2331,7 @@ static void msdc_cqe_enable(struct mmc_host *mmc)
>  static void msdc_cqe_disable(struct mmc_host *mmc, bool recovery)
>  {
>         struct msdc_host *host = mmc_priv(mmc);
> +       unsigned int val = 0;
>
>         /* disable cmdq irq */
>         sdr_clr_bits(host->base + MSDC_INTEN, MSDC_INT_CMDQ);
> @@ -2339,6 +2341,9 @@ 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);
> +               if (WARN_ON(readl_poll_timeout(host->base + MSDC_DMA_CFG, val,
> +                       !(val & MSDC_DMA_CFG_STS), 1, 3000)))
> +                       return;
>                 msdc_reset_hw(host);
>         }
>  }
> --
> 2.18.0

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] mmc: mediatek: add wait dma stop done flow
@ 2021-09-06 17:09   ` Ulf Hansson
  0 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2021-09-06 17:09 UTC (permalink / raw)
  To: Derong Liu
  Cc: Chaotian Jing, Matthias Brugger, linux-mmc, Linux ARM,
	moderated list:ARM/Mediatek SoC support,
	Linux Kernel Mailing List, wsp_upstream, Peng Zhou

On Fri, 27 Aug 2021 at 09:15, Derong Liu <derong.liu@mediatek.com> wrote:
>
> 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.
>
> Change-Id: I9b87523f19b24ca73958bbcb83bb418413c5a180

I am dropping this tag.

> Signed-off-by: Derong Liu <derong.liu@mediatek.com>

Applied for next, thanks! I guess we should also tag this for stable
kernels, right?

Kind regards
Uffe


> ---
>  drivers/mmc/host/mtk-sd.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
> index 4dfc246c5f95..b99330bad6a5 100644
> --- a/drivers/mmc/host/mtk-sd.c
> +++ b/drivers/mmc/host/mtk-sd.c
> @@ -8,6 +8,7 @@
>  #include <linux/clk.h>
>  #include <linux/delay.h>
>  #include <linux/dma-mapping.h>
> +#include <linux/iopoll.h>
>  #include <linux/ioport.h>
>  #include <linux/irq.h>
>  #include <linux/of_address.h>
> @@ -2330,6 +2331,7 @@ static void msdc_cqe_enable(struct mmc_host *mmc)
>  static void msdc_cqe_disable(struct mmc_host *mmc, bool recovery)
>  {
>         struct msdc_host *host = mmc_priv(mmc);
> +       unsigned int val = 0;
>
>         /* disable cmdq irq */
>         sdr_clr_bits(host->base + MSDC_INTEN, MSDC_INT_CMDQ);
> @@ -2339,6 +2341,9 @@ 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);
> +               if (WARN_ON(readl_poll_timeout(host->base + MSDC_DMA_CFG, val,
> +                       !(val & MSDC_DMA_CFG_STS), 1, 3000)))
> +                       return;
>                 msdc_reset_hw(host);
>         }
>  }
> --
> 2.18.0

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-06 17:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-27  7:15 [PATCH v3] mmc: mediatek: add wait dma stop done flow Derong Liu
2021-09-06 17:09 ` Ulf Hansson
2021-09-06 17:09   ` Ulf Hansson
2021-09-06 17:09   ` Ulf Hansson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.