Commit 52cf81f3 authored by Arun Gopalakrishnan's avatar Arun Gopalakrishnan Committed by Hari Kanigeri

ARM OMAP4 Syslink IPC heapbuf destroy fix

This fixes the hang in heapbuf_destroy function.
The root cause of the issue was in heapbuf_close,
that was fixed with reference to latest syslink
code
Signed-off-by: default avatarArun M G <arunmg@ti.com>
parent df5cd95c
...@@ -183,29 +183,24 @@ int heapbuf_destroy(void) ...@@ -183,29 +183,24 @@ int heapbuf_destroy(void)
{ {
s32 retval = 0; s32 retval = 0;
struct mutex *lock = NULL; struct mutex *lock = NULL;
/*struct heapbuf_obj *obj = NULL;*/ struct heapbuf_obj *obj = NULL;
if (WARN_ON(heapbuf_state.nshandle == NULL)) { if (WARN_ON(heapbuf_state.nshandle == NULL)) {
retval = -ENODEV; retval = -ENODEV;
goto error; goto error;
} }
#if 0 /* Check if any heapbuf instances have not been deleted/closed so far.
/* Check if any heapbuf instances have not been deleted so far. * if there any, delete or close them
* if not, delete them or close
*/ */
list_for_each_entry(obj, &heapbuf_state.obj_list, list_elem) { list_for_each_entry(obj, &heapbuf_state.obj_list, list_elem) {
if (obj->owner->proc_id == multiproc_get_id(NULL)) if (obj->owner->proc_id == multiproc_get_id(NULL))
heapbuf_delete(&obj->free_list); heapbuf_delete(&obj->top);
else else
heapbuf_close(&obj->free_list); heapbuf_close(obj->top);
}
#endif
/* If a heapbuf instance exist, do not proceed IS THIS OK */ if (list_empty(&heapbuf_state.obj_list))
if (!list_empty(&heapbuf_state.obj_list)) { break;
retval = -EBUSY;
goto error;
} }
retval = nameserver_delete(&heapbuf_state.nshandle); retval = nameserver_delete(&heapbuf_state.nshandle);
...@@ -306,19 +301,19 @@ static void *_heapbuf_create(const struct heapbuf_params *params, ...@@ -306,19 +301,19 @@ static void *_heapbuf_create(const struct heapbuf_params *params,
listmp_sharedmemory_shared_memreq(&listmp_params); listmp_sharedmemory_shared_memreq(&listmp_params);
listmp_params.lock_handle = params->lock_handle; listmp_params.lock_handle = params->lock_handle;
obj->lock_handle = params->lock_handle; obj->lock_handle = params->lock_handle;
if (createflag == true) /* Assign the memory with proper cache line padding */
obj->free_list = listmp_sharedmemory_create(&listmp_params); obj->attrs = (struct heapbuf_attrs *) params->shared_addr;
else
if (createflag == false)
listmp_sharedmemory_open(&obj->free_list, &listmp_params); listmp_sharedmemory_open(&obj->free_list, &listmp_params);
else {
obj->free_list = listmp_sharedmemory_create(&listmp_params);
if (obj->free_list == NULL) { if (obj->free_list == NULL) {
retval = -ENOMEM; retval = -ENOMEM;
goto listmp_error; goto listmp_error;
} }
/* Assign the memory with proper cache line padding */
obj->attrs = (struct heapbuf_attrs *) params->shared_addr;
if (createflag == true) {
obj->attrs->version = HEAPBUF_VERSION; obj->attrs->version = HEAPBUF_VERSION;
obj->attrs->num_free_blocks = params->num_blocks; obj->attrs->num_free_blocks = params->num_blocks;
obj->attrs->min_free_blocks = params->num_blocks; obj->attrs->min_free_blocks = params->num_blocks;
...@@ -345,7 +340,6 @@ static void *_heapbuf_create(const struct heapbuf_params *params, ...@@ -345,7 +340,6 @@ static void *_heapbuf_create(const struct heapbuf_params *params,
/* Populate the params member */ /* Populate the params member */
memcpy(&obj->params, params, sizeof(struct heapbuf_params)); memcpy(&obj->params, params, sizeof(struct heapbuf_params));
if (createflag == true) {
if (params->name != NULL) { if (params->name != NULL) {
obj->params.name = kmalloc(strlen(params->name) + 1, obj->params.name = kmalloc(strlen(params->name) + 1,
GFP_KERNEL); GFP_KERNEL);
...@@ -357,7 +351,6 @@ static void *_heapbuf_create(const struct heapbuf_params *params, ...@@ -357,7 +351,6 @@ static void *_heapbuf_create(const struct heapbuf_params *params,
strncpy(obj->params.name, params->name, strncpy(obj->params.name, params->name,
strlen(params->name) + 1); strlen(params->name) + 1);
} }
}
/* Update processor information */ /* Update processor information */
obj->owner = kmalloc(sizeof(struct heapbuf_proc_attrs), GFP_KERNEL); obj->owner = kmalloc(sizeof(struct heapbuf_proc_attrs), GFP_KERNEL);
...@@ -555,11 +548,8 @@ int heapbuf_open(void **hphandle, ...@@ -555,11 +548,8 @@ int heapbuf_open(void **hphandle,
s32 retval = 0; s32 retval = 0;
u16 myproc_id; u16 myproc_id;
gt_1trace(heap_debugmask, GT_ENTER,
"heapbuf_open:\n params: %x\n", params);
BUG_ON(hphandle == NULL); BUG_ON(hphandle == NULL);
BUG_ON(params == NULL); BUG_ON(params == NULL);
if (WARN_ON(heapbuf_state.nshandle == NULL)) { if (WARN_ON(heapbuf_state.nshandle == NULL)) {
retval = -ENODEV; retval = -ENODEV;
goto error; goto error;
...@@ -618,7 +608,6 @@ int heapbuf_close(void *hphandle) ...@@ -618,7 +608,6 @@ int heapbuf_close(void *hphandle)
{ {
struct heap_object *handle = NULL; struct heap_object *handle = NULL;
struct heapbuf_obj *obj = NULL; struct heapbuf_obj *obj = NULL;
struct heapbuf_params *params = NULL;
s32 retval = 0; s32 retval = 0;
u16 myproc_id = 0; u16 myproc_id = 0;
...@@ -639,20 +628,17 @@ int heapbuf_close(void *hphandle) ...@@ -639,20 +628,17 @@ int heapbuf_close(void *hphandle)
goto error; goto error;
myproc_id = multiproc_get_id(NULL); myproc_id = multiproc_get_id(NULL);
if ((obj->remote->proc_id == myproc_id) /* opening an instance created locally */
&& (obj->remote->open_count == 0)) { if (obj->owner->proc_id == myproc_id) {
list_del(&obj->list_elem); if (obj->owner->open_count > 1)
params = (struct heapbuf_params *)&obj->params; obj->owner->open_count--;
if (params->name != NULL) {
retval = nameserver_remove(heapbuf_state.nshandle,
params->name);
if (unlikely(retval != 0))
goto error;
}
kfree(params->name); goto owner_close_done;
} } else
obj->remote->open_count--;
if (obj->remote->open_count == 0) {
list_del(&obj->list_elem);
listmp_sharedmemory_close((listmp_sharedmemory_handle *) listmp_sharedmemory_close((listmp_sharedmemory_handle *)
obj->free_list); obj->free_list);
kfree(obj->owner); kfree(obj->owner);
...@@ -660,6 +646,9 @@ int heapbuf_close(void *hphandle) ...@@ -660,6 +646,9 @@ int heapbuf_close(void *hphandle)
kfree(obj); kfree(obj);
kfree(handle); kfree(handle);
handle = NULL; handle = NULL;
}
owner_close_done:
mutex_unlock(heapbuf_state.list_lock); mutex_unlock(heapbuf_state.list_lock);
return 0; return 0;
...@@ -869,7 +858,7 @@ int heapbuf_get_extended_stats(void *hphandle, ...@@ -869,7 +858,7 @@ int heapbuf_get_extended_stats(void *hphandle,
mutex_unlock(heapbuf_state.list_lock); mutex_unlock(heapbuf_state.list_lock);
error: error:
printk(KERN_ERR "heapbuf_get_extended_stats failed status: %x\n", printk(KERN_ERR "heapbuf_get_extended_stats status: %x\n",
retval); retval);
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