summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngela Stegmaier <angelabaker@ti.com>2010-06-22 18:08:41 -0500
committerRicardo Perez Olivares <x0081762@ti.com>2010-07-16 17:41:48 -0500
commit8dd42a3aaf0902dab320d8f4b748ce72af6cf942 (patch)
tree4f96a95606c78c9fc0cd951764f8f5b6cff33534
parent05fca4546d51e1363872cb623167e738944fd191 (diff)
SYSLINK: ipc- resource cleanup gatemp changes
Changes to gatemp for resource cleanup. Signed-off-by: Angela Stegmaier <angelabaker@ti.com>
-rw-r--r--arch/arm/plat-omap/include/syslink/gatemp_ioctl.h2
-rw-r--r--drivers/dsp/syslink/multicore_ipc/gatemp_ioctl.c117
-rw-r--r--drivers/dsp/syslink/multicore_ipc/ipc_ioctl.c2
3 files changed, 99 insertions, 22 deletions
diff --git a/arch/arm/plat-omap/include/syslink/gatemp_ioctl.h b/arch/arm/plat-omap/include/syslink/gatemp_ioctl.h
index 203f6b1a4961..ff99aebf2fc3 100644
--- a/arch/arm/plat-omap/include/syslink/gatemp_ioctl.h
+++ b/arch/arm/plat-omap/include/syslink/gatemp_ioctl.h
@@ -172,6 +172,6 @@ struct gatemp_cmd_args {
* ioctl interface function for gatemp
*/
int gatemp_ioctl(struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long args);
+ unsigned int cmd, unsigned long args, bool user);
#endif /* _GATEMP_IOCTL_H_ */
diff --git a/drivers/dsp/syslink/multicore_ipc/gatemp_ioctl.c b/drivers/dsp/syslink/multicore_ipc/gatemp_ioctl.c
index 7270a76774b9..aec9c7a16feb 100644
--- a/drivers/dsp/syslink/multicore_ipc/gatemp_ioctl.c
+++ b/drivers/dsp/syslink/multicore_ipc/gatemp_ioctl.c
@@ -27,6 +27,50 @@
#include <gatemp_ioctl.h>
#include <sharedregion.h>
+static struct resource_info *find_gatemp_resource(
+ struct ipc_process_context *pr_ctxt,
+ unsigned int cmd,
+ struct gatemp_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 gatemp_cmd_args *args =
+ (struct gatemp_cmd_args *)info->data;
+ if (info->cmd == cmd) {
+ switch (cmd) {
+ case CMD_GATEMP_DELETE:
+ {
+ void *handle =
+ args->args.delete_instance.handle;
+ void *temp =
+ cargs->args.delete_instance.handle;
+ if (temp == handle)
+ found = true;
+ break;
+ }
+ case CMD_GATEMP_DESTROY:
+ {
+ found = true;
+ break;
+ }
+ }
+ if (found == true)
+ break;
+ }
+ }
+
+ spin_unlock(&pr_ctxt->res_lock);
+
+ if (found == false)
+ info = NULL;
+
+ return info;
+}
+
/* ioctl interface to gatemp_get_config function*/
static int gatemp_ioctl_get_config(struct gatemp_cmd_args *cargs)
{
@@ -258,31 +302,39 @@ static int gatemp_ioctl_get_default_remote(struct gatemp_cmd_args *cargs)
/* ioctl interface for gatemp module */
int gatemp_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 gatemp_cmd_args __user *uarg =
(struct gatemp_cmd_args __user *)args;
struct gatemp_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,
- sizeof(struct gatemp_cmd_args));
- if (size) {
- status = -EFAULT;
- goto exit;
+ /* Copy the full args from user-side */
+ size = copy_from_user(&cargs, uarg,
+ sizeof(struct gatemp_cmd_args));
+ if (size) {
+ status = -EFAULT;
+ goto exit;
+ }
+ } else {
+ if (args != 0)
+ memcpy(&cargs, (void *)args,
+ sizeof(struct gatemp_cmd_args));
}
switch (cmd) {
@@ -292,11 +344,19 @@ int gatemp_ioctl(struct inode *inode, struct file *filp,
case CMD_GATEMP_SETUP:
status = gatemp_ioctl_setup(&cargs);
+ if (status >= 0)
+ add_pr_res(pr_ctxt, CMD_GATEMP_DESTROY, NULL);
break;
case CMD_GATEMP_DESTROY:
+ {
+ struct resource_info *info = NULL;
+ info = find_gatemp_resource(pr_ctxt, CMD_GATEMP_DESTROY,
+ &cargs);
status = gatemp_ioctl_destroy(&cargs);
+ remove_pr_res(pr_ctxt, info);
break;
+ }
case CMD_GATEMP_PARAMS_INIT:
status = gatemp_ioctl_params_init(&cargs);
@@ -304,11 +364,25 @@ int gatemp_ioctl(struct inode *inode, struct file *filp,
case CMD_GATEMP_CREATE:
status = gatemp_ioctl_create(&cargs);
+ if (status >= 0) {
+ struct gatemp_cmd_args *temp = kmalloc(
+ sizeof(struct gatemp_cmd_args),
+ GFP_KERNEL);
+ temp->args.delete_instance.handle =
+ cargs.args.create.handle;
+ add_pr_res(pr_ctxt, CMD_GATEMP_DELETE, (void *)temp);
+ }
break;
case CMD_GATEMP_DELETE:
+ {
+ struct resource_info *info = NULL;
+ info = find_gatemp_resource(pr_ctxt, CMD_GATEMP_DELETE,
+ &cargs);
status = gatemp_ioctl_delete(&cargs);
+ remove_pr_res(pr_ctxt, info);
break;
+ }
case CMD_GATEMP_OPEN:
status = gatemp_ioctl_open(&cargs);
@@ -344,11 +418,14 @@ int gatemp_ioctl(struct inode *inode, struct file *filp,
break;
}
- /* Copy the full args to the user-side. */
- size = copy_to_user(uarg, &cargs, sizeof(struct gatemp_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 gatemp_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 7088496e17f0..ef6e59281a82 100644
--- a/drivers/dsp/syslink/multicore_ipc/ipc_ioctl.c
+++ b/drivers/dsp/syslink/multicore_ipc/ipc_ioctl.c
@@ -79,7 +79,7 @@ int ipc_ioc_router(u32 cmd, ulong arg, struct file *filp, bool user)
ioc_nr <= SHAREDREGION_END_CMD)
retval = sharedregion_ioctl(NULL, filp, cmd, arg, user);
else if (ioc_nr >= GATEMP_BASE_CMD && ioc_nr <= GATEMP_END_CMD)
- retval = gatemp_ioctl(NULL, filp, cmd, arg);
+ retval = gatemp_ioctl(NULL, filp, cmd, arg, user);
else if (ioc_nr >= LISTMP_BASE_CMD && ioc_nr <= LISTMP_END_CMD)
retval = listmp_ioctl(NULL, filp, cmd, arg);
else if (ioc_nr >= MESSAGEQ_BASE_CMD && ioc_nr <= MESSAGEQ_END_CMD)