Commit bcf4f99a authored by Arun Gopalakrishnan's avatar Arun Gopalakrishnan Committed by Hari Kanigeri

IPC SharedRegion module fixes

The changes are
1. The ioctl interface is modified based on review comment
   to make it consistest with other ipc modules(e.g messageq)
2. All the ioctl commands were made as IOWR commands
3. Debug prints were added in all the APIs failure return
Signed-off-by: default avatarArun M G <arunmg@ti.com>
parent 5b28e4d8
...@@ -53,18 +53,19 @@ enum CMD_SHAREDREGION { ...@@ -53,18 +53,19 @@ enum CMD_SHAREDREGION {
/* /*
* Command for sharedregion_setup * Command for sharedregion_setup
*/ */
#define CMD_SHAREDREGION_SETUP _IOW(IPC_IOC_MAGIC, \ #define CMD_SHAREDREGION_SETUP _IOWR(IPC_IOC_MAGIC, \
SHAREDREGION_SETUP, \ SHAREDREGION_SETUP, \
struct sharedregion_cmd_args) struct sharedregion_cmd_args)
/* /*
* Command for sharedregion_setup * Command for sharedregion_setup
*/ */
#define CMD_SHAREDREGION_DESTROY _IO(IPC_IOC_MAGIC, \ #define CMD_SHAREDREGION_DESTROY _IOWR(IPC_IOC_MAGIC, \
SHAREDREGION_DESTROY) SHAREDREGION_DESTROY, \
struct sharedregion_cmd_args)
/* /*
* Command for sharedregion_ADD * Command for sharedregion_ADD
*/ */
#define CMD_SHAREDREGION_ADD _IOW(IPC_IOC_MAGIC, \ #define CMD_SHAREDREGION_ADD _IOWR(IPC_IOC_MAGIC, \
SHAREDREGION_ADD, \ SHAREDREGION_ADD, \
struct sharedregion_cmd_args) struct sharedregion_cmd_args)
/* /*
...@@ -91,13 +92,13 @@ enum CMD_SHAREDREGION { ...@@ -91,13 +92,13 @@ enum CMD_SHAREDREGION {
/* /*
* Command for sharedregion_remove * Command for sharedregion_remove
*/ */
#define CMD_SHAREDREGION_REMOVE _IOW(IPC_IOC_MAGIC, \ #define CMD_SHAREDREGION_REMOVE _IOWR(IPC_IOC_MAGIC, \
SHAREDREGION_REMOVE, \ SHAREDREGION_REMOVE, \
struct sharedregion_cmd_args) struct sharedregion_cmd_args)
/* /*
* Command for sharedregion_set_table_info * Command for sharedregion_set_table_info
*/ */
#define CMD_SHAREDREGION_SETTABLEINFO _IOW(IPC_IOC_MAGIC, \ #define CMD_SHAREDREGION_SETTABLEINFO _IOWR(IPC_IOC_MAGIC, \
SHAREDREGION_SETTABLEINFO, \ SHAREDREGION_SETTABLEINFO, \
struct sharedregion_cmd_args) struct sharedregion_cmd_args)
...@@ -163,7 +164,7 @@ union sharedregion_arg { ...@@ -163,7 +164,7 @@ union sharedregion_arg {
* Command arguments for sharedregion * Command arguments for sharedregion
*/ */
struct sharedregion_cmd_args { struct sharedregion_cmd_args {
union sharedregion_arg cmd_arg; union sharedregion_arg args;
s32 api_status; s32 api_status;
}; };
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE. * PURPOSE.
*/ */
#include <linux/module.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
* Module state object * Module state object
*/ */
struct sharedregion_object { struct sharedregion_object {
void *gate_handle; struct mutex *gate_handle;
struct sharedregion_info *table; /* Ptr to the table */ struct sharedregion_info *table; /* Ptr to the table */
u32 bitOffset; /* Index bit offset */ u32 bitOffset; /* Index bit offset */
u32 region_size; /* Max size of each region */ u32 region_size; /* Max size of each region */
...@@ -55,14 +55,12 @@ static struct sharedregion_object sharedregion_state = { ...@@ -55,14 +55,12 @@ static struct sharedregion_object sharedregion_state = {
*/ */
int sharedregion_get_config(struct sharedregion_config *config) int sharedregion_get_config(struct sharedregion_config *config)
{ {
gt_1trace(sharedregion_mask, GT_ENTER,
"sharedregion_get_config:\n config: %x \n", config);
BUG_ON((config == NULL)); BUG_ON((config == NULL));
memcpy(config, &sharedregion_state.cfg, memcpy(config, &sharedregion_state.cfg,
sizeof(struct sharedregion_config)); sizeof(struct sharedregion_config));
return 0; return 0;
} }
EXPORT_SYMBOL(sharedregion_get_config);
/* /*
...@@ -97,8 +95,6 @@ int sharedregion_setup(const struct sharedregion_config *config) ...@@ -97,8 +95,6 @@ int sharedregion_setup(const struct sharedregion_config *config)
s32 retval = 0; s32 retval = 0;
u16 proc_count; u16 proc_count;
gt_1trace(sharedregion_mask, GT_ENTER,
"sharedregion_setup:\n config: %x \n", config);
if (config != NULL) { if (config != NULL) {
if (WARN_ON(config->max_regions == 0)) { if (WARN_ON(config->max_regions == 0)) {
retval = -EINVAL; retval = -EINVAL;
...@@ -147,8 +143,10 @@ gate_create_fail: ...@@ -147,8 +143,10 @@ gate_create_fail:
sharedregion_state.cfg.max_regions = SHAREDREGION_MAX_REGIONS_DEFAULT; sharedregion_state.cfg.max_regions = SHAREDREGION_MAX_REGIONS_DEFAULT;
error: error:
printk(KERN_ERR "sharedregion_setup failed status:%x\n", retval);
return retval; return retval;
} }
EXPORT_SYMBOL(sharedregion_setup);
/* /*
* ======== sharedregion_destroy ======== * ======== sharedregion_destroy ========
...@@ -160,7 +158,6 @@ int sharedregion_destroy(void) ...@@ -160,7 +158,6 @@ int sharedregion_destroy(void)
s32 retval = 0; s32 retval = 0;
void *gate_handle = NULL; void *gate_handle = NULL;
gt_0trace(sharedregion_mask, GT_ENTER, "sharedregion_destroy: \n");
if (WARN_ON(sharedregion_state.table == NULL)) { if (WARN_ON(sharedregion_state.table == NULL)) {
retval = -ENODEV; retval = -ENODEV;
goto error; goto error;
...@@ -179,8 +176,10 @@ int sharedregion_destroy(void) ...@@ -179,8 +176,10 @@ int sharedregion_destroy(void)
return 0; return 0;
error: error:
printk(KERN_ERR "sharedregion_destroy failed status:%x\n", retval);
return retval; return retval;
} }
EXPORT_SYMBOL(sharedregion_destroy);
/* /*
* ======== sharedregion_add ======== * ======== sharedregion_add ========
...@@ -197,9 +196,6 @@ int sharedregion_add(u32 index, void *base, u32 len) ...@@ -197,9 +196,6 @@ int sharedregion_add(u32 index, void *base, u32 len)
u16 myproc_id; u16 myproc_id;
bool overlap = false; bool overlap = false;
gt_3trace(sharedregion_mask, GT_ENTER, "sharedregion_add:\n"
" index: %x base: %x,\n len: %x", index, base, len);
if (WARN_ON(sharedregion_state.table == NULL)) { if (WARN_ON(sharedregion_state.table == NULL)) {
retval = -ENODEV; retval = -ENODEV;
goto error; goto error;
...@@ -262,8 +258,10 @@ mem_overlap_error: ...@@ -262,8 +258,10 @@ mem_overlap_error:
mutex_unlock(sharedregion_state.gate_handle); mutex_unlock(sharedregion_state.gate_handle);
error: error:
printk(KERN_ERR "sharedregion_add failed status:%x\n", retval);
return retval; return retval;
} }
EXPORT_SYMBOL(sharedregion_add);
/* /*
* ======== sharedregion_remove ======== * ======== sharedregion_remove ========
...@@ -277,8 +275,6 @@ int sharedregion_remove(u32 index) ...@@ -277,8 +275,6 @@ int sharedregion_remove(u32 index)
struct sharedregion_info *table = NULL; struct sharedregion_info *table = NULL;
s32 retval = 0; s32 retval = 0;
gt_1trace(sharedregion_mask, GT_ENTER,
"sharedregion_remove:\n index: %x \n", index);
if (WARN_ON(sharedregion_state.table == NULL)) { if (WARN_ON(sharedregion_state.table == NULL)) {
retval = -ENODEV; retval = -ENODEV;
goto error; goto error;
...@@ -302,9 +298,10 @@ int sharedregion_remove(u32 index) ...@@ -302,9 +298,10 @@ int sharedregion_remove(u32 index)
return 0; return 0;
error: error:
printk(KERN_ERR "sharedregion_remove failed status:%x\n", retval);
return retval; return retval;
} }
EXPORT_SYMBOL(sharedregion_remove);
/* /*
* ======== sharedregion_get_index ======== * ======== sharedregion_get_index ========
...@@ -320,8 +317,6 @@ int sharedregion_get_index(void *addr) ...@@ -320,8 +317,6 @@ int sharedregion_get_index(void *addr)
u16 myproc_id; u16 myproc_id;
s32 retval = 0; s32 retval = 0;
gt_1trace(sharedregion_mask, GT_ENTER,
"sharedregion_get_index:\n addr: %x \n", addr);
if (WARN_ON(sharedregion_state.table == NULL)) { if (WARN_ON(sharedregion_state.table == NULL)) {
retval = -ENODEV; retval = -ENODEV;
goto exit; goto exit;
...@@ -352,8 +347,10 @@ int sharedregion_get_index(void *addr) ...@@ -352,8 +347,10 @@ int sharedregion_get_index(void *addr)
mutex_unlock(sharedregion_state.gate_handle); mutex_unlock(sharedregion_state.gate_handle);
exit: exit:
printk(KERN_ERR "sharedregion_get_index failed status:%x\n", retval);
return retval; return retval;
} }
EXPORT_SYMBOL(sharedregion_get_index);
/* /*
* ======== sharedregion_get_ptr ======== * ======== sharedregion_get_ptr ========
...@@ -368,8 +365,6 @@ void *sharedregion_get_ptr(u32 *srptr) ...@@ -368,8 +365,6 @@ void *sharedregion_get_ptr(u32 *srptr)
u16 myproc_id; u16 myproc_id;
s32 retval = 0; s32 retval = 0;
gt_1trace(sharedregion_mask, GT_ENTER,
"sharedregion_get_ptr:\n srptr: %x \n", srptr);
if (WARN_ON(sharedregion_state.table == NULL)) if (WARN_ON(sharedregion_state.table == NULL))
goto error; goto error;
...@@ -391,9 +386,11 @@ void *sharedregion_get_ptr(u32 *srptr) ...@@ -391,9 +386,11 @@ void *sharedregion_get_ptr(u32 *srptr)
return ptr; return ptr;
error: error:
printk(KERN_ERR "sharedregion_get_ptr failed \n");
return (void *)NULL; return (void *)NULL;
} }
EXPORT_SYMBOL(sharedregion_get_ptr);
/* /*
* ======== sharedregion_get_srptr ======== * ======== sharedregion_get_srptr ========
...@@ -409,9 +406,6 @@ u32 *sharedregion_get_srptr(void *addr, s32 index) ...@@ -409,9 +406,6 @@ u32 *sharedregion_get_srptr(void *addr, s32 index)
u32 myproc_id; u32 myproc_id;
s32 retval = 0; s32 retval = 0;
gt_2trace(sharedregion_mask, GT_ENTER,
"sharedregion_get_srptr:\n"
"addr: %x, index: %x \n", addr, index);
if (WARN_ON(sharedregion_state.table == NULL)) if (WARN_ON(sharedregion_state.table == NULL))
goto error; goto error;
...@@ -435,8 +429,10 @@ u32 *sharedregion_get_srptr(void *addr, s32 index) ...@@ -435,8 +429,10 @@ u32 *sharedregion_get_srptr(void *addr, s32 index)
return ptr; return ptr;
error: error:
printk(KERN_ERR "sharedregion_get_srptr failed\n");
return (u32 *)NULL; return (u32 *)NULL;
} }
EXPORT_SYMBOL(sharedregion_get_srptr);
/* /*
* ======== sharedregion_get_table_info ======== * ======== sharedregion_get_table_info ========
...@@ -452,10 +448,6 @@ int sharedregion_get_table_info(u32 index, u16 proc_id, ...@@ -452,10 +448,6 @@ int sharedregion_get_table_info(u32 index, u16 proc_id,
u16 proc_count; u16 proc_count;
s32 retval = 0; s32 retval = 0;
gt_3trace(sharedregion_mask, GT_ENTER,
"sharedregion_get_table_info:\n"
"index: %x, proc_id: %x,\n info: %x \n",
index, proc_id, info);
BUG_ON(info != NULL); BUG_ON(info != NULL);
if (WARN_ON(sharedregion_state.table == NULL)) { if (WARN_ON(sharedregion_state.table == NULL)) {
retval = -ENODEV; retval = -ENODEV;
...@@ -482,8 +474,11 @@ int sharedregion_get_table_info(u32 index, u16 proc_id, ...@@ -482,8 +474,11 @@ int sharedregion_get_table_info(u32 index, u16 proc_id,
return 0; return 0;
error: error:
printk(KERN_ERR "sharedregion_get_table_info failed status:%x\n",
retval);
return retval; return retval;
} }
EXPORT_SYMBOL(sharedregion_get_table_info);
/* /*
* ======== sharedregion_set_table_info ======== * ======== sharedregion_set_table_info ========
...@@ -499,10 +494,6 @@ int sharedregion_set_table_info(u32 index, u16 proc_id, ...@@ -499,10 +494,6 @@ int sharedregion_set_table_info(u32 index, u16 proc_id,
u16 proc_count; u16 proc_count;
s32 retval = 0; s32 retval = 0;
gt_3trace(sharedregion_mask, GT_ENTER,
"sharedregion_set_table_info:\n"
"index: %x, proc_id: %x,\n info: %x \n",
index, proc_id, info);
BUG_ON(info != NULL); BUG_ON(info != NULL);
if (WARN_ON(sharedregion_state.table == NULL)) { if (WARN_ON(sharedregion_state.table == NULL)) {
retval = -ENODEV; retval = -ENODEV;
...@@ -529,8 +520,11 @@ int sharedregion_set_table_info(u32 index, u16 proc_id, ...@@ -529,8 +520,11 @@ int sharedregion_set_table_info(u32 index, u16 proc_id,
return 0; return 0;
error: error:
printk(KERN_ERR "sharedregion_set_table_info failed status:%x\n",
retval);
return retval; return retval;
} }
EXPORT_SYMBOL(sharedregion_set_table_info);
/* /*
* ======== Sharedregion_attach ======== * ======== Sharedregion_attach ========
...@@ -583,8 +577,6 @@ void sharedregion_attach(u16 proc_id) ...@@ -583,8 +577,6 @@ void sharedregion_attach(u16 proc_id)
s32 retval = 0; s32 retval = 0;
s32 i; s32 i;
gt_1trace(sharedregion_mask, GT_ENTER,
"sharedregion_attach:\n proc_id: %x\n", proc_id);
if (WARN_ON(sharedregion_state.table == NULL)) if (WARN_ON(sharedregion_state.table == NULL))
goto error; goto error;
...@@ -662,8 +654,7 @@ void sharedregion_attach(u16 proc_id) ...@@ -662,8 +654,7 @@ void sharedregion_attach(u16 proc_id)
error: error:
return; return;
} }
EXPORT_SYMBOL(sharedregion_attach);
/* /*
* ======== Sharedregion_detach ======== * ======== Sharedregion_detach ========
...@@ -696,8 +687,6 @@ void sharedregion_detach(u16 proc_id) ...@@ -696,8 +687,6 @@ void sharedregion_detach(u16 proc_id)
{ {
u16 proc_count; u16 proc_count;
gt_1trace(sharedregion_mask, GT_ENTER,
"sharedRegion_detach:\n proc_id: %x\n", proc_id);
if (WARN_ON(sharedregion_state.table == NULL)) if (WARN_ON(sharedregion_state.table == NULL))
goto error; goto error;
...@@ -708,4 +697,5 @@ void sharedregion_detach(u16 proc_id) ...@@ -708,4 +697,5 @@ void sharedregion_detach(u16 proc_id)
error: error:
return; return;
} }
EXPORT_SYMBOL(sharedregion_detach);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment