diff options
author | Angela Stegmaier <angelabaker@ti.com> | 2010-06-22 17:45:25 -0500 |
---|---|---|
committer | Ricardo Perez Olivares <x0081762@ti.com> | 2010-07-16 17:41:48 -0500 |
commit | 96e244a1cfc97fd396879371e33862c08ceaef93 (patch) | |
tree | 213bfda246a089c6a1d8e1f7c54cb795f301f5b0 | |
parent | 2ab4fb9e2c48e581d0318b7ec094a6dc78e89232 (diff) |
SYSLINK: ipc- resource cleanup nameserver changes
Changes to the nameserver module to add the resources to the list to be
cleaned up when the driver handle is released.
Signed-off-by: Angela Stegmaier <angelabaker@ti.com>
-rw-r--r-- | arch/arm/plat-omap/include/syslink/nameserver_ioctl.h | 2 | ||||
-rw-r--r-- | drivers/dsp/syslink/multicore_ipc/ipc_ioctl.c | 2 | ||||
-rw-r--r-- | drivers/dsp/syslink/multicore_ipc/nameserver_ioctl.c | 118 |
3 files changed, 101 insertions, 21 deletions
diff --git a/arch/arm/plat-omap/include/syslink/nameserver_ioctl.h b/arch/arm/plat-omap/include/syslink/nameserver_ioctl.h index 4909aa3fa3cb..8e8159dc240b 100644 --- a/arch/arm/plat-omap/include/syslink/nameserver_ioctl.h +++ b/arch/arm/plat-omap/include/syslink/nameserver_ioctl.h @@ -256,6 +256,6 @@ struct nameserver_cmd_args { * This ioctl interface for nameserver module */ int nameserver_ioctl(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long args); + unsigned int cmd, unsigned long args, bool user); #endif /* _NAMESERVER_IOCTL_H_ */ diff --git a/drivers/dsp/syslink/multicore_ipc/ipc_ioctl.c b/drivers/dsp/syslink/multicore_ipc/ipc_ioctl.c index 9253ce62df18..f9fcb31f706e 100644 --- a/drivers/dsp/syslink/multicore_ipc/ipc_ioctl.c +++ b/drivers/dsp/syslink/multicore_ipc/ipc_ioctl.c @@ -72,7 +72,7 @@ int ipc_ioc_router(u32 cmd, ulong arg, struct file *filp, bool user) if (ioc_nr >= MULTIPROC_BASE_CMD && ioc_nr <= MULTIPROC_END_CMD) retval = multiproc_ioctl(NULL, filp, cmd, arg, user); else if (ioc_nr >= NAMESERVER_BASE_CMD && ioc_nr <= NAMESERVER_END_CMD) - retval = nameserver_ioctl(NULL, filp, cmd, arg); + retval = nameserver_ioctl(NULL, filp, cmd, arg, user); else if (ioc_nr >= HEAPBUFMP_BASE_CMD && ioc_nr <= HEAPBUFMP_END_CMD) retval = heapbufmp_ioctl(NULL, filp, cmd, arg); else if (ioc_nr >= SHAREDREGION_BASE_CMD && diff --git a/drivers/dsp/syslink/multicore_ipc/nameserver_ioctl.c b/drivers/dsp/syslink/multicore_ipc/nameserver_ioctl.c index c4cc75e40cb6..4411bef0dc41 100644 --- a/drivers/dsp/syslink/multicore_ipc/nameserver_ioctl.c +++ b/drivers/dsp/syslink/multicore_ipc/nameserver_ioctl.c @@ -27,6 +27,50 @@ * FUNCTIONS NEED TO BE REVIEWED OPTIMIZED! */ +static struct resource_info *find_nameserver_resource( + struct ipc_process_context *pr_ctxt, + unsigned int cmd, + struct nameserver_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 nameserver_cmd_args *args = + (struct nameserver_cmd_args *)info->data; + if (info->cmd == cmd) { + switch (cmd) { + case CMD_NAMESERVER_DELETE: + { + void *handle = + args->args.delete_instance.handle; + void *temp = + cargs->args.delete_instance.handle; + if (temp == handle) + found = true; + break; + } + case CMD_NAMESERVER_DESTROY: + { + found = true; + break; + } + } + if (found == true) + break; + } + } + + spin_unlock(&pr_ctxt->res_lock); + + if (found == false) + info = NULL; + + return info; +} + /* * ======== nameserver_ioctl_setup ======== * Purpose: @@ -489,31 +533,39 @@ exit: * This ioctl interface for nameserver module */ int nameserver_ioctl(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long args) + unsigned int cmd, unsigned long args, bool user) { s32 status = 0; s32 size = 0; struct nameserver_cmd_args __user *uarg = (struct nameserver_cmd_args __user *)args; struct nameserver_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 nameserver_cmd_args)); - if (size) { - status = -EFAULT; - goto exit; + if (size) { + status = -EFAULT; + goto exit; + } + } else { + if (args != 0) + memcpy(&cargs, (void *)args, + sizeof(struct nameserver_cmd_args)); } switch (cmd) { @@ -551,11 +603,27 @@ int nameserver_ioctl(struct inode *inode, struct file *filp, case CMD_NAMESERVER_CREATE: status = nameserver_ioctl_create(&cargs); + if (status >= 0) { + struct nameserver_cmd_args *temp = kmalloc( + sizeof(struct nameserver_cmd_args), + GFP_KERNEL); + temp->args.delete_instance.handle = + cargs.args.create.handle; + add_pr_res(pr_ctxt, CMD_NAMESERVER_DELETE, + (void *)temp); + } break; case CMD_NAMESERVER_DELETE: + { + struct resource_info *info = NULL; + info = find_nameserver_resource(pr_ctxt, + CMD_NAMESERVER_DELETE, + &cargs); status = nameserver_ioctl_delete(&cargs); + remove_pr_res(pr_ctxt, info); break; + } case CMD_NAMESERVER_GETHANDLE: status = nameserver_ioctl_get_handle(&cargs); @@ -563,11 +631,20 @@ int nameserver_ioctl(struct inode *inode, struct file *filp, case CMD_NAMESERVER_SETUP: status = nameserver_ioctl_setup(&cargs); + if (cargs.api_status >= 0) + add_pr_res(pr_ctxt, CMD_NAMESERVER_DESTROY, NULL); break; case CMD_NAMESERVER_DESTROY: + { + struct resource_info *info = NULL; + info = find_nameserver_resource(pr_ctxt, + CMD_NAMESERVER_DESTROY, + &cargs); status = nameserver_ioctl_destroy(&cargs); + remove_pr_res(pr_ctxt, info); break; + } default: WARN_ON(cmd); @@ -581,11 +658,14 @@ int nameserver_ioctl(struct inode *inode, struct file *filp, if (status < 0) goto exit; - /* Copy the full args to the user-side. */ - size = copy_to_user(uarg, &cargs, sizeof(struct nameserver_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 nameserver_cmd_args)); + if (size) { + status = -EFAULT; + goto exit; + } } exit: |