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: 3748 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id B641123E52 for ; Sun, 28 Aug 2011 22:11:49 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 9F2A8A181E9 for ; Sun, 28 Aug 2011 22:11:49 +0000 (UTC) Received: by fxd18 with SMTP id 18so5858125fxd.11 for ; Sun, 28 Aug 2011 15:11:49 -0700 (PDT) Received: by 10.223.22.14 with SMTP id l14mr2278730fab.100.1314569509371; Sun, 28 Aug 2011 15:11:49 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.11.8 with SMTP id m8cs75941lab; Sun, 28 Aug 2011 15:11:49 -0700 (PDT) Received: by 10.204.151.212 with SMTP id d20mr1649880bkw.43.1314569508490; Sun, 28 Aug 2011 15:11:48 -0700 (PDT) Received: from mail-bw0-f50.google.com (mail-bw0-f50.google.com [209.85.214.50]) by mx.google.com with ESMTPS id x14si6156617bkd.14.2011.08.28.15.11.46 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 28 Aug 2011 15:11:47 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of per.forlin@linaro.org) client-ip=209.85.214.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of per.forlin@linaro.org) smtp.mail=per.forlin@linaro.org Received: by bkbzu5 with SMTP id zu5so5061318bkb.37 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 Cc: Chris Ball , Nicolas Pitre , Per Forlin 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 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; } }