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

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

 



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 :(

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