msm: kgsl: Don't allocate memory dynamically for drawobj sync structs

The memory allocated dynamically here is just used to store a single
instance of a struct. Allocate both possible structs on the stack
instead of allocating them dynamically to improve performance.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Ruchit <ruchitmarathe@gmail.com>
fourteen
Sultan Alsawaf 4 years ago committed by Jenna
parent 5e51cea6b2
commit 1e86c65339
  1. 21
      drivers/gpu/msm/kgsl_drawobj.c

@ -483,8 +483,12 @@ int kgsl_drawobj_sync_add_sync(struct kgsl_device *device,
struct kgsl_drawobj_sync *syncobj,
struct kgsl_cmd_syncpoint *sync)
{
union {
struct kgsl_cmd_syncpoint_timestamp sync_timestamp;
struct kgsl_cmd_syncpoint_fence sync_fence;
} data;
void *priv;
int ret, psize;
int psize;
struct kgsl_drawobj *drawobj = DRAWOBJ(syncobj);
int (*func)(struct kgsl_device *device,
struct kgsl_drawobj_sync *syncobj,
@ -494,10 +498,12 @@ int kgsl_drawobj_sync_add_sync(struct kgsl_device *device,
case KGSL_CMD_SYNCPOINT_TYPE_TIMESTAMP:
psize = sizeof(struct kgsl_cmd_syncpoint_timestamp);
func = drawobj_add_sync_timestamp;
priv = &data.sync_timestamp;
break;
case KGSL_CMD_SYNCPOINT_TYPE_FENCE:
psize = sizeof(struct kgsl_cmd_syncpoint_fence);
func = drawobj_add_sync_fence;
priv = &data.sync_fence;
break;
default:
KGSL_DRV_ERR(device,
@ -513,19 +519,10 @@ int kgsl_drawobj_sync_add_sync(struct kgsl_device *device,
return -EINVAL;
}
priv = kzalloc(sync->size, GFP_KERNEL);
if (priv == NULL)
return -ENOMEM;
if (copy_from_user(priv, sync->priv, sync->size)) {
kfree(priv);
if (copy_from_user(priv, sync->priv, sync->size))
return -EFAULT;
}
ret = func(device, syncobj, priv);
kfree(priv);
return ret;
return func(device, syncobj, priv);
}
static void add_profiling_buffer(struct kgsl_device *device,

Loading…
Cancel
Save