Skip to content

Commit 03e8cb5

Browse files
James Hogancjb
authored andcommitted
mmc: dw_mmc: fix stop when fallen back to PIO
There are several situations when dw_mci_submit_data_dma() decides to fall back to PIO mode instead of using DMA, due to a short (to avoid overhead) or "complex" (e.g. with unaligned buffers) transaction, even though host->use_dma is set. However dw_mci_stop_dma() decides whether to stop DMA or set the EVENT_XFER_COMPLETE event based on host->use_dma. When falling back to PIO mode this results in data timeout errors getting missed and the driver locking up. Therefore add host->using_dma to indicate whether the current transaction is using dma or not, and adjust dw_mci_stop_dma() to use that instead. Signed-off-by: James Hogan <james.hogan@imgtec.com> Acked-by: Will Newton <will.newton@imgtec.com> Tested-by: Jaehoon Chung <jh80.chung@samsung.com> Signed-off-by: Chris Ball <cjb@laptop.org>
1 parent 65d1351 commit 03e8cb5

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎drivers/mmc/host/dw_mmc.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ static void send_stop_cmd(struct dw_mci *host, struct mmc_data *data)
287287
/* DMA interface functions */
288288
static void dw_mci_stop_dma(struct dw_mci *host)
289289
{
290-
if (host->use_dma) {
290+
if (host->using_dma) {
291291
host->dma_ops->stop(host);
292292
host->dma_ops->cleanup(host);
293293
} else {
@@ -435,6 +435,8 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data)
435435
unsigned int i, direction, sg_len;
436436
u32 temp;
437437

438+
host->using_dma = 0;
439+
438440
/* If we don't have a channel, we can't do DMA */
439441
if (!host->use_dma)
440442
return -ENODEV;
@@ -454,6 +456,8 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data)
454456
return -EINVAL;
455457
}
456458

459+
host->using_dma = 1;
460+
457461
if (data->flags & MMC_DATA_READ)
458462
direction = DMA_FROM_DEVICE;
459463
else

‎include/linux/mmc/dw_mmc.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ struct mmc_data;
4848
* @data: The data currently being transferred, or NULL if no data
4949
* transfer is in progress.
5050
* @use_dma: Whether DMA channel is initialized or not.
51+
* @using_dma: Whether DMA is in use for the current transfer.
5152
* @sg_dma: Bus address of DMA buffer.
5253
* @sg_cpu: Virtual address of DMA buffer.
5354
* @dma_ops: Pointer to platform-specific DMA callbacks.
@@ -121,6 +122,7 @@ struct dw_mci {
121122

122123
/* DMA interface members*/
123124
int use_dma;
125+
int using_dma;
124126

125127
dma_addr_t sg_dma;
126128
void *sg_cpu;

0 commit comments

Comments
 (0)