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 @@
#include <linux/types.h>
#include <linux/list.h>
/*
* NAMESERVER_MODULEID
* Unique module ID
*/
#define NAMESERVER_MODULEID (0xF414)
/*
* Instance config-params object.
*/
......
......@@ -24,8 +24,8 @@
struct nameserver_remote_object {
int (*get)(const struct nameserver_remote_object *obj,
const char *instance_name, const char *name,
void *value, u32 value_len); /* Function to get data from
remote nameserver */
void *value, u32 value_len, void *reserved);
/* Function to get data from remote nameserver */
void *obj; /* Implementation specific object */
};
......
......@@ -21,13 +21,18 @@
#include <linux/types.h>
/*
* NAMESERVERREMOTENOTIFY_MODULEID
* Unique module ID
*/
#define NAMESERVERREMOTENOTIFY_MODULEID (0x08FD)
/*
* Module configuration structure
*/
struct nameserver_remotenotify_config {
void *gate_handle;
/* Handle of gate to be used for local thread safety.
If provided as NULL, gate handle is created internally. */
u32 reserved;
/* Reserved value (not currently used) */
};
/*
......@@ -82,7 +87,7 @@ int nameserver_remotenotify_delete(void **handle);
*/
int nameserver_remotenotify_get(void *handle,
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
......
......@@ -22,6 +22,7 @@
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/slab.h>
#include <syslink/atomic_linux.h>
#include <nameserver.h>
#include <multiproc.h>
......@@ -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
*/
......@@ -135,6 +139,7 @@ struct nameserver_module_object {
struct list_head obj_list;
struct mutex *list_lock;
struct nameserver_remote_object **remote_handle_list;
atomic_t ref_count;
};
/*
......@@ -224,6 +229,19 @@ int nameserver_setup(void)
s32 retval = 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();
list = kmalloc(nr_procs * sizeof(struct nameserver_remote_object *),
GFP_KERNEL);
......@@ -245,8 +263,8 @@ int nameserver_setup(void)
return 0;
error:
printk(KERN_ERR "nameserver_setup failed, retval: %x\n", retval);
kfree(list);
printk(KERN_ERR "nameserver_setup failed, retval: %x\n", retval);
return retval;
}
EXPORT_SYMBOL(nameserver_setup);
......@@ -261,6 +279,13 @@ int nameserver_destroy(void)
s32 retval = 0;
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)) {
retval = -ENODEV;
goto exit;
......@@ -782,8 +807,7 @@ error:
mutex_unlock(temp_obj->gate_handle);
exit:
printk(KERN_ERR "nameserver_get_local failed status:%x \n",
retval);
printk(KERN_ERR "nameserver_get_local entry not found!\n");
return retval;
}
EXPORT_SYMBOL(nameserver_get_local);
......@@ -824,10 +848,12 @@ int nameserver_get(void *handle, const char *name,
/* Skip current processor */
if (i == local_proc_id)
continue;
retval = nameserver_remote_get(
nameserver_state.remote_handle_list[i],
temp_obj->name, name, buffer, length);
if (retval == 0) /* Got the value */
if (retval > 0 || ((retval < 0) &&
(retval != -ENOENT))) /* Got the value */
break;
}
goto exit;
......@@ -848,7 +874,8 @@ int nameserver_get(void *handle, const char *name,
retval = nameserver_remote_get(
nameserver_state.remote_handle_list[proc_id[i]],
temp_obj->name, name, buffer, length);
if (retval == 0)
if (retval > 0 || ((retval < 0) &&
(retval != -ENOENT))) /* Got the value */
break;
}
}
......
......@@ -17,7 +17,6 @@
#include <linux/types.h>
#include <linux/slab.h>
#include <gt.h>
#include <nameserver_remote.h>
/*
......@@ -31,20 +30,13 @@ int nameserver_remote_get(const struct nameserver_remote_object *handle,
{
s32 retval = 0;
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);
if (WARN_ON(instance_name == NULL)) {
retval = -EINVAL;
goto exit;
}
retval = handle->get(handle, instance_name, name, value, value_len);
retval = handle->get(handle, instance_name,
name, value, value_len, NULL);
exit:
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