msm: kgsl: Use kzalloc to allocate scatterlists of 1 page or less
The majority of the scatterlist allocations used in KGSL are under 1
page (1 page of struct scatterlist is approximately 1024 entries
equalling 4MB of allocated buffer). In these cases using vmalloc
for the sglist is undesirable and slow. Add functions to check the
size of the allocation and favor kzalloc for 1 page allocations and
vmalloc for larger lists.
Change-Id: Ic0dedbad99b60111677dd56b74edd8cedcac17f0
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
diff --git a/drivers/gpu/msm/kgsl_sharedmem.c b/drivers/gpu/msm/kgsl_sharedmem.c
index d7d0809..1f142f8 100644
--- a/drivers/gpu/msm/kgsl_sharedmem.c
+++ b/drivers/gpu/msm/kgsl_sharedmem.c
@@ -463,7 +463,8 @@
memdesc->priv = KGSL_MEMFLAGS_CACHED;
memdesc->ops = &kgsl_vmalloc_ops;
- memdesc->sg = vmalloc(sglen * sizeof(struct scatterlist));
+ memdesc->sg = kgsl_sg_alloc(sglen);
+
if (memdesc->sg == NULL) {
ret = -ENOMEM;
goto done;
@@ -589,7 +590,7 @@
if (memdesc->ops && memdesc->ops->free)
memdesc->ops->free(memdesc);
- vfree(memdesc->sg);
+ kgsl_sg_free(memdesc->sg, memdesc->sglen);
memset(memdesc, 0, sizeof(*memdesc));
}