From 1e86c65339934e7477029a12dae7ad2c7dbb3b20 Mon Sep 17 00:00:00 2001 From: Sultan Alsawaf Date: Sat, 26 Dec 2020 11:38:24 -0800 Subject: [PATCH] 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 Signed-off-by: Ruchit --- drivers/gpu/msm/kgsl_drawobj.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/msm/kgsl_drawobj.c b/drivers/gpu/msm/kgsl_drawobj.c index f5b424a5be04..89f59fcf5342 100755 --- a/drivers/gpu/msm/kgsl_drawobj.c +++ b/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,