msm: kgsl: convert sg allocation to vmalloc

kmalloc allocates physically contiguous memory and
may fail for larger allocations due to fragmentation.
The large allocations are caused by the fact that the
scatterlist structure is 24 bytes and the array size
is proportional to the number of pages being mapped.
This commit is contained in:
SecureCRT 2012-06-22 16:08:12 +08:00
parent b4c5202bec
commit 376f66c119
5 changed files with 8 additions and 7 deletions

View File

@ -72,6 +72,7 @@
| (MMU_CONFIG << MH_MMU_CONFIG__PA_W_CLNT_BEHAVIOR__SHIFT))
static const struct kgsl_functable adreno_functable;
unsigned int kgsl_cff_dump_enable=0;
static struct adreno_device device_3d0 = {
.dev = {

View File

@ -1291,8 +1291,7 @@ static int memdesc_sg_virt(struct kgsl_memdesc *memdesc,
int sglen = PAGE_ALIGN(size) / PAGE_SIZE;
unsigned long paddr = (unsigned long) addr;
memdesc->sg = kmalloc(sglen * sizeof(struct scatterlist),
GFP_KERNEL);
memdesc->sg = vmalloc(sglen * sizeof(struct scatterlist));
if (memdesc->sg == NULL)
return -ENOMEM;
@ -1332,7 +1331,7 @@ static int memdesc_sg_virt(struct kgsl_memdesc *memdesc,
err:
spin_unlock(&current->mm->page_table_lock);
kfree(memdesc->sg);
vfree(memdesc->sg);
memdesc->sg = NULL;
return -EINVAL;

View File

@ -20,7 +20,7 @@
#include <linux/slab.h>
#include <linux/time.h>
#include <linux/sched.h>
#include <mach/socinfo.h>
//#include <mach/socinfo.h>
#include "kgsl.h"
#include "kgsl_cffdump.h"

View File

@ -425,7 +425,7 @@ _kgsl_sharedmem_vmalloc(struct kgsl_memdesc *memdesc,
memdesc->ops = &kgsl_vmalloc_ops;
memdesc->hostptr = (void *) ptr;
memdesc->sg = kmalloc(sglen * sizeof(struct scatterlist), GFP_KERNEL);
memdesc->sg = vmalloc(sglen * sizeof(struct scatterlist));
if (memdesc->sg == NULL) {
ret = -ENOMEM;
goto done;
@ -564,7 +564,7 @@ void kgsl_sharedmem_free(struct kgsl_memdesc *memdesc)
if (memdesc->ops && memdesc->ops->free)
memdesc->ops->free(memdesc);
kfree(memdesc->sg);
vfree(memdesc->sg);
memset(memdesc, 0, sizeof(*memdesc));
}

View File

@ -16,6 +16,7 @@
#include <linux/slab.h>
#include <linux/dma-mapping.h>
#include <linux/vmalloc.h>
#include <linux/kmemleak.h>
/*
@ -87,7 +88,7 @@ memdesc_sg_phys(struct kgsl_memdesc *memdesc,
{
struct page *page = phys_to_page(physaddr);
memdesc->sg = kmalloc(sizeof(struct scatterlist) * 1, GFP_KERNEL);
memdesc->sg = vmalloc(sizeof(struct scatterlist) * 1);
if (memdesc->sg == NULL)
return -ENOMEM;