From cdb6836051de23555821909140d3283624bcaceb Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas Date: Sat, 18 Jul 2015 23:56:37 +0300 Subject: [PATCH] omap_hsmmc: free dma on errors without this next DMA fails and IO hangs forever --- drivers/mmc/host/omap_hsmmc.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 348f577b66cf..3c4a0e45d715 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c @@ -1039,6 +1039,19 @@ omap_hsmmc_cmd_done(struct omap_hsmmc_host *host, struct mmc_command *cmd) omap_hsmmc_request_done(host, cmd->mrq); } +static void omap_hsmmc_free_dma(struct omap_hsmmc_host *host) +{ + int dma_ch; + + dma_ch = xchg(&host->dma_ch_tx, -1); + if (dma_ch != -1) + omap_free_dma(dma_ch); + + dma_ch = xchg(&host->dma_ch_rx, -1); + if (dma_ch != -1) + omap_free_dma(dma_ch); +} + /* * DMA clean up for command errors */ @@ -1059,6 +1072,7 @@ static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno) omap_hsmmc_get_dma_dir(host, host->data)); host->data->host_cookie = 0; } + omap_hsmmc_free_dma(host); host->data = NULL; } @@ -2346,18 +2360,11 @@ static int omap_hsmmc_resume(struct device *dev) static int omap_hsmmc_runtime_suspend(struct device *dev) { struct omap_hsmmc_host *host; - int dma_ch; host = platform_get_drvdata(to_platform_device(dev)); omap_hsmmc_context_save(host); - dma_ch = xchg(&host->dma_ch_tx, -1); - if (dma_ch != -1) - omap_free_dma(dma_ch); - - dma_ch = xchg(&host->dma_ch_rx, -1); - if (dma_ch != -1) - omap_free_dma(dma_ch); + omap_hsmmc_free_dma(host); dev_dbg(mmc_dev(host->mmc), "disabled\n"); -- 2.39.2