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. 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)); } for (i = 0; i < HCD_BUFFER_POOLS; i++) { @@ -160,8 +161,8 @@ void hcd_buffer_free( } if (!hcd_uses_dma(hcd)) { - kfree(addr); - return; + return size < PAGE_SIZE ? kfree(addr) + : free_pages(addr, get_order(size)); } for (i = 0; i < HCD_BUFFER_POOLS; i++) { -- 2.17.1