From patchwork Tue Jun 21 01:52:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 9189157 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 BECD96075F for ; Tue, 21 Jun 2016 01:52:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1FB827E66 for ; Tue, 21 Jun 2016 01:52:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 961FE27F60; Tue, 21 Jun 2016 01:52:31 +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 1294827E66 for ; Tue, 21 Jun 2016 01:52:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751628AbcFUBw3 (ORCPT ); Mon, 20 Jun 2016 21:52:29 -0400 Received: from lucky1.263xmail.com ([211.157.147.134]:53523 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751235AbcFUBw2 (ORCPT ); Mon, 20 Jun 2016 21:52:28 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.12]) by lucky1.263xmail.com (Postfix) with SMTP id 5824D725; Tue, 21 Jun 2016 09:52:24 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 Received: from [172.16.12.144] (localhost.localdomain [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 1845B2DA7; Tue, 21 Jun 2016 09:52:22 +0800 (CST) X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: shawn.lin@rock-chips.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <7084d2da668cfb9a5f63107e6f4d04b1> X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from [172.16.12.144] (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 114863O75P8; Tue, 21 Jun 2016 09:52:22 +0800 (CST) Subject: Re: mmc: dw_mmc: warning with CONFIG_DMA_API_DEBUG To: Seung-Woo Kim , jh80.chung@samsung.com, ulf.hansson@linaro.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org References: <001501d1cace$9b8f2b60$d2ad8220$@samsung.com> Cc: shawn.lin@rock-chips.com From: Shawn Lin Message-ID: Date: Tue, 21 Jun 2016 09:52:17 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <001501d1cace$9b8f2b60$d2ad8220$@samsung.com> 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 On 2016/6/20 16:34, Seung-Woo Kim wrote: > 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] Thanks for this report and fix. DTO(the same as IDMAC-RI/TI) interrupts may or may not come together with DATA_ERR. If DATA_ERR occur without geting DTO, we should issue CMD12 manually to generate DTO. It's a ugly deisgn for dwmmc but from the vendor's ask. So you should never think we complete the xfer without checking DATA_ERR. This way you got the warning. So could you try this one: } } else { pending = mci_readl(host, IDSTS); @@ -2482,7 +2483,8 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id) mci_writel(host, IDSTS, SDMMC_IDMAC_INT_TI | SDMMC_IDMAC_INT_RI); mci_writel(host, IDSTS, SDMMC_IDMAC_INT_NI); - host->dma_ops->complete((void *)host); + if (!test_bit(EVENT_DATA_ERROR, &host->pending_events)) + host->dma_ops->complete((void *)host); } } > [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. > --- > 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; > --- > > 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 > --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -2474,7 +2474,8 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id) mci_writel(host, IDSTS64, SDMMC_IDMAC_INT_TI | SDMMC_IDMAC_INT_RI); mci_writel(host, IDSTS64, SDMMC_IDMAC_INT_NI); - host->dma_ops->complete((void *)host); + if (!test_bit(EVENT_DATA_ERROR, &host->pending_events)) + host->dma_ops->complete((void *)host);