[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210316003357.GC15335@b29397-desktop>
Date: Tue, 16 Mar 2021 08:33:57 +0800
From: Peter Chen <peter.chen@...nel.org>
To: Sanket Parmar <sparmar@...ence.com>
Cc: Pawel Laszczak <pawell@...ence.com>,
"a-govindraju@...com" <a-govindraju@...com>,
"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Rahul Kumar <kurahul@...ence.com>,
"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
"kishon@...com" <kishon@...com>
Subject: Re: [PATCH 2/2] usb: cdns3: Optimize DMA request buffer allocation
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
Powered by blists - more mailing lists