From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B3DDC00454 for ; Mon, 9 Dec 2019 22:26:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2B4D220637 for ; Mon, 9 Dec 2019 22:26:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726960AbfLIW0y (ORCPT ); Mon, 9 Dec 2019 17:26:54 -0500 Received: from shards.monkeyblade.net ([23.128.96.9]:36466 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726156AbfLIW0y (ORCPT ); Mon, 9 Dec 2019 17:26:54 -0500 Received: from localhost (unknown [IPv6:2601:601:9f00:1c3::3d5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 8B885154925CD; Mon, 9 Dec 2019 14:26:53 -0800 (PST) Date: Mon, 09 Dec 2019 14:26:53 -0800 (PST) Message-Id: <20191209.142653.1925547187942224188.davem@davemloft.net> To: grygorii.strashko@ti.com Cc: netdev@vger.kernel.org, ivan.khoronzhuk@linaro.org, nsekhar@ti.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: ethernet: ti: davinci_cpdma: fix warning "device driver frees DMA memory with different size" From: David Miller In-Reply-To: <20191209111924.22555-1-grygorii.strashko@ti.com> References: <20191209111924.22555-1-grygorii.strashko@ti.com> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Mon, 09 Dec 2019 14:26:53 -0800 (PST) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Grygorii Strashko Date: Mon, 9 Dec 2019 13:19:24 +0200 > 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 > --- > changes in v3: > - removed swlen local var Applied and queued up for -stable, thanks.