summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngela Stegmaier <angelabaker@ti.com>2010-06-22 17:31:53 -0500
committerRicardo Perez Olivares <x0081762@ti.com>2010-07-16 17:41:48 -0500
commit2ab4fb9e2c48e581d0318b7ec094a6dc78e89232 (patch)
treea4b0136859927020dbe1a18aac27710744432f17
parent4715d931a465263e279c3edf37af817a16ef5aad (diff)
SYSLINK: ipc- resource cleanup multiproc changes
Changes to the multiproc module to add setup calls to the list of resources to be cleaned when the driver handle is closed. Signed-off-by: Angela Stegmaier <angelabaker@ti.com>
-rw-r--r--arch/arm/plat-omap/include/syslink/multiproc_ioctl.h2
-rw-r--r--drivers/dsp/syslink/multicore_ipc/ipc_ioctl.c2
-rw-r--r--drivers/dsp/syslink/multicore_ipc/multiproc_ioctl.c89
3 files changed, 72 insertions, 21 deletions
diff --git a/arch/arm/plat-omap/include/syslink/multiproc_ioctl.h b/arch/arm/plat-omap/include/syslink/multiproc_ioctl.h
index 0c9780136b02..f641f22d13d1 100644
--- a/arch/arm/plat-omap/include/syslink/multiproc_ioctl.h
+++ b/arch/arm/plat-omap/include/syslink/multiproc_ioctl.h
@@ -89,6 +89,6 @@ struct multiproc_cmd_args {
* This ioctl interface for multiproc module
*/
int multiproc_ioctl(struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long args);
+ unsigned int cmd, unsigned long args, bool user);
#endif /* _MULTIPROC_IOCTL_H_ */
diff --git a/drivers/dsp/syslink/multicore_ipc/ipc_ioctl.c b/drivers/dsp/syslink/multicore_ipc/ipc_ioctl.c
index 5949d7c1dc33..9253ce62df18 100644
--- a/drivers/dsp/syslink/multicore_ipc/ipc_ioctl.c
+++ b/drivers/dsp/syslink/multicore_ipc/ipc_ioctl.c
@@ -70,7 +70,7 @@ int ipc_ioc_router(u32 cmd, ulong arg, struct file *filp, bool user)
u32 ioc_nr = _IOC_NR(cmd);
if (ioc_nr >= MULTIPROC_BASE_CMD && ioc_nr <= MULTIPROC_END_CMD)
- retval = multiproc_ioctl(NULL, filp, cmd, arg);
+ 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);
else if (ioc_nr >= HEAPBUFMP_BASE_CMD && ioc_nr <= HEAPBUFMP_END_CMD)
diff --git a/drivers/dsp/syslink/multicore_ipc/multiproc_ioctl.c b/drivers/dsp/syslink/multicore_ipc/multiproc_ioctl.c
index 8f36304f3397..758a08685d04 100644
--- a/drivers/dsp/syslink/multicore_ipc/multiproc_ioctl.c
+++ b/drivers/dsp/syslink/multicore_ipc/multiproc_ioctl.c
@@ -22,6 +22,36 @@
#include <multiproc.h>
#include <multiproc_ioctl.h>
+static struct resource_info *find_mproc_resource(
+ struct ipc_process_context *pr_ctxt,
+ unsigned int cmd,
+ struct multiproc_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) {
+ if (info->cmd == cmd) {
+ switch (cmd) {
+ case CMD_MULTIPROC_DESTROY:
+ found = true;
+ break;
+ }
+ }
+ if (found == true)
+ break;
+ }
+
+ spin_unlock(&pr_ctxt->res_lock);
+
+ if (found == false)
+ info = NULL;
+
+ return info;
+}
+
/*
* ======== mproc_ioctl_setup ========
* Purpose:
@@ -100,41 +130,59 @@ static int multiproc_ioctl_set_local_id(struct multiproc_cmd_args *cargs)
* This ioctl interface for multiproc module
*/
int multiproc_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 multiproc_cmd_args __user *uarg =
(struct multiproc_cmd_args __user *)args;
struct multiproc_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 multiproc_cmd_args));
- if (size) {
- status = -EFAULT;
- goto exit;
+ if (size) {
+ status = -EFAULT;
+ goto exit;
+ }
+ } else {
+ if (args != 0)
+ memcpy(&cargs, (void *)args,
+ sizeof(struct multiproc_cmd_args));
}
switch (cmd) {
case CMD_MULTIPROC_SETUP:
status = mproc_ioctl_setup(&cargs);
+ if (status == 0 && cargs.api_status >= 0)
+ add_pr_res(pr_ctxt, CMD_MULTIPROC_DESTROY, NULL);
break;
case CMD_MULTIPROC_DESTROY:
+ {
+ struct resource_info *info = NULL;
+
+ info = find_mproc_resource(pr_ctxt,
+ CMD_MULTIPROC_DESTROY,
+ &cargs);
status = mproc_ioctl_destroy(&cargs);
+ remove_pr_res(pr_ctxt, info);
break;
+ }
case CMD_MULTIPROC_GETCONFIG:
status = mproc_ioctl_get_config(&cargs);
@@ -157,11 +205,14 @@ int multiproc_ioctl(struct inode *inode, struct file *filp,
goto exit;
- /* Copy the full args to the user-side. */
- size = copy_to_user(uarg, &cargs, sizeof(struct multiproc_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 multiproc_cmd_args));
+ if (size) {
+ status = -EFAULT;
+ goto exit;
+ }
}
exit: