Skip to content

Commit 053bf34

Browse files
perforcjb
authored andcommitted
mmc: omap_hsmmc: DMA unmap only once in case of MMC error
Reported by Russell King: mmcblk0: error -84 transferring data, sector 149201, nr 64, cmd response 0x900, card status 0xb00 mmcblk0: retrying using single block read WARNING: at lib/dma-debug.c:811 check_unmap omap_hsmmc omap_hsmmc.0: DMA-API: device driver tries to free DMA memory it has not allocated [device address=0x0000000080933000] [size=20480 bytes] In case of an error dma_unmap() is issued in omap_hsmmc_dma_cleanup() and then again in omap_hsmmc_post_req(). Resolve this by clearing the host_cookie to indicate there is no DMA mapped memory to unmap. Signed-off-by: Per Forlin <per.forlin@linaro.org> Tested-by: Balaji T K <balajitk@ti.com> Tested-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Chris Ball <cjb@laptop.org>
1 parent 77a7300 commit 053bf34

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎drivers/mmc/host/omap_hsmmc.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,7 @@ static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno)
10101010
host->data->sg_len,
10111011
omap_hsmmc_get_dma_dir(host, host->data));
10121012
omap_free_dma(dma_ch);
1013+
host->data->host_cookie = 0;
10131014
}
10141015
host->data = NULL;
10151016
}
@@ -1575,8 +1576,10 @@ static void omap_hsmmc_post_req(struct mmc_host *mmc, struct mmc_request *mrq,
15751576
struct mmc_data *data = mrq->data;
15761577

15771578
if (host->use_dma) {
1578-
dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len,
1579-
omap_hsmmc_get_dma_dir(host, data));
1579+
if (data->host_cookie)
1580+
dma_unmap_sg(mmc_dev(host->mmc), data->sg,
1581+
data->sg_len,
1582+
omap_hsmmc_get_dma_dir(host, data));
15801583
data->host_cookie = 0;
15811584
}
15821585
}

0 commit comments

Comments
 (0)