gpu: ion: use vmalloc to allocate page array to map kernel
authorRebecca Schultz Zavin <rebecca@android.com>
Sun, 30 Sep 2012 21:53:27 +0000 (14:53 -0700)
committerArve Hjønnevåg <arve@android.com>
Mon, 1 Jul 2013 21:16:08 +0000 (14:16 -0700)
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.

Change-Id: I5fabf79be6cfd158f7805bfca6267a60c4708582
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
drivers/gpu/ion/ion_system_heap.c

index 7b441926a761e709afbffb0ab5d153c137bb9d26..86e2eab5e59674e91df244c6be295831225a9d4e 100644 (file)
@@ -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;
 }