aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeniy Didin <Evgeniy.Didin@synopsys.com>2018-03-14 15:30:51 -0400
committerUlf Hansson <ulf.hansson@linaro.org>2018-03-16 03:38:54 -0400
commit47b7de2f6c18f75d1f2716efe752cba43f32a626 (patch)
treec4fab703f558a4aeaed5a7dffe62dfcbb6b6ef61
parentc658dc58c7eaa8569ceb0edd1ddbdfda84fe8aa5 (diff)
mmc: dw_mmc: fix falling from idmac to PIO mode when dw_mci_reset occurs
It was found that in IDMAC mode after soft-reset driver switches to PIO mode. That's what happens in case of DTO timeout overflow calculation failure: 1. soft-reset is called 2. driver restarts dma 3. descriptors states are checked, one of descriptor is owned by the IDMAC. 4. driver can't use DMA and then switches to PIO mode. Failure was already fixed in: https://www.spinics.net/lists/linux-mmc/msg48125.html. Behaviour while soft-reset is not something we except or even want to happen. So we switch from dw_mci_idmac_reset to dw_mci_idmac_init, so descriptors are cleaned before starting dma. And while at it explicitly zero des0 which otherwise might contain garbage as being allocated by dmam_alloc_coherent(). Signed-off-by: Evgeniy Didin <Evgeniy.Didin@synopsys.com> Cc: Jaehoon Chung <jh80.chung@samsung.com> Cc: Ulf Hansson <ulf.hansson@linaro.org> Cc: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Jisheng Zhang <Jisheng.Zhang@synaptics.com> Cc: Shawn Lin <shawn.lin@rock-chips.com> Cc: Alexey Brodkin <abrodkin@synopsys.com> Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> Cc: linux-snps-arc@lists.infradead.org Cc: <stable@vger.kernel.org> # 4.4+ Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/host/dw_mmc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 545550591389..06d47414d0c1 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -564,6 +564,7 @@ static int dw_mci_idmac_init(struct dw_mci *host)
564 (sizeof(struct idmac_desc_64addr) * 564 (sizeof(struct idmac_desc_64addr) *
565 (i + 1))) >> 32; 565 (i + 1))) >> 32;
566 /* Initialize reserved and buffer size fields to "0" */ 566 /* Initialize reserved and buffer size fields to "0" */
567 p->des0 = 0;
567 p->des1 = 0; 568 p->des1 = 0;
568 p->des2 = 0; 569 p->des2 = 0;
569 p->des3 = 0; 570 p->des3 = 0;
@@ -586,6 +587,7 @@ static int dw_mci_idmac_init(struct dw_mci *host)
586 i++, p++) { 587 i++, p++) {
587 p->des3 = cpu_to_le32(host->sg_dma + 588 p->des3 = cpu_to_le32(host->sg_dma +
588 (sizeof(struct idmac_desc) * (i + 1))); 589 (sizeof(struct idmac_desc) * (i + 1)));
590 p->des0 = 0;
589 p->des1 = 0; 591 p->des1 = 0;
590 } 592 }
591 593
@@ -1801,8 +1803,8 @@ static bool dw_mci_reset(struct dw_mci *host)
1801 } 1803 }
1802 1804
1803 if (host->use_dma == TRANS_MODE_IDMAC) 1805 if (host->use_dma == TRANS_MODE_IDMAC)
1804 /* It is also recommended that we reset and reprogram idmac */ 1806 /* It is also required that we reinit idmac */
1805 dw_mci_idmac_reset(host); 1807 dw_mci_idmac_init(host);
1806 1808
1807 ret = true; 1809 ret = true;
1808 1810