From patchwork Sun Dec 29 17:21:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 182551 Delivered-To: patch@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp5458234ild; Sun, 29 Dec 2019 09:43:59 -0800 (PST) X-Google-Smtp-Source: APXvYqzMAEf9YRqQ0r3fcMgYKkxJd+Dov4pg+xz6N8otwpo0lMcrdPUHR9KoSZ4DM71s6NpNSdPB X-Received: by 2002:a9d:1c95:: with SMTP id l21mr60038415ota.271.1577641439590; Sun, 29 Dec 2019 09:43:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577641439; cv=none; d=google.com; s=arc-20160816; b=vAughpyMlE4+pRQXaZ2n8witUs8+qqQysRaHwbYKy1Y0Yt7VVkWid5X140qVKpcrJP a8vjjxM89yxlYelLIWa9aR0k8ccd5t5HonW+ZmXkCa4O28hSLc4sJIUng4pg6JkAoPBi 3qGzwrgOJJPKUx/NEbVrSyt4NAPGcj+5MzLHRmA/jhMpJyMJZMazaIeLO+d3awm3y8R8 uoDrgAiYqHYnWKLK6tOMMs9YZFtbHKMxLFmarbfeZ0zWJTr6Ay7TfF7C1zQpF8SNz6Vb MpDYFFy1PMVngOmQLl0PJw01uJ/6i5TblQu6BQTTBGJUyIgm8PaOYwlExEtO/UzhlcZ1 n7Vw== 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 t23si21855864otk.304.2019.12.29.09.43.59; Sun, 29 Dec 2019 09:43:59 -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 S1730590AbfL2Rn6 (ORCPT + 27 others); Sun, 29 Dec 2019 12:43:58 -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 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);