Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1856352ybl; Sat, 7 Dec 2019 04:03:55 -0800 (PST) X-Google-Smtp-Source: APXvYqx7ZhJtIVUKgMVpjaqdn358qMh7sCXTivYGc5HdudTOjRqevkiIsIGMRDO6T6GX2m2j03qT X-Received: by 2002:aca:a811:: with SMTP id r17mr16794595oie.59.1575720235408; Sat, 07 Dec 2019 04:03:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575720235; cv=none; d=google.com; s=arc-20160816; b=AB095xhzjLcdqDBFnFOaChBU7zSQzCp9JKqyOjG3R27l2Rei8mZcOzDGCbo8frIY0Y NkuKMM9oiKuiPkd/gh651iR9Pnp6vsvUBb/vfwtx9v8Ehxz6UPWRPDrYEi7N1XJZ1KbP Fx7Kmy9mTIq4wmE2zpuDcYg7hKksUG0PZiXHuZk29fppXl4u3pbgv93RVmbhX2Kd5Zez 8x+GO7n0oKZn7CNl8a5ULAu7koJVQWSWiUTFjJJcrpRUumNT4F4YONog7/Qyqtk4ZpMU DGrD9GCrMcdK9LOijjfPF78mGUiveGeXcDjfwB4nlaEs5AwaD6zWTtdgLd8p1fIDCk3T 44/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:to:from:date:dkim-signature; bh=WCHftxVyszB2Wm7Mx9nwVJT5KwAoHKsTgufbG3ZvSE0=; b=n5hnxn3qXieO9awHtwjIl+4nYJTTStGsCzCeHx9dC5UDKXgcYYgF93CxvEAtpwxryb +zqleY3lGQiIhCMCHLXDQ7zcL9sEgIWT+EkhhYNBpHDLn9H5Pu+kE9pIh7X/xMNXDP6W OOnqNkoOleszoBkjn3cWLvOhKYCvBuCvPYU3rpt/QRC5YNzAI+Vd6vOHOqx5TF2w/d/U h9JPrnuWqZcje3vOZlgeVjONe/pqmkbFkSiIjrTknEBWmTUA1LYjKDjBjCaC2sB8ssgP feU+EvvZ6NW08RpqG5zOe/wAimJUY4iTjU04qZhNjgrLMkJ7Uazx5X5Pfr6UgyyQjL+d H1ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ytbBU3WG; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j6si9116793oie.222.2019.12.07.04.03.31; Sat, 07 Dec 2019 04:03:55 -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=@linaro.org header.s=google header.b=ytbBU3WG; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726418AbfLGMCp (ORCPT + 99 others); Sat, 7 Dec 2019 07:02:45 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:44393 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726196AbfLGMCp (ORCPT ); Sat, 7 Dec 2019 07:02:45 -0500 Received: by mail-lf1-f66.google.com with SMTP id v201so7243021lfa.11 for ; Sat, 07 Dec 2019 04:02:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=WCHftxVyszB2Wm7Mx9nwVJT5KwAoHKsTgufbG3ZvSE0=; b=ytbBU3WGJ0ZQjaUeGfDOGl3u4A5i8tgrxA0IewP25ocFnCwA1+3oTAyMV69GqIGkXL NGotBHGibozbI7wv7KFb5d9JbZux3LyufzbW1NznboOPwhfW7JdKsPCsvOURwBmZHK5h cV1xLr8ML2hyWZ4bsH8RrKbCOUaTWijO3wL+MJHl8bXJx35eFwBAC4uMgLcvVwz/TwkH WIhaRgR5+9aXLw3VJ1XU5hzQbE8F3/mwTTVkTFB+0EdX7PAp8BlG/47YvSLdEg7WS8TU EpLGTMe03jOVW9kRiKaFsGWNfu4UR5aoauIt1FIrN4d+U24nlQRb4G5+LFkvlcT/sqi7 KXrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=WCHftxVyszB2Wm7Mx9nwVJT5KwAoHKsTgufbG3ZvSE0=; b=lMoI1//7QxceV3bcKNGfLaon8OYV8z44UoF6W8Dxkxvobs7QZiahGxMG1adqwtoFb+ K6zkc3qA63mvNQI5MYQZQ0CgvLreBBehREuYqAl7M+RauLh3Z/RfN6FpE8xGHtAK54Ox TYyI7GNicAbfXLqM3H/xq9Z4P4VRfFdwOYbChGWE42sPctKkuGasHGZrfFx2nUZEqADA CALDGvc5xeoNAvfEm1qvSZiyZAVPN9cRZPXX8VDqInCnXz0jQ+alxS4x5lySBb3b4n1J 1Ana1nrQ6c94sbqHlHOSjQkDFxpMr1W49RmCBIdmldKEPpZRxKmzwrJi1xIRy3HzgD9p zsSg== X-Gm-Message-State: APjAAAXXwt3L2CTfrrm/1g6GCJxvM1TX9fX3lLrYcBLOAILbuPzkqygy Rc3m/0Bb2/Ce9tz5GiRlUZXTAw== X-Received: by 2002:ac2:4c2b:: with SMTP id u11mr10809676lfq.46.1575720162331; Sat, 07 Dec 2019 04:02:42 -0800 (PST) Received: from khorivan (57-201-94-178.pool.ukrtel.net. [178.94.201.57]) by smtp.gmail.com with ESMTPSA id p12sm2553575lfc.43.2019.12.07.04.02.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Dec 2019 04:02:41 -0800 (PST) Date: Sat, 7 Dec 2019 14:02:39 +0200 From: Ivan Khoronzhuk To: Grygorii Strashko , David Miller , netdev@vger.kernel.org, nsekhar@ti.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] net: ethernet: ti: davinci_cpdma: fix warning "device driver frees DMA memory with different size" Message-ID: <20191207120238.GB2798@khorivan> Mail-Followup-To: Grygorii Strashko , David Miller , netdev@vger.kernel.org, nsekhar@ti.com, linux-kernel@vger.kernel.org References: <20191204165029.9264-1-grygorii.strashko@ti.com> <20191204.123718.1152659362924451799.davem@davemloft.net> <0c6b88b2-31b1-11f0-7baa-1ecd5f4b6644@ti.com> <20191207114419.GA2798@khorivan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20191207114419.GA2798@khorivan> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Dec 07, 2019 at 01:44:20PM +0200, Ivan Khoronzhuk wrote: >On Thu, Dec 05, 2019 at 12:48:46PM +0200, Grygorii Strashko wrote: >> >> >>On 04/12/2019 22:37, David Miller wrote: >>>From: Grygorii Strashko >>>Date: Wed, 4 Dec 2019 18:50:29 +0200 >>> >>>>@@ -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 >>>> >>> >>>Now there is no reason to keep a separate swlen variable. >>> >>>The integral value is always consumed as the length before the descriptor bits >>>are added to it. >>> >>>Therefore you can just use 'len' everywhere in this function now. >>> >> >>Sry, but seems i can't, at least i can't just drop swlen. >> >>Below in this function: >> writel_relaxed(0, &desc->hw_next); >> writel_relaxed(buffer, &desc->hw_buffer); >> writel_relaxed(len, &desc->hw_len); >> writel_relaxed(mode | len, &desc->hw_mode); >>^^ here the "len" should be use >> >> writel_relaxed((uintptr_t)si->token, &desc->sw_token); >> writel_relaxed(buffer, &desc->sw_buffer); >> writel_relaxed(swlen, &desc->sw_len); >>^^ and here "len"|CPDMA_DMA_EXT_MAP if (si->data_dma) [1] >> >> desc_read(desc, sw_len); >> >>so additional if statement has to be added at [1] if "swlen" is dropped >> >>-- >>Best regards, >>grygorii > >Seems like yes, > >And the "swlen" can be avoided like this: > >--- 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 submit_info *si) > 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,7 @@ static int cpdma_chan_submit_si(struct submit_info *si) > if (si->data_dma) { > buffer = si->data_dma; > dma_sync_single_for_device(ctlr->dev, buffer, len, chan->dir); >- swlen |= CPDMA_DMA_EXT_MAP; >+ writel_relaxed(len | CPDMA_DMA_EXT_MAP, &desc->sw_len); > } else { > buffer = dma_map_single(ctlr->dev, si->data_virt, len, chan->dir); > ret = dma_mapping_error(ctlr->dev, buffer); >@@ -1054,6 +1053,7 @@ static int cpdma_chan_submit_si(struct submit_info *si) > cpdma_desc_free(ctlr->pool, desc, 1); > return -EINVAL; > } >+ writel_relaxed(len, &desc->sw_len); > } > > /* Relaxed IO accessors can be used here as there is read barrier >@@ -1065,7 +1065,6 @@ static int cpdma_chan_submit_si(struct submit_info *si) > 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); > desc_read(desc, sw_len); > > __cpdma_chan_submit(chan, desc); > >But not sure what is better. > Or like this: --- 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 submit_info *si) 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 submit_info *si) 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,7 @@ static int cpdma_chan_submit_si(struct submit_info *si) 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); But it's branched twice then. -- Regards, Ivan Khoronzhuk