Re: [PATCH 2/2] usb: host: xhci: using dma pool for scratchpad buffer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 29, 2017 at 08:50:23AM +0300, Felipe Balbi wrote:
> 
> Hi,
> 
> Peter Chen <peter.chen@xxxxxxx> writes:
> > According to xHCI ch4.20 Scratchpad Buffers
> > 	A Scratchpad Buffer is a PAGESIZE block of system memory
> >        	located on a PAGESIZE boundary
> > 	...
> > 	Software clears the Scratchpad Buffer to ‘0’
> >
> > So, we need to use dma pool for PAGESIZE boundary buffer, and zeroed
> > its region using dma_pool_zalloc.
> 
> you're doing two separate things here...
> 
> > Signed-off-by: Peter Chen <peter.chen@xxxxxxx>
> > ---
> >  drivers/usb/host/xhci-mem.c | 21 +++++++++++++++------
> >  drivers/usb/host/xhci.h     |  1 +
> >  2 files changed, 16 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
> > index 22a03b7..56aa0a6 100644
> > --- a/drivers/usb/host/xhci-mem.c
> > +++ b/drivers/usb/host/xhci-mem.c
> > @@ -1710,12 +1710,18 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
> >  		goto fail_sp3;
> >  
> >  	xhci->dcbaa->dev_context_ptrs[0] = cpu_to_le64(xhci->scratchpad->sp_dma);
> > +
> > +	xhci->scratchpad_pool = dma_pool_create("xhci scratchpad buffer pool",
> > +			dev, xhci->page_size,
> > +			xhci->page_size, xhci->page_size);
> 
> adding a DMA pool here, and ...
> 
> > +	if (!xhci->scratchpad_pool)
> > +		goto fail_sp4;
> > +
> >  	for (i = 0; i < num_sp; i++) {
> >  		dma_addr_t dma;
> > -		void *buf = dma_alloc_coherent(dev, xhci->page_size, &dma,
> > -				flags);
> > +		void *buf = dma_pool_zalloc(xhci->scratchpad_pool, flags, &dma);
> 
> ... fixing a possible bug here.
> 

I know it is two things, but after the dma pool is introduced, we need a
new API to allocate memory, do you want to me use dma_pool_alloc first,
then, change it to use dma_pool_zalloc at another patch? I am ok to do
that.

-- 

Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux