From: Rebecca Schultz Zavin Date: Fri, 13 Dec 2013 22:24:09 +0000 (-0800) Subject: gpu: ion: use vmalloc to allocate page array to map kernel X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=98d5d5f8bad43770803a08e5a969cc9d8200b681;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git gpu: ion: use vmalloc to allocate page array to map kernel When ion_map_kernel is execute the system must allocate an array large enough to hold a pointer to each page in the buffer. If the buffer is very large and the system memory has become very fragmented, there may not be sufficient high order allocations available from kmalloc. Use vmalloc instead. Signed-off-by: Rebecca Schultz Zavin [jstultz: modified patch to apply to staging directory] Signed-off-by: John Stultz Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c index 25b02556076a..fcfbb661f2df 100644 --- a/drivers/staging/android/ion/ion_system_heap.c +++ b/drivers/staging/android/ion/ion_system_heap.c @@ -174,10 +174,12 @@ void *ion_system_heap_map_kernel(struct ion_heap *heap, pgprot_t pgprot; struct sg_table *table = buffer->priv_virt; int npages = PAGE_ALIGN(buffer->size) / PAGE_SIZE; - struct page **pages = kzalloc(sizeof(struct page *) * npages, - GFP_KERNEL); + struct page **pages = vmalloc(sizeof(struct page *) * npages); struct page **tmp = pages; + if (!pages) + return 0; + if (buffer->flags & ION_FLAG_CACHED) pgprot = PAGE_KERNEL; else @@ -192,7 +194,7 @@ void *ion_system_heap_map_kernel(struct ion_heap *heap, } } vaddr = vmap(pages, npages, VM_MAP, pgprot); - kfree(pages); + vfree(pages); return vaddr; }