From a433ed2a53830824fbb34ef70bbca8994e0e7d11 Mon Sep 17 00:00:00 2001 From: Shawn Lin Date: Wed, 12 Aug 2015 16:25:27 +0800 Subject: [PATCH] mmc: rk_sdmmc: fix SW-IOMMU memory leak We could quickly reproduce this bug by decrease IO_TLB_DEFAULT_SIZE and manually disable mmc DTO interrupt which can make driver fall into post_tmo all the time. So, some of these dump for swiotlb we can get here due to no enough IO_TLB can be used to map page for kernel space: DMA: Out of SW-IOMMU space for 128 bytes at device ff0f0000.rksdmmc DMA: Out of SW-IOMMU space for 128 bytes at device ff0f0000.rksdmmc ... DMA: Out of SW-IOMMU space for 128 bytes at device ff0f0000.rksdmmc DMA: Out of SW-IOMMU space for 128 bytes at device ff0f0000.rksdmmc Signed-off-by: Shawn Lin Reported-and-tested-by: Jianhong Chen Cc: Yao Xiao --- drivers/mmc/host/rk_sdmmc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/rk_sdmmc.c b/drivers/mmc/host/rk_sdmmc.c index 870c94cc1ec1..7c2b6fe855fe 100755 --- a/drivers/mmc/host/rk_sdmmc.c +++ b/drivers/mmc/host/rk_sdmmc.c @@ -1969,20 +1969,21 @@ static void dw_mci_post_tmo(struct mmc_host *mmc) { struct dw_mci_slot *slot = mmc_priv(mmc); struct dw_mci *host = slot->host; - struct mmc_data *data; u32 i, regs, cmd_flags; u32 sdio_int; unsigned long timeout = 0; bool ret_timeout = true, is_retry = false; u32 opcode, offset; + if (host->cur_slot->mrq->data) + dw_mci_stop_dma(host); + offset = host->cru_reset_offset; opcode = host->mrq->cmd->opcode; host->cur_slot->mrq = NULL; host->mrq = NULL; host->state = STATE_IDLE; - - data = host->data; + host->data = NULL; if ((opcode == MMC_SEND_TUNING_BLOCK_HS200) || (opcode == MMC_SEND_TUNING_BLOCK)) -- 2.34.1