Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1841834ybl; Sat, 7 Dec 2019 03:45:08 -0800 (PST) X-Google-Smtp-Source: APXvYqzuuDxVViMQKi+oSxAQKtbDZru2WPOIR+5GUXHY+1/woUmgPBz6+nFdwTwNJP5u2jVuk2OD X-Received: by 2002:aca:50cd:: with SMTP id e196mr16836554oib.178.1575719107988; Sat, 07 Dec 2019 03:45:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575719107; cv=none; d=google.com; s=arc-20160816; b=0cIgq4fTToVWL93HAn9ByggUP9Rkq5hmvdwItuT4tqnzmmXlQwNfCdfSdE53jG3meD fIS7UWVoatkatWpL1ro9hATztmjexqQDVKLd+huTegZhotgGveL68Ru3AO43PBwshi76 Hf+ORIOl9rd08fedd+7fyYovUMcltxvzdsmsl0IvqBuLqlgGe4OH498C6A2zxDV5WVgf nrMDrmzt+CoSTnvRTWnzvmEe24gdwySbpmOPDM4inQZ7eCWtFq+rWedmb1zA30WHxN61 5AbhyFma6UMCN0PfzQFic7MI7H/tM9E+HLJDuA6hYyhqtuxC58RjBHDBuF3WhgH5ip+M RCZw== 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:cc:to:from:date:dkim-signature; bh=noLqQanQbnK+x5xF9NBNdaHzY6bHKm/YguNVSzLLRs8=; b=ZfqgWEJ0hjRKH8XknqA6SkzXOOGu0sZXuRfHqjhjPvoGECNeVN4u6EDL4b9qUuAmta vp0yejKu9bXBUUJDac+flWod0qQzygh1cvQq5Dvfy3XsGWiGjc5YrqhE5wiqIBNCgPww Iwj99Vh7ksLl/fGSYP2OZSs08+KmL+DId4oYC/IcNQ0tki5zMscVes5FUzacq9Ci14U0 DuvxJ3dbgYh/0J1j7094vUHnkghJ6jH1D7YHok9ivyLnDwpa4eyugFMBjgCwm9iClL8W vQbkc+hw9SSXvyEvP08oJX2+ar7ZpqLtnX3vzvw/2qUOA1iHozDXcLiVySmqh4AUYfc8 1/lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UgUf7w3P; 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 u12si4702950otq.51.2019.12.07.03.44.55; Sat, 07 Dec 2019 03:45:07 -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=UgUf7w3P; 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 S1726400AbfLGLo1 (ORCPT + 99 others); Sat, 7 Dec 2019 06:44:27 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:46310 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726106AbfLGLo0 (ORCPT ); Sat, 7 Dec 2019 06:44:26 -0500 Received: by mail-lj1-f195.google.com with SMTP id z17so10413177ljk.13 for ; Sat, 07 Dec 2019 03:44:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=noLqQanQbnK+x5xF9NBNdaHzY6bHKm/YguNVSzLLRs8=; b=UgUf7w3Px2Ofpq8vNvIc+I5YbSVu5X+2Go381iL0MdD8lIlkb0koa4Htd8fUtlS3Td 6yRp3yQwgzZRbaBg5A2zdDgmj8EO53X0lpaFbU+fdI6P0zKMFtVgiKTTGh89GOxwSKJz KGiz77uCnQamHdgxr8SNbtPaBr0VcPdkFsfKYv2BM84nA+coKjOq/9rRDyNISWw08fIT pz3AaMcx8noVyKPyhcvnoM9nKUqxmL7SbCwoo39A/IjIAYCows+Mzei71e63FTtDnh54 6ZivZ98SI4K9Jy2VF7uFmmvjOI2Tp3JK8x24+z9kIKOZomGoZ7YG1uKGKtlXLH5qkw2k ZmIQ== 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:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=noLqQanQbnK+x5xF9NBNdaHzY6bHKm/YguNVSzLLRs8=; b=n6XrHijbhDvbVVUjJAGEqkp9lVH+IJ/BNImvnhXO5kHkJ5Uj47gCSJVHCDS0PF69sU vlAwrkq4WKSaBwpl723q7duFSwNW4RZwa1Sh5NzDuoRExm/eGvZr2S2nulJIwRTiVS8W hfJ+qNN2M78IEtkWcJM1mlR3hhN6yFCXB1evRo/91ntsodPNpjz9Qhj+/B0lKek3btqR wES40xOvosByNU3bNj3lvOyH9rWpLiyXJiEGzvzWGTpjS9q7XHIq3HhPzgGauxg3SmC9 EfxM0mK804u/rNxuq2YrWQUXT63FBUed+3d0JyDipWI00ATE+ZP9Yq4y5mGBR/KRISBm s+Qw== X-Gm-Message-State: APjAAAXoiy9EvlvL68KHxsi55KM4wSn7Na9XrNUlm+L4CiVxO3uRwTgD UXCX7eEB+TRaWXRi5u6zCCTrhw== X-Received: by 2002:a2e:859a:: with SMTP id b26mr11402734lji.137.1575719063530; Sat, 07 Dec 2019 03:44:23 -0800 (PST) Received: from khorivan (57-201-94-178.pool.ukrtel.net. [178.94.201.57]) by smtp.gmail.com with ESMTPSA id c189sm3761894lfg.75.2019.12.07.03.44.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Dec 2019 03:44:22 -0800 (PST) Date: Sat, 7 Dec 2019 13:44:20 +0200 From: Ivan Khoronzhuk To: Grygorii Strashko Cc: 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: <20191207114419.GA2798@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <0c6b88b2-31b1-11f0-7baa-1ecd5f4b6644@ti.com> 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 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. -- Regards, Ivan Khoronzhuk