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.

CRs-fixed: 327066
Change-Id: Ic7d15ca0399aa5c1fa01b7892cff736b3d1e4236
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
This commit is contained in:
Jeff Boody
2012-01-18 15:47:46 -07:00
committed by Linux Build Service Account
parent d24aaeed10
commit 28afec421e
3 changed files with 8 additions and 8 deletions

View File

@@ -1318,8 +1318,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;
@@ -1359,7 +1358,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

@@ -1,4 +1,4 @@
/* Copyright (c) 2002,2007-2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2002,2007-2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -421,7 +421,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;
@@ -554,7 +554,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

@@ -1,4 +1,4 @@
/* Copyright (c) 2002,2007-2011, Code Aurora Forum. All rights reserved.
/* Copyright (c) 2002,2007-2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -15,6 +15,7 @@
#include <linux/slab.h>
#include <linux/dma-mapping.h>
#include <linux/vmalloc.h>
#include "kgsl_mmu.h"
struct kgsl_device;
@@ -81,7 +82,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;