From patchwork Mon Jun 20 08:34:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seung-Woo Kim X-Patchwork-Id: 9186861 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6D0F5601C0 for ; Mon, 20 Jun 2016 08:34:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56DA324B5E for ; Mon, 20 Jun 2016 08:34:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B2F725227; Mon, 20 Jun 2016 08:34:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEDE524B5E for ; Mon, 20 Jun 2016 08:34:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753106AbcFTIew (ORCPT ); Mon, 20 Jun 2016 04:34:52 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:59875 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753104AbcFTIeu (ORCPT ); Mon, 20 Jun 2016 04:34:50 -0400 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O9200RJAAI05Z90@mailout3.samsung.com>; Mon, 20 Jun 2016 17:34:48 +0900 (KST) Received: from epcpsbgm1new.samsung.com ( [172.20.52.113]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 57.0B.05160.8AAA7675; Mon, 20 Jun 2016 17:34:48 +0900 (KST) X-AuditID: cbfee68e-f79266d000001428-ab-5767aaa86d46 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 59.28.02101.8AAA7675; Mon, 20 Jun 2016 17:34:48 +0900 (KST) Received: from NOSW0312KIM01 ([10.113.62.208]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O92005O0AHZD920@mmp2.samsung.com>; Mon, 20 Jun 2016 17:34:48 +0900 (KST) From: Seung-Woo Kim To: jh80.chung@samsung.com, ulf.hansson@linaro.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, sw0312.kim@samsung.com Subject: mmc: dw_mmc: warning with CONFIG_DMA_API_DEBUG Date: Mon, 20 Jun 2016 17:34:48 +0900 Message-id: <001501d1cace$9b8f2b60$d2ad8220$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AdHKzNQR/BPYt9DOQ7mHrqveW/LO7A== Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeLIzCtJLcpLzFFi42JZI2JSqLtiVXq4wexGOYsbv9pYLS7vmsNm ceR/P6PFjMkv2SyOrw13YPW4c20Pm0ffllWMHp83yQUwR3HZpKTmZJalFunbJXBlnDiwna3g tmzFqt5FLA2MKyW7GDk4JARMJFYey+1i5AQyxSQu3FvP1sXIxSEksIJRoql1HRtEwkRiwZLf TBCJWYwSXXf6GCGcD4wST7YcZgapYhPQkdi/5DcrSEJEoJVRYs+qWYwgCWEBc4nvkzYxgdgs AqoSnyZfYQexeQUsJZ73fmKEsAUlfky+xwJiMwtoSazfeZwJwpaX2LzmLTPEGQoSO86+BqsX EdCTmLy2hw2iRkRi34t3YBdJCKxil2hffxNqm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yNhcSZz38f91YUIC 6YklqdmpqQWpRTB9TBycUg2MEksNjXqEC90dF85bGDyFkeFiyPn2uQ84HsmELI+zXfP6xdn3 /gpSrm+zJnhtvnVi84HXdyxdajq2rCsUY5IRYfpWsfXUa13ZhshTF2sbprXrKxtLS/xIFX4Y kWbMPHNO0yHTeZPPytq4OhXXnUlLXdcWFM2rmxAouPe1W8EtdScbZYPz6ueVWIozEg21mIuK EwG94r3A8AIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi folks, During booting test on my Exynos5422 based Odroid-XU3, kernel compiled with CONFIG_DMA_API_DEBUG reported following warning: ------------[ cut here ]------------ WARNING: CPU: 0 PID: 0 at lib/dma-debug.c:1096 check_unmap+0x7bc/0xb38 dwmmc_exynos 12200000.mmc: DMA-API: device driver tries to free DMA memory it has not allocated [device address=0x000000006d9d2200] [size=128 bytes] Modules linked in: CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.7.0-rc4 #26 Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) [] (unwind_backtrace) from [] (show_stack+0x20/0x24) [] (show_stack) from [] (dump_stack+0x80/0x94) [] (dump_stack) from [] (__warn+0xf8/0x110) [] (__warn) from [] (warn_slowpath_fmt+0x48/0x50) [] (warn_slowpath_fmt) from [] (check_unmap+0x7bc/0xb38) [] (check_unmap) from [] (debug_dma_unmap_sg+0x118/0x148) [] (debug_dma_unmap_sg) from [] (dw_mci_dma_cleanup+0x7c/0xb8) [] (dw_mci_dma_cleanup) from [] (dw_mci_stop_dma+0x40/0x50) [] (dw_mci_stop_dma) from [] (dw_mci_tasklet_func+0x130/0x3b4) [] (dw_mci_tasklet_func) from [] (tasklet_action+0xb4/0x150) [] (tasklet_action) from [] (__do_softirq+0xe4/0x3cc) [] (__do_softirq) from [] (irq_exit+0xd0/0x10c) [] (irq_exit) from [] (__handle_domain_irq+0x90/0xfc) [] (__handle_domain_irq) from [] (gic_handle_irq+0x64/0xa8) [] (gic_handle_irq) from [] (__irq_svc+0x54/0x90) Exception stack(0xc1101ef8 to 0xc1101f40) 1ee0: 00000001 00000000 1f00: 00000000 c011b600 c1100000 c110753c 00000000 c11c3984 c11074d4 c1107548 1f20: 00000000 c1101f54 c1101f58 c1101f48 c010a1fc c010a200 60000013 ffffffff [] (__irq_svc) from [] (arch_cpu_idle+0x48/0x4c) [] (arch_cpu_idle) from [] (default_idle_call+0x30/0x3c) [] (default_idle_call) from [] (cpu_startup_entry+0x358/0x3b4) [] (cpu_startup_entry) from [] (rest_init+0x94/0x98) [] (rest_init) from [] (start_kernel+0x3a4/0x3b0) [] (start_kernel) from [<4000807c>] (0x4000807c) ---[ end trace 256f83eed365daf0 ]--- The warning occurs because after complete callback function, dw_mci_dmac_complete_dma() is called, then dw_mci_stop_dma() is called again. So it causes dma_unmap_sg() is called twice for same sg. It occurs during clock setting at booting time. Simply, clearing host->using_dma flag on dw_mci_dmac_complete_dma() and dw_mci_stop_dma() like following fixes the issue, but I am not sure this approach is proper. --- --- Best Regards, - Seung-Woo Kim -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 2cc6123..a71c94b 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -388,6 +388,7 @@ static void dw_mci_stop_dma(struct dw_mci *host) if (host->using_dma) { host->dma_ops->stop(host); host->dma_ops->cleanup(host); + host->using_dma = 0; } /* Data transfer was stopped by the interrupt handler */ @@ -455,6 +456,7 @@ static void dw_mci_dmac_complete_dma(void *arg) DMA_FROM_DEVICE); host->dma_ops->cleanup(host); + host->using_dma = 0; /* * If the card was removed, data will be NULL. No point in trying to @@ -943,8 +945,6 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data) int sg_len; u32 temp; - host->using_dma = 0; - /* If we don't have a channel, we can't do DMA */ if (!host->use_dma) return -ENODEV;