Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13472680ybl; Sun, 29 Dec 2019 12:44:25 -0800 (PST) X-Google-Smtp-Source: APXvYqxp/eq1tFrErgxqDmMMBqmq4Hih12kma6hjVF74sM2h2jn9xxLMYcKvedJpWStOBmaxTxLk X-Received: by 2002:a9d:2965:: with SMTP id d92mr66156985otb.175.1577652265232; Sun, 29 Dec 2019 12:44:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577652265; cv=none; d=google.com; s=arc-20160816; b=FQBluZolIYC2SdbWvsRA4yF/swVvz+F64exU2OhXV8+6gTCVo5PlnEhaUOa3/nIcvM v2iC2MDK1qqqQpI4JhjhBuo9BPSAntYGvPqONjwK7FR8VKx9Pwej8xQdsDcfPx+JjFvU l122/Vfv4ge1yLUf4/Z2wrOwBn+3gmV3ztGOM1Z5Sw7h5Fp6WPDmDyHHnxqwoteTy7Zz Ff090gQSinpIVc3YhEksAHIcfWHF7lwG9DTy0CNRcgx9aDKeI50+Dbkgb1L5ZfpAqWmU utXt6YEHcKt2pUrZgR7+Xau3dzzS8YWx6R/oqUY7BW8IdN+/vTuqpdSBU0ZCYrvz1bFh GCkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Et9CsXdzHMeCT7mCFMz6/rTs0areHsCxvptJUH7rYRA=; b=WEDhmYjYmgvw6sRvAm84acszowJ+ObXgG0RcnJRTV+XetJD9RIyl4FRPYET5d4RI2N 2Z29qwKWMC8HRee9zNcRHJEHqtrLBCqvQdhiRaSkqmns5jYrJWQeh21B2dFVVRNjqodl KZL9Bt1Rl8J/IDl0XZdurAGts8mM5uWvypwNt9m3ld+prI0wulKwbeR1NdCDZf5x4kz3 IPAat7VrWXH/WNDV3a2/AI59wtzugVs9gvtTwEOgP69vJdxDyWczdZENHNqjpTmiaZh4 GywfHF3uod2EnlFBqc3uuq6m8vwbcka4dhSjrPF7Za1WWKTOWZTuumiqRu/lLpYxFV0j ibPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f7lGd58J; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a9si20787067oib.59.2019.12.29.12.44.14; Sun, 29 Dec 2019 12:44:25 -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=@kernel.org header.s=default header.b=f7lGd58J; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730585AbfL2Rn5 (ORCPT + 99 others); Sun, 29 Dec 2019 12:43:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:51664 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730567AbfL2Rny (ORCPT ); Sun, 29 Dec 2019 12:43:54 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 69805206DB; Sun, 29 Dec 2019 17:43:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577641432; bh=V3+NHjsZK12w+f54PUHvuEZcTt4VLM0wwAGwxvBFGgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f7lGd58J08080jszeHhI6o0EFVICyNvkLaMqWmnYnvKD8tEJwzMZeXeFd9a+bf82U d2gI8J/0KmoDuGdLwu5V0PvDW+qanP5Q7SufS23d+SwjFOESnpfbB7vk+RCs/MWLlr t47jCUMWsTCrcL32gQmjtGDEsgERp08l6kMNjoJ8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ivan Khoronzhuk , Grygorii Strashko , "David S. Miller" Subject: [PATCH 5.4 024/434] net: ethernet: ti: davinci_cpdma: fix warning "device driver frees DMA memory with different size" Date: Sun, 29 Dec 2019 18:21:17 +0100 Message-Id: <20191229172703.713659060@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229172702.393141737@linuxfoundation.org> References: <20191229172702.393141737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Grygorii Strashko [ Upstream commit 8a2b22203f8596729c54eba221b4044351bfe167 ] 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 Reviewed-by: Ivan Khoronzhuk Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/ti/davinci_cpdma.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c @@ -1018,7 +1018,6 @@ static int cpdma_chan_submit_si(struct s struct cpdma_chan *chan = si->chan; struct cpdma_ctlr *ctlr = chan->ctlr; int len = si->len; - int swlen = len; struct cpdma_desc __iomem *desc; dma_addr_t buffer; u32 mode; @@ -1046,7 +1045,6 @@ static int cpdma_chan_submit_si(struct s if (si->data_dma) { buffer = si->data_dma; dma_sync_single_for_device(ctlr->dev, buffer, len, chan->dir); - swlen |= CPDMA_DMA_EXT_MAP; } else { buffer = dma_map_single(ctlr->dev, si->data_virt, len, chan->dir); ret = dma_mapping_error(ctlr->dev, buffer); @@ -1065,7 +1063,8 @@ static int cpdma_chan_submit_si(struct s writel_relaxed(mode | len, &desc->hw_mode); writel_relaxed((uintptr_t)si->token, &desc->sw_token); writel_relaxed(buffer, &desc->sw_buffer); - writel_relaxed(swlen, &desc->sw_len); + writel_relaxed(si->data_dma ? len | CPDMA_DMA_EXT_MAP : len, + &desc->sw_len); desc_read(desc, sw_len); __cpdma_chan_submit(chan, desc);