Commit 644a3fe2 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 20ce3458
...@@ -239,30 +239,32 @@ int gatepeterson_destroy(void) ...@@ -239,30 +239,32 @@ int gatepeterson_destroy(void)
goto exit; goto exit;
} }
if (atomic_dec_return(&gatepeterson_state.ref_count) if (!(atomic_dec_return(&gatepeterson_state.ref_count)
== GATEPETERSON_MAKE_MAGICSTAMP(0)) { == GATEPETERSON_MAKE_MAGICSTAMP(0))) {
/* Temporarily increment ref_count here. */ retval = 1;
atomic_set(&gatepeterson_state.ref_count, goto exit;
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. */ /* Temporarily increment ref_count here. */
atomic_set(&gatepeterson_state.ref_count, atomic_set(&gatepeterson_state.ref_count,
GATEPETERSON_MAKE_MAGICSTAMP(0)); 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); retval = mutex_lock_interruptible(gatepeterson_state.mod_lock);
if (retval != 0) if (retval != 0)
......
...@@ -576,8 +576,6 @@ int notify_ducatidrv_delete(struct notify_driver_object **handle_ptr) ...@@ -576,8 +576,6 @@ int notify_ducatidrv_delete(struct notify_driver_object **handle_ptr)
WARN_ON(1); WARN_ON(1);
/*FIXME: Exit gracefully */ /*FIXME: Exit gracefully */
} }
omap_mbox_put(ducati_mbox);
ducati_mbox = NULL;
kfree(driver_obj); kfree(driver_obj);
driver_obj = NULL; driver_obj = NULL;
...@@ -624,6 +622,8 @@ int notify_ducatidrv_destroy(void) ...@@ -624,6 +622,8 @@ int notify_ducatidrv_destroy(void)
atomic_set(&(notify_ducatidriver_state.ref_count), atomic_set(&(notify_ducatidriver_state.ref_count),
NOTIFYDRIVERSHM_MAKE_MAGICSTAMP(0)); 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) ...@@ -663,7 +663,6 @@ int notify_ducatidrv_setup(struct notify_ducatidrv_config *cfg)
atomic_cmpmask_and_set(&(notify_ducatidriver_state.ref_count), atomic_cmpmask_and_set(&(notify_ducatidriver_state.ref_count),
NOTIFYDRIVERSHM_MAKE_MAGICSTAMP(0), NOTIFYDRIVERSHM_MAKE_MAGICSTAMP(0),
NOTIFYDRIVERSHM_MAKE_MAGICSTAMP(0)); NOTIFYDRIVERSHM_MAKE_MAGICSTAMP(0));
if (atomic_inc_return(&(notify_ducatidriver_state.ref_count)) != if (atomic_inc_return(&(notify_ducatidriver_state.ref_count)) !=
NOTIFYDRIVERSHM_MAKE_MAGICSTAMP(1u)) { NOTIFYDRIVERSHM_MAKE_MAGICSTAMP(1u)) {
return 1; return 1;
...@@ -673,12 +672,13 @@ int notify_ducatidrv_setup(struct notify_ducatidrv_config *cfg) ...@@ -673,12 +672,13 @@ int notify_ducatidrv_setup(struct notify_ducatidrv_config *cfg)
/* Create a default gate handle here */ /* Create a default gate handle here */
notify_ducatidriver_state.gate_handle = notify_ducatidriver_state.gate_handle =
kmalloc(sizeof(struct mutex), GFP_KERNEL); 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) { if (notify_ducatidriver_state.gate_handle == NULL) {
atomic_set(&(notify_ducatidriver_state.ref_count), atomic_set(&(notify_ducatidriver_state.ref_count),
NOTIFYDRIVERSHM_MAKE_MAGICSTAMP(0)); NOTIFYDRIVERSHM_MAKE_MAGICSTAMP(0));
status = -ENOMEM; status = -ENOMEM;
goto error_exit; goto error_exit;
} else { } else {
memcpy(&notify_ducatidriver_state.cfg, 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