Commit 1e92a8df authored by Arun Gopalakrishnan's avatar Arun Gopalakrishnan Committed by Hari Kanigeri

ARM OMAP4 Syslink IPC NameServer,NameServer Notify Changes

This patch can be used to synk with the syslink drop 2.0.0.6
for above modules
The major changes are
1. The atomic function usage came in the above modules
2. Some logical changes came in some of the fuinctions
   in above modules (nameserver get, nameserver notify get etc.)
Signed-off-by: default avatarArun M G <arunmg@ti.com>
parent 33a77e11
...@@ -23,6 +23,12 @@ ...@@ -23,6 +23,12 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/list.h> #include <linux/list.h>
/*
* NAMESERVER_MODULEID
* Unique module ID
*/
#define NAMESERVER_MODULEID (0xF414)
/* /*
* Instance config-params object. * Instance config-params object.
*/ */
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
struct nameserver_remote_object { struct nameserver_remote_object {
int (*get)(const struct nameserver_remote_object *obj, int (*get)(const struct nameserver_remote_object *obj,
const char *instance_name, const char *name, const char *instance_name, const char *name,
void *value, u32 value_len); /* Function to get data from void *value, u32 value_len, void *reserved);
remote nameserver */ /* Function to get data from remote nameserver */
void *obj; /* Implementation specific object */ void *obj; /* Implementation specific object */
}; };
......
...@@ -21,13 +21,18 @@ ...@@ -21,13 +21,18 @@
#include <linux/types.h> #include <linux/types.h>
/*
* NAMESERVERREMOTENOTIFY_MODULEID
* Unique module ID
*/
#define NAMESERVERREMOTENOTIFY_MODULEID (0x08FD)
/* /*
* Module configuration structure * Module configuration structure
*/ */
struct nameserver_remotenotify_config { struct nameserver_remotenotify_config {
void *gate_handle; u32 reserved;
/* Handle of gate to be used for local thread safety. /* Reserved value (not currently used) */
If provided as NULL, gate handle is created internally. */
}; };
/* /*
...@@ -82,7 +87,7 @@ int nameserver_remotenotify_delete(void **handle); ...@@ -82,7 +87,7 @@ int nameserver_remotenotify_delete(void **handle);
*/ */
int nameserver_remotenotify_get(void *handle, int nameserver_remotenotify_get(void *handle,
const char *instance_name, const char *name, const char *instance_name, const char *name,
u8 *value, u32 value_len, void *reserved); void *value, u32 value_len, void *reserved);
/* /*
* Get the shared memory requirements for the nameserver_remotenotify * Get the shared memory requirements for the nameserver_remotenotify
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <syslink/atomic_linux.h>
#include <nameserver.h> #include <nameserver.h>
#include <multiproc.h> #include <multiproc.h>
...@@ -103,6 +104,9 @@ ...@@ -103,6 +104,9 @@
* *
*/ */
/* Macro to make a correct module magic number with refCount */
#define NAMESERVER_MAKE_MAGICSTAMP(x) ((NAMESERVER_MODULEID << 12u) | (x))
/* /*
* A name/value table entry * A name/value table entry
*/ */
...@@ -135,6 +139,7 @@ struct nameserver_module_object { ...@@ -135,6 +139,7 @@ struct nameserver_module_object {
struct list_head obj_list; struct list_head obj_list;
struct mutex *list_lock; struct mutex *list_lock;
struct nameserver_remote_object **remote_handle_list; struct nameserver_remote_object **remote_handle_list;
atomic_t ref_count;
}; };
/* /*
...@@ -224,6 +229,19 @@ int nameserver_setup(void) ...@@ -224,6 +229,19 @@ int nameserver_setup(void)
s32 retval = 0; s32 retval = 0;
u16 nr_procs = 0; u16 nr_procs = 0;
/* This sets the ref_count variable if not initialized, upper 16 bits is
* written with module Id to ensure correctness of refCount variable
*/
atomic_cmpmask_and_set(&nameserver_state.ref_count,
NAMESERVER_MAKE_MAGICSTAMP(0),
NAMESERVER_MAKE_MAGICSTAMP(0));
if (atomic_inc_return(&nameserver_state.ref_count)
!= NAMESERVER_MAKE_MAGICSTAMP(1)) {
retval = -EEXIST;
goto error;
}
nr_procs = multiproc_get_max_processors(); nr_procs = multiproc_get_max_processors();
list = kmalloc(nr_procs * sizeof(struct nameserver_remote_object *), list = kmalloc(nr_procs * sizeof(struct nameserver_remote_object *),
GFP_KERNEL); GFP_KERNEL);
...@@ -245,8 +263,8 @@ int nameserver_setup(void) ...@@ -245,8 +263,8 @@ int nameserver_setup(void)
return 0; return 0;
error: error:
printk(KERN_ERR "nameserver_setup failed, retval: %x\n", retval);
kfree(list); kfree(list);
printk(KERN_ERR "nameserver_setup failed, retval: %x\n", retval);
return retval; return retval;
} }
EXPORT_SYMBOL(nameserver_setup); EXPORT_SYMBOL(nameserver_setup);
...@@ -261,6 +279,13 @@ int nameserver_destroy(void) ...@@ -261,6 +279,13 @@ int nameserver_destroy(void)
s32 retval = 0; s32 retval = 0;
struct mutex *lock = NULL; struct mutex *lock = NULL;
if (WARN_ON(atomic_cmpmask_and_lt(&(nameserver_state.ref_count),
NAMESERVER_MAKE_MAGICSTAMP(0),
NAMESERVER_MAKE_MAGICSTAMP(1)) == true)) {
retval = -ENODEV;
goto exit;
}
if (WARN_ON(nameserver_state.list_lock == NULL)) { if (WARN_ON(nameserver_state.list_lock == NULL)) {
retval = -ENODEV; retval = -ENODEV;
goto exit; goto exit;
...@@ -782,8 +807,7 @@ error: ...@@ -782,8 +807,7 @@ error:
mutex_unlock(temp_obj->gate_handle); mutex_unlock(temp_obj->gate_handle);
exit: exit:
printk(KERN_ERR "nameserver_get_local failed status:%x \n", printk(KERN_ERR "nameserver_get_local entry not found!\n");
retval);
return retval; return retval;
} }
EXPORT_SYMBOL(nameserver_get_local); EXPORT_SYMBOL(nameserver_get_local);
...@@ -824,10 +848,12 @@ int nameserver_get(void *handle, const char *name, ...@@ -824,10 +848,12 @@ int nameserver_get(void *handle, const char *name,
/* Skip current processor */ /* Skip current processor */
if (i == local_proc_id) if (i == local_proc_id)
continue; continue;
retval = nameserver_remote_get( retval = nameserver_remote_get(
nameserver_state.remote_handle_list[i], nameserver_state.remote_handle_list[i],
temp_obj->name, name, buffer, length); temp_obj->name, name, buffer, length);
if (retval == 0) /* Got the value */ if (retval > 0 || ((retval < 0) &&
(retval != -ENOENT))) /* Got the value */
break; break;
} }
goto exit; goto exit;
...@@ -848,7 +874,8 @@ int nameserver_get(void *handle, const char *name, ...@@ -848,7 +874,8 @@ int nameserver_get(void *handle, const char *name,
retval = nameserver_remote_get( retval = nameserver_remote_get(
nameserver_state.remote_handle_list[proc_id[i]], nameserver_state.remote_handle_list[proc_id[i]],
temp_obj->name, name, buffer, length); temp_obj->name, name, buffer, length);
if (retval == 0) if (retval > 0 || ((retval < 0) &&
(retval != -ENOENT))) /* Got the value */
break; break;
} }
} }
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <gt.h>
#include <nameserver_remote.h> #include <nameserver_remote.h>
/* /*
...@@ -31,20 +30,13 @@ int nameserver_remote_get(const struct nameserver_remote_object *handle, ...@@ -31,20 +30,13 @@ int nameserver_remote_get(const struct nameserver_remote_object *handle,
{ {
s32 retval = 0; s32 retval = 0;
if (WARN_ON(instance_name == NULL)) {
gt_0trace(ns_debugmask, GT_ENTER, "nameserver_remote_get\n");
if (handle == NULL || instance_name == NULL ||
name == NULL || value == NULL) {
gt_5trace(ns_debugmask, GT_6CLASS,
"nameserver_remote_get: invalid argument!\n"
"instance_name: %s,\n name: %s,\n"
"handle: %x, value: %x, value_len: %x\n",
instance_name, name, handle, value, value_len);
retval = -EINVAL; retval = -EINVAL;
goto exit; goto exit;
} }
retval = handle->get(handle, instance_name, name, value, value_len); retval = handle->get(handle, instance_name,
name, value, value_len, NULL);
exit: exit:
return retval; return retval;
......
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