回复: [PATCH] USB: add __get_free_pages() in hcd_buffer_alloc function

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

 




________________________________________
发件人: Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx>
发送时间: 2021年1月3日 19:03
收件人: Zhang, Qiang
抄送: stern@xxxxxxxxxxxxxxxxxxx; linux-usb@xxxxxxxxxxxxxxx
主题: Re: [PATCH] USB: add __get_free_pages() in hcd_buffer_alloc function

On Sun, Jan 03, 2021 at 04:19:02PM +0800, qiang.zhang@xxxxxxxxxxxxx wrote:
> From: Zqiang <qiang.zhang@xxxxxxxxxxxxx>
>
> When USB hosts just use PIO, allocate memory by slab/slub
> memory manager, if the required memory size is larger than
> one or more page sizes, need allocate memory directly from
> buddy systems.

>That says _what_ you are doing, but not _why_ you need to do this.

>What in-tree host controller has this problem and on what platform?

>
> Signed-off-by: Zqiang <qiang.zhang@xxxxxxxxxxxxx>
> ---
>  drivers/usb/core/buffer.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
> index fbb087b728dc..28e7db9f93d5 100644
> --- a/drivers/usb/core/buffer.c
> +++ b/drivers/usb/core/buffer.c
> @@ -131,7 +131,8 @@ void *hcd_buffer_alloc(
>       /* some USB hosts just use PIO */
>       if (!hcd_uses_dma(hcd)) {
>               *dma = ~(dma_addr_t) 0;
> -             return kmalloc(size, mem_flags);
> +             return size < PAGE_SIZE ? kmalloc(size, mem_flags)
> +                                     : __get_free_pages(mem_flags, get_order(size));

>Please never use ? : statements if at all possible.  Use a real if ()
>instead.

>Oh, and make sure your code actually builds properly :(

 I'm very sorry. It was my mistake, I will modify and resend.  
 if some hcd hosts not support DMA  and localmem_pool,
 when we call usb_alloc_coherent function ,It's  actually 
 just a call kmalloc function, it is only suitable for allocating 
 memory smaller than one pagesize,  if size is larger than the 
 size of a pagesize, need allocate memory directly from buddy 
 system.

 
>What platforms did you test this on?

>thanks,

>greg k-h




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

  Powered by Linux