Commit 1a11912a authored by Simon Que's avatar Simon Que Committed by Hari Kanigeri

SYSLINK: ipc - Fixed cleanup order of operations

Syslink destroy phase was failing because of incorrect order of
operations in gatepeterson and notify ducati.
Signed-off-by: default avatarSimon Que <sque@ti.com>
parent d07bcdda
......@@ -239,30 +239,32 @@ int gatepeterson_destroy(void)
goto exit;
}
if (atomic_dec_return(&gatepeterson_state.ref_count)
== GATEPETERSON_MAKE_MAGICSTAMP(0)) {
/* Temporarily increment ref_count here. */
atomic_set(&gatepeterson_state.ref_count,
GATEPETERSON_MAKE_MAGICSTAMP(1));
/* Check if any gatepeterson instances have not been
* ideleted/closed so far, if there any, delete or close them
*/
list_for_each_entry(obj, &gatepeterson_state.obj_list, elem) {
if (obj->attrs->creator_proc_id ==
multiproc_get_id(NULL))
gatepeterson_delete(&obj->top);
else
gatepeterson_close(&obj->top);
if (list_empty(&gatepeterson_state.obj_list))
break;
}
if (!(atomic_dec_return(&gatepeterson_state.ref_count)
== GATEPETERSON_MAKE_MAGICSTAMP(0))) {
retval = 1;
goto exit;
}
/* Again reset ref_count. */
atomic_set(&gatepeterson_state.ref_count,
GATEPETERSON_MAKE_MAGICSTAMP(0));
/* Temporarily increment ref_count here. */
atomic_set(&gatepeterson_state.ref_count,
GATEPETERSON_MAKE_MAGICSTAMP(1));
/* Check if any gatepeterson instances have not been
* ideleted/closed so far, if there any, delete or close them
*/
list_for_each_entry(obj, &gatepeterson_state.obj_list, elem) {
if (obj->attrs->creator_proc_id ==
multiproc_get_id(NULL))
gatepeterson_delete(&obj->top);
else
gatepeterson_close(&obj->top);
if (list_empty(&gatepeterson_state.obj_list))
break;
}
/* Again reset ref_count. */
atomic_set(&gatepeterson_state.ref_count,
GATEPETERSON_MAKE_MAGICSTAMP(0));
retval = mutex_lock_interruptible(gatepeterson_state.mod_lock);
if (retval != 0)
......
......@@ -576,8 +576,6 @@ int notify_ducatidrv_delete(struct notify_driver_object **handle_ptr)
WARN_ON(1);
/*FIXME: Exit gracefully */
}
omap_mbox_put(ducati_mbox);
ducati_mbox = NULL;
kfree(driver_obj);
driver_obj = NULL;
......@@ -624,6 +622,8 @@ int notify_ducatidrv_destroy(void)
atomic_set(&(notify_ducatidriver_state.ref_count),
NOTIFYDRIVERSHM_MAKE_MAGICSTAMP(0));
omap_mbox_put(ducati_mbox);
ducati_mbox = NULL;
}
......@@ -663,7 +663,6 @@ int notify_ducatidrv_setup(struct notify_ducatidrv_config *cfg)
atomic_cmpmask_and_set(&(notify_ducatidriver_state.ref_count),
NOTIFYDRIVERSHM_MAKE_MAGICSTAMP(0),
NOTIFYDRIVERSHM_MAKE_MAGICSTAMP(0));
if (atomic_inc_return(&(notify_ducatidriver_state.ref_count)) !=
NOTIFYDRIVERSHM_MAKE_MAGICSTAMP(1u)) {
return 1;
......@@ -673,12 +672,13 @@ int notify_ducatidrv_setup(struct notify_ducatidrv_config *cfg)
/* Create a default gate handle here */
notify_ducatidriver_state.gate_handle =
kmalloc(sizeof(struct mutex), GFP_KERNEL);
mutex_init(notify_ducatidriver_state.gate_handle);
mutex_init(notify_ducatidriver_state.gate_handle);
if (notify_ducatidriver_state.gate_handle == NULL) {
atomic_set(&(notify_ducatidriver_state.ref_count),
NOTIFYDRIVERSHM_MAKE_MAGICSTAMP(0));
status = -ENOMEM;
goto error_exit;
} else {
memcpy(&notify_ducatidriver_state.cfg,
......
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