All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Chen <peter.chen@kernel.org>
To: Sanket Parmar <sparmar@cadence.com>
Cc: Pawel Laszczak <pawell@cadence.com>,
	"a-govindraju@ti.com" <a-govindraju@ti.com>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Rahul Kumar <kurahul@cadence.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"kishon@ti.com" <kishon@ti.com>
Subject: Re: [PATCH 2/2] usb: cdns3: Optimize DMA request buffer allocation
Date: Tue, 16 Mar 2021 08:33:57 +0800	[thread overview]
Message-ID: <20210316003357.GC15335@b29397-desktop> (raw)
In-Reply-To: <BY5PR07MB81194FB5A32CE9D6B793FF30B06C9@BY5PR07MB8119.namprd07.prod.outlook.com>

On 21-03-15 15:51:04, Sanket Parmar wrote:
> > > +
> > >  	priv_req->flags |= REQUEST_UNALIGNED;
> > >  	trace_cdns3_prepare_aligned_request(priv_req);
> > >
> > > @@ -3088,11 +3113,11 @@ static void cdns3_gadget_exit(struct cdns
> > *cdns)
> > >  		struct cdns3_aligned_buf *buf;
> > >
> > >  		buf = cdns3_next_align_buf(&priv_dev->aligned_buf_list);
> > > -		dma_free_coherent(priv_dev->sysdev, buf->size,
> > > -				  buf->buf,
> > > -				  buf->dma);
> > > +		dma_unmap_single(priv_dev->sysdev, buf->dma, buf->size,
> > > +			buf->dir);
> > 
> > It only needs to DMA unmap after DMA has completed, this buf will not be
> > used, otherwise, the kfree below will cause issue.
> 
> This part is not clear.  Aligned DMA buffer is allocated and mapped in cdns3_prepare_aligned_request_buf()
> and put into aligned_buf_list. While unloading the gadget, We need to undo the same if aligned_buf_list is not
> empty.  Am I missing something here? 

My point is this unmap operation is useless since there is no user for
aligned buf, and it calls kfree afterwards. You could also keep it as it has
no harm.

> 
> Also, I will post v2 of this patch which uses dma_*_noncoherent APIs suggested by Christoph Hellwig.

-- 

Thanks,
Peter Chen


  reply	other threads:[~2021-03-16  0:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-09  5:19 [PATCH 1/2] usb: cdns3: Use dma_pool_* api to alloc trb pool Sanket Parmar
2021-03-09  5:19 ` [PATCH 2/2] usb: cdns3: Optimize DMA request buffer allocation Sanket Parmar
2021-03-09  9:28   ` Christoph Hellwig
2021-03-09 10:18     ` Sanket Parmar
2021-03-09 10:31       ` Christoph Hellwig
2021-03-09 10:49         ` Sanket Parmar
2021-03-14  5:10   ` Peter Chen
2021-03-15 15:51     ` Sanket Parmar
2021-03-16  0:33       ` Peter Chen [this message]
2021-03-14  2:49 ` [PATCH 1/2] usb: cdns3: Use dma_pool_* api to alloc trb pool Peter Chen
2021-03-15  6:11   ` Sanket Parmar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210316003357.GC15335@b29397-desktop \
    --to=peter.chen@kernel.org \
    --cc=a-govindraju@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kishon@ti.com \
    --cc=kurahul@cadence.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=pawell@cadence.com \
    --cc=sparmar@cadence.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.