Skip to content

Commit

Permalink
mmc: dw_mmc: fix falling from idmac to PIO mode when dw_mci_reset occurs
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Jaehoon Chung <[email protected]>
Cc: Ulf Hansson <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: Jisheng Zhang <[email protected]>
Cc: Shawn Lin <[email protected]>
Cc: Alexey Brodkin <[email protected]>
Cc: Eugeniy Paltsev <[email protected]>
Cc: [email protected]
Cc: <[email protected]> # 4.4+
Signed-off-by: Ulf Hansson <[email protected]>
  • Loading branch information
EvgeniiDidin authored and storulf committed Mar 16, 2018
1 parent c658dc5 commit 47b7de2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/mmc/host/dw_mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ static int dw_mci_idmac_init(struct dw_mci *host)
(sizeof(struct idmac_desc_64addr) *
(i + 1))) >> 32;
/* Initialize reserved and buffer size fields to "0" */
p->des0 = 0;
p->des1 = 0;
p->des2 = 0;
p->des3 = 0;
Expand All @@ -586,6 +587,7 @@ static int dw_mci_idmac_init(struct dw_mci *host)
i++, p++) {
p->des3 = cpu_to_le32(host->sg_dma +
(sizeof(struct idmac_desc) * (i + 1)));
p->des0 = 0;
p->des1 = 0;
}

Expand Down Expand Up @@ -1801,8 +1803,8 @@ static bool dw_mci_reset(struct dw_mci *host)
}

if (host->use_dma == TRANS_MODE_IDMAC)
/* It is also recommended that we reset and reprogram idmac */
dw_mci_idmac_reset(host);
/* It is also required that we reinit idmac */
dw_mci_idmac_init(host);

ret = true;

Expand Down

0 comments on commit 47b7de2

Please sign in to comment.