diff options
author | Angela Stegmaier <angelabaker@ti.com> | 2010-06-22 18:21:33 -0500 |
---|---|---|
committer | Ricardo Perez Olivares <x0081762@ti.com> | 2010-07-16 17:41:49 -0500 |
commit | a57ecc322a129f909884ac63b43d709c1056c98f (patch) | |
tree | cc87962ec0f85376773a3a76c91795fa9bb23ca4 | |
parent | 540687b9dd957a7b1059ddc36330f01d8103c033 (diff) |
SYSLINK: ipc- resource cleanup heapmemmp changes
Changes to heapmemmp for resource cleanup.
Signed-off-by: Angela Stegmaier <angelabaker@ti.com>
-rw-r--r-- | arch/arm/plat-omap/include/syslink/heapmemmp_ioctl.h | 2 | ||||
-rw-r--r-- | drivers/dsp/syslink/multicore_ipc/heapmemmp_ioctl.c | 116 | ||||
-rw-r--r-- | drivers/dsp/syslink/multicore_ipc/ipc_ioctl.c | 2 |
3 files changed, 98 insertions, 22 deletions
diff --git a/arch/arm/plat-omap/include/syslink/heapmemmp_ioctl.h b/arch/arm/plat-omap/include/syslink/heapmemmp_ioctl.h index f95dad36c45b..1fbb44f2bb37 100644 --- a/arch/arm/plat-omap/include/syslink/heapmemmp_ioctl.h +++ b/arch/arm/plat-omap/include/syslink/heapmemmp_ioctl.h @@ -238,6 +238,6 @@ struct heapmemmp_cmd_args{ * This ioctl interface for heapmem module */ int heapmemmp_ioctl(struct inode *pinode, struct file *filp, - unsigned int cmd, unsigned long args); + unsigned int cmd, unsigned long args, bool user); #endif /* _HEAPMEMMP_IOCTL_ */ diff --git a/drivers/dsp/syslink/multicore_ipc/heapmemmp_ioctl.c b/drivers/dsp/syslink/multicore_ipc/heapmemmp_ioctl.c index 56a0828c2098..c145e01d7762 100644 --- a/drivers/dsp/syslink/multicore_ipc/heapmemmp_ioctl.c +++ b/drivers/dsp/syslink/multicore_ipc/heapmemmp_ioctl.c @@ -27,6 +27,48 @@ #include <heapmemmp_ioctl.h> #include <sharedregion.h> +static struct resource_info *find_heapmemmp_resource( + struct ipc_process_context *pr_ctxt, + unsigned int cmd, + struct heapmemmp_cmd_args *cargs) +{ + struct resource_info *info = NULL; + bool found = false; + + spin_lock(&pr_ctxt->res_lock); + + list_for_each_entry(info, &pr_ctxt->resources, res) { + struct heapmemmp_cmd_args *args = + (struct heapmemmp_cmd_args *)info->data; + if (info->cmd == cmd) { + switch (cmd) { + case CMD_HEAPMEMMP_DELETE: + { + void *handle = args->args.delete.handle; + void *temp = cargs->args.delete.handle; + if (temp == handle) + found = true; + break; + } + case CMD_HEAPMEMMP_DESTROY: + { + found = true; + break; + } + } + if (found == true) + break; + } + } + + spin_unlock(&pr_ctxt->res_lock); + + if (found == false) + info = NULL; + + return info; +} + /* * ======== heapmemmp_ioctl_alloc ======== * Purpose: @@ -39,6 +81,7 @@ static int heapmemmp_ioctl_alloc(struct heapmemmp_cmd_args *cargs) s32 index; s32 status = 0; + printk(KERN_ERR "heapmemmp_ioctl_alloc: heapmemmp_alloc\n"); block = heapmemmp_alloc(cargs->args.alloc.handle, cargs->args.alloc.size, cargs->args.alloc.align); @@ -372,30 +415,38 @@ static int heapmemmp_ioctl_restore(struct heapmemmp_cmd_args *cargs) * This ioctl interface for heapmem module */ int heapmemmp_ioctl(struct inode *pinode, struct file *filp, - unsigned int cmd, unsigned long args) + unsigned int cmd, unsigned long args, bool user) { s32 status = 0; s32 size = 0; struct heapmemmp_cmd_args __user *uarg = (struct heapmemmp_cmd_args __user *)args; struct heapmemmp_cmd_args cargs; + struct ipc_process_context *pr_ctxt = + (struct ipc_process_context *)filp->private_data; - if (_IOC_DIR(cmd) & _IOC_READ) - status = !access_ok(VERIFY_WRITE, uarg, _IOC_SIZE(cmd)); - else if (_IOC_DIR(cmd) & _IOC_WRITE) - status = !access_ok(VERIFY_READ, uarg, _IOC_SIZE(cmd)); + if (user == true) { + if (_IOC_DIR(cmd) & _IOC_READ) + status = !access_ok(VERIFY_WRITE, uarg, _IOC_SIZE(cmd)); + else if (_IOC_DIR(cmd) & _IOC_WRITE) + status = !access_ok(VERIFY_READ, uarg, _IOC_SIZE(cmd)); - if (status) { - status = -EFAULT; - goto exit; - } + if (status) { + status = -EFAULT; + goto exit; + } - /* Copy the full args from user-side */ - size = copy_from_user(&cargs, uarg, + /* Copy the full args from user-side */ + size = copy_from_user(&cargs, uarg, sizeof(struct heapmemmp_cmd_args)); - if (size) { - status = -EFAULT; - goto exit; + if (size) { + status = -EFAULT; + goto exit; + } + } else { + if (args != 0) + memcpy(&cargs, (void *)args, + sizeof(struct heapmemmp_cmd_args)); } switch (cmd) { @@ -413,11 +464,25 @@ int heapmemmp_ioctl(struct inode *pinode, struct file *filp, case CMD_HEAPMEMMP_CREATE: status = heapmemmp_ioctl_create(&cargs); + if (status >= 0) { + struct heapmemmp_cmd_args *temp = kmalloc( + sizeof(struct heapmemmp_cmd_args), + GFP_KERNEL); + temp->args.delete.handle = cargs.args.create.handle; + add_pr_res(pr_ctxt, CMD_HEAPMEMMP_DELETE, (void *)temp); + } break; case CMD_HEAPMEMMP_DELETE: + { + struct resource_info *info = NULL; + info = find_heapmemmp_resource(pr_ctxt, + CMD_HEAPMEMMP_DELETE, + &cargs); status = heapmemmp_ioctl_delete(&cargs); + remove_pr_res(pr_ctxt, info); break; + } case CMD_HEAPMEMMP_OPEN: status = heapmemmp_ioctl_open(&cargs); @@ -441,11 +506,20 @@ int heapmemmp_ioctl(struct inode *pinode, struct file *filp, case CMD_HEAPMEMMP_SETUP: status = heapmemmp_ioctl_setup(&cargs); + if (status >= 0) + add_pr_res(pr_ctxt, CMD_HEAPMEMMP_DESTROY, NULL); break; case CMD_HEAPMEMMP_DESTROY: + { + struct resource_info *info = NULL; + info = find_heapmemmp_resource(pr_ctxt, + CMD_HEAPMEMMP_DESTROY, + &cargs); status = heapmemmp_ioctl_destroy(&cargs); + remove_pr_res(pr_ctxt, info); break; + } case CMD_HEAPMEMMP_GETSTATS: status = heapmemmp_ioctl_get_stats(&cargs); @@ -465,12 +539,14 @@ int heapmemmp_ioctl(struct inode *pinode, struct file *filp, break; } - /* Copy the full args to the user-side. */ - size = copy_to_user(uarg, &cargs, - sizeof(struct heapmemmp_cmd_args)); - if (size) { - status = -EFAULT; - goto exit; + if (user == true) { + /* Copy the full args to the user-side. */ + size = copy_to_user(uarg, &cargs, + sizeof(struct heapmemmp_cmd_args)); + if (size) { + status = -EFAULT; + goto exit; + } } exit: diff --git a/drivers/dsp/syslink/multicore_ipc/ipc_ioctl.c b/drivers/dsp/syslink/multicore_ipc/ipc_ioctl.c index 34681da0da7e..f6275c2788b3 100644 --- a/drivers/dsp/syslink/multicore_ipc/ipc_ioctl.c +++ b/drivers/dsp/syslink/multicore_ipc/ipc_ioctl.c @@ -89,7 +89,7 @@ int ipc_ioc_router(u32 cmd, ulong arg, struct file *filp, bool user) /* else if (ioc_nr >= SYSMEMMGR_BASE_CMD && ioc_nr <= SYSMEMMGR_END_CMD) retval = sysmemmgr_ioctl(NULL, NULL, cmd, arg);*/ else if (ioc_nr >= HEAPMEMMP_BASE_CMD && ioc_nr <= HEAPMEMMP_END_CMD) - retval = heapmemmp_ioctl(NULL, filp, cmd, arg); + retval = heapmemmp_ioctl(NULL, filp, cmd, arg, user); else if (ioc_nr >= NOTIFY_BASE_CMD && ioc_nr <= NOTIFY_END_CMD) retval = notify_drv_ioctl(NULL, filp, cmd, arg); else |