diff --git a/drivers/gpu/msm/adreno_ringbuffer.c b/drivers/gpu/msm/adreno_ringbuffer.c index 1aa6777f8..c707e28be 100644 --- a/drivers/gpu/msm/adreno_ringbuffer.c +++ b/drivers/gpu/msm/adreno_ringbuffer.c @@ -869,6 +869,7 @@ int adreno_ringbuffer_submitcmd(struct adreno_device *adreno_dev, struct kgsl_memobj_node *ib; unsigned int numibs = 0; unsigned int *link; + unsigned int link_onstack[SZ_256] __aligned(sizeof(long)); unsigned int *cmds; struct kgsl_context *context; struct adreno_context *drawctxt; @@ -996,10 +997,14 @@ int adreno_ringbuffer_submitcmd(struct adreno_device *adreno_dev, if (gpudev->ccu_invalidate) dwords += 4; - link = kvcalloc(dwords, sizeof(unsigned int), GFP_KERNEL); - if (!link) { - ret = -ENOMEM; - goto done; + if (dwords <= ARRAY_SIZE(link_onstack)) { + link = link_onstack; + } else { + link = kvcalloc(dwords, sizeof(unsigned int), GFP_KERNEL); + if (!link) { + ret = -ENOMEM; + goto done; + } } cmds = link; @@ -1129,7 +1134,9 @@ int adreno_ringbuffer_submitcmd(struct adreno_device *adreno_dev, trace_kgsl_issueibcmds(device, context->id, numibs, drawobj->timestamp, drawobj->flags, ret, drawctxt->type); - kvfree(link); + if (link != link_onstack) + kvfree(link); + return ret; }