Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp705219ybl; Wed, 4 Dec 2019 09:31:33 -0800 (PST) X-Google-Smtp-Source: APXvYqxottIpOvc4X0rHpLMDFWhrcn1Rd7G8Gq+3SNkT18A2v4ONaoGlOQR3oTF/GQnd2h5uXZs9 X-Received: by 2002:aca:bd42:: with SMTP id n63mr3649244oif.70.1575480692904; Wed, 04 Dec 2019 09:31:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575480692; cv=none; d=google.com; s=arc-20160816; b=roSVkxnB9jvKs30MlE9Gx9gTBj9l0VrsUoyM7xJk7XHZdQtTAwL3XivAlRTz/9RW96 uNz/RkWvTh050dKvIZU0+b1mSjDkcg23DjXornkrIbIiLqVU2xSpDOdc+94Z5Cu8bPgp Z4MlZxWkzE5zBg3/oEbnwrrG7ltA22F0yqWHhFsbS1raZqRDxzecHbuyA5BrJ+STFz5z dRbRyAsS4mU57Xsk6/TFybYBpZ1lnBmXC6aaXKN3Iu/WD3j0aHb4s+F5MOCcODcaD3ht tLabJyTM2wWFOw3Xv6Lgm8rPRZ8KNUI4kI2KaZrdpIo3rvo/6IWEjn8UtdgXrL2F+Eb/ /FvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=Fsq/sOp9KxxrreLSU1uAKOD6Ws/kWQRUU7rs0e7O1Bo=; b=KItJgliqo28Teo1Dy/jKET8V164spxJfSCWsOtdQ8XIWBFNpCXiA+lMOwPWEKfzBAd rMSaWS9AyHuHi3KI9VGSD1vi5E6/m51uACge21p19NSFZu4nIf+SZ7lEnjRROqbgtxd1 YGK/CcISeugyfz7Ne+5huArVVqPEbgnKVYPElVfXElVBAV+P3AKI+cBioRFYkJ5OQST1 PEFkqxFU6YIp8vB0gQ68ObyyShJCfzx6Oe2VWwIo5ooki+TswYMe6zMXr+jo018EYaCf YuSYrnnqD4i9ZS0NGT53epGogyF+r5jw0AR4ZVAaKDTO2YpbY9pIjGoaMTqoKQa9JOuq 59Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Vrj2vo2W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a10si3476346oid.244.2019.12.04.09.31.20; Wed, 04 Dec 2019 09:31:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Vrj2vo2W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728924AbfLDQug (ORCPT + 99 others); Wed, 4 Dec 2019 11:50:36 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:45716 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726934AbfLDQug (ORCPT ); Wed, 4 Dec 2019 11:50:36 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id xB4GoWR6091288; Wed, 4 Dec 2019 10:50:32 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1575478232; bh=Fsq/sOp9KxxrreLSU1uAKOD6Ws/kWQRUU7rs0e7O1Bo=; h=From:To:CC:Subject:Date; b=Vrj2vo2Wt5iBs7dHFyOKFXF945VyQsaQIbLcJq/GHeEgC+RhsoC5NtspRH0zPNfZr 9zhpTathXj2IHuY+KvFjHMiB8tv3klK5JOLDxXin8j6kjdUIhIOwDt9uSKVyOxXKsN 2LsxfeWzftkirh/mvaokktXA5bBVCAY1G+CTqDB4= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id xB4GoWDC036211; Wed, 4 Dec 2019 10:50:32 -0600 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Wed, 4 Dec 2019 10:50:32 -0600 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Wed, 4 Dec 2019 10:50:32 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id xB4GoV8Q046172; Wed, 4 Dec 2019 10:50:32 -0600 From: Grygorii Strashko To: "David S. Miller" , , Ivan Khoronzhuk CC: Sekhar Nori , , Grygorii Strashko Subject: [PATCH v2] net: ethernet: ti: davinci_cpdma: fix warning "device driver frees DMA memory with different size" Date: Wed, 4 Dec 2019 18:50:29 +0200 Message-ID: <20191204165029.9264-1-grygorii.strashko@ti.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The TI CPSW(s) driver produces warning with DMA API debug options enabled: WARNING: CPU: 0 PID: 1033 at kernel/dma/debug.c:1025 check_unmap+0x4a8/0x968 DMA-API: cpsw 48484000.ethernet: device driver frees DMA memory with different size [device address=0x00000000abc6aa02] [map size=64 bytes] [unmap size=42 bytes] CPU: 0 PID: 1033 Comm: ping Not tainted 5.3.0-dirty #41 Hardware name: Generic DRA72X (Flattened Device Tree) [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (dump_stack+0xd8/0x110) [] (dump_stack) from [] (__warn+0xe0/0x10c) [] (__warn) from [] (warn_slowpath_fmt+0x44/0x6c) [] (warn_slowpath_fmt) from [] (check_unmap+0x4a8/0x968) [] (check_unmap) from [] (debug_dma_unmap_page+0x80/0x90) [] (debug_dma_unmap_page) from [] (__cpdma_chan_free+0x114/0x16c) [] (__cpdma_chan_free) from [] (__cpdma_chan_process+0x158/0x17c) [] (__cpdma_chan_process) from [] (cpdma_chan_process+0x3c/0x5c) [] (cpdma_chan_process) from [] (cpsw_tx_mq_poll+0x48/0x94) [] (cpsw_tx_mq_poll) from [] (net_rx_action+0x108/0x4e4) [] (net_rx_action) from [] (__do_softirq+0xec/0x598) [] (__do_softirq) from [] (do_softirq.part.4+0x68/0x74) [] (do_softirq.part.4) from [] (__local_bh_enable_ip+0x124/0x17c) [] (__local_bh_enable_ip) from [] (ip_finish_output2+0x294/0xb7c) [] (ip_finish_output2) from [] (ip_output+0x210/0x364) [] (ip_output) from [] (ip_send_skb+0x1c/0xf8) [] (ip_send_skb) from [] (raw_sendmsg+0x9a8/0xc74) [] (raw_sendmsg) from [] (sock_sendmsg+0x14/0x24) [] (sock_sendmsg) from [] (__sys_sendto+0xbc/0x100) [] (__sys_sendto) from [] (__sys_trace_return+0x0/0x14) Exception stack(0xea9a7fa8 to 0xea9a7ff0) ... The reason is that cpdma_chan_submit_si() now stores original buffer length (sw_len) in CPDMA descriptor instead of adjusted buffer length (hw_len) used to map the buffer. Hence, fix an issue by passing correct buffer length in CPDMA descriptor. Cc: Ivan Khoronzhuk Fixes: 6670acacd59e ("net: ethernet: ti: davinci_cpdma: add dma mapped submit") Signed-off-by: Grygorii Strashko --- drivers/net/ethernet/ti/davinci_cpdma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c index 37ba708ac781..f30a9b9c78a7 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c @@ -1018,7 +1018,7 @@ static int cpdma_chan_submit_si(struct submit_info *si) struct cpdma_chan *chan = si->chan; struct cpdma_ctlr *ctlr = chan->ctlr; int len = si->len; - int swlen = len; + int swlen; struct cpdma_desc __iomem *desc; dma_addr_t buffer; u32 mode; @@ -1040,6 +1040,7 @@ static int cpdma_chan_submit_si(struct submit_info *si) chan->stats.runt_transmit_buff++; } + swlen = len; mode = CPDMA_DESC_OWNER | CPDMA_DESC_SOP | CPDMA_DESC_EOP; cpdma_desc_to_port(chan, mode, si->directed); -- 2.17.1