From patchwork Sun Aug 28 22:08:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Per Forlin X-Patchwork-Id: 1105962 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7SMCE0W020203 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 28 Aug 2011 22:12:35 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qxna7-0003c9-LL; Sun, 28 Aug 2011 22:11:55 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qxna7-0003jR-6n; Sun, 28 Aug 2011 22:11:55 +0000 Received: from mail-bw0-f49.google.com ([209.85.214.49]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qxna3-0003j6-NL for linux-arm-kernel@lists.infradead.org; Sun, 28 Aug 2011 22:11:53 +0000 Received: by bke17 with SMTP id 17so4395848bke.36 for ; Sun, 28 Aug 2011 15:11:46 -0700 (PDT) Received: by 10.204.154.90 with SMTP id n26mr1779543bkw.137.1314569506174; Sun, 28 Aug 2011 15:11:46 -0700 (PDT) Received: from localhost.localdomain (c-c37f71d5.029-82-6c756e10.cust.bredbandsbolaget.se [213.113.127.195]) by mx.google.com with ESMTPS id y7sm1034085bkq.15.2011.08.28.15.11.43 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 28 Aug 2011 15:11:44 -0700 (PDT) From: Per Forlin To: linaro-dev@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, Venkatraman S , Russell King - ARM Linux , Santosh , Balaji T Krishnamoorthy , Sourav Poddar Subject: [PATCH] mmc: omap_hsmmc: DMA unmap only once in case of MMC error Date: Mon, 29 Aug 2011 00:08:43 +0200 Message-Id: <1314569323-6886-1-git-send-email-per.forlin@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110828_181151_927520_275EE5E3 X-CRM114-Status: GOOD ( 15.39 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.214.49 listed in list.dnswl.org] Cc: Nicolas Pitre , Chris Ball , Per Forlin X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 28 Aug 2011 22:12:35 +0000 (UTC) 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 /home/rmk/git/linux-2.6-rmk/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 --- Bug fix on 3.1-rc3 drivers/mmc/host/omap_hsmmc.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 21e4a79..31d9817 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c @@ -1011,6 +1011,7 @@ static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno) host->data->sg_len, omap_hsmmc_get_dma_dir(host, host->data)); omap_free_dma(dma_ch); + host->data->host_cookie = 0; } host->data = NULL; } @@ -1576,8 +1577,10 @@ static void omap_hsmmc_post_req(struct mmc_host *mmc, struct mmc_request *mrq, struct mmc_data *data = mrq->data; if (host->use_dma) { - dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len, - omap_hsmmc_get_dma_dir(host, data)); + if (data->host_cookie) + dma_unmap_sg(mmc_dev(host->mmc), data->sg, + data->sg_len, + omap_hsmmc_get_dma_dir(host, data)); data->host_cookie = 0; } }