Commit 497ea6dc authored by Suman Anna's avatar Suman Anna Committed by Hari Kanigeri

SYSLINK: ipc - fix messageq bugs

This patch resolves the bugs found during the validation of
messageQ sample. The patch has temporary workarounds by assigning
the procIds for SysM3 and AppM3 as 1.
Signed-off-by: default avatarJohn Jayan <x00jayan@ti.com>
Signed-off-by: default avatarSuman Anna <s-anna@ti.com>
parent dd1a8b6b
...@@ -421,7 +421,6 @@ int messageq_destroy(void) ...@@ -421,7 +421,6 @@ int messageq_destroy(void)
/* Delete any Message Queues that have not been deleted so far. */ /* Delete any Message Queues that have not been deleted so far. */
for (i = 0; i < messageq_state.num_queues; i++) { for (i = 0; i < messageq_state.num_queues; i++) {
BUG_ON(messageq_state.queues[i] == NULL);
if (messageq_state.queues[i] != NULL) if (messageq_state.queues[i] != NULL)
messageq_delete(&(messageq_state.queues[i])); messageq_delete(&(messageq_state.queues[i]));
} }
...@@ -604,13 +603,14 @@ void *messageq_create(char *name, const struct messageq_params *params) ...@@ -604,13 +603,14 @@ void *messageq_create(char *name, const struct messageq_params *params)
status, "Failed to create synchronizer semaphore"); status, "Failed to create synchronizer semaphore");
goto semaphore_create_fail; goto semaphore_create_fail;
} else { } else {
sema_init(handle->synchronizer, 1); sema_init(handle->synchronizer, 0);
} }
if (name != NULL) { if (name != NULL) {
nameserver_add_uint32(messageq_state.ns_handle, name, nameserver_add_uint32(messageq_state.ns_handle, name,
handle->queue); handle->queue);
} }
goto exit;
semaphore_create_fail: semaphore_create_fail:
if (handle->name != NULL) if (handle->name != NULL)
...@@ -946,7 +946,7 @@ messageq_msg messageq_alloc(u16 heap_id, u32 size) ...@@ -946,7 +946,7 @@ messageq_msg messageq_alloc(u16 heap_id, u32 size)
"Module was not initialized!"); "Module was not initialized!");
goto exit; goto exit;
} }
if (WARN_ON(heap_id < messageq_state.num_heaps)) { if (WARN_ON(heap_id >= messageq_state.num_heaps)) {
/*! @retval NULL Heap id is invalid */ /*! @retval NULL Heap id is invalid */
gt_2trace(messageq_dbgmask, GT_4CLASS, "messageq_alloc", gt_2trace(messageq_dbgmask, GT_4CLASS, "messageq_alloc",
MESSAGEQ_E_INVALIDHEAPID, MESSAGEQ_E_INVALIDHEAPID,
...@@ -1008,7 +1008,7 @@ int messageq_free(messageq_msg msg) ...@@ -1008,7 +1008,7 @@ int messageq_free(messageq_msg msg)
status = -EINVAL; status = -EINVAL;
goto exit; goto exit;
} }
if (msg->heap_id < messageq_state.num_heaps) { if (msg->heap_id >= messageq_state.num_heaps) {
status = MESSAGEQ_E_INVALIDHEAPID; status = MESSAGEQ_E_INVALIDHEAPID;
/*! @retval MESSAGEQ_E_INVALIDHEAPID /*! @retval MESSAGEQ_E_INVALIDHEAPID
* Heap id is invalid */ * Heap id is invalid */
...@@ -1050,6 +1050,11 @@ int messageq_put(u32 queue_id, messageq_msg msg) ...@@ -1050,6 +1050,11 @@ int messageq_put(u32 queue_id, messageq_msg msg)
u32 priority; u32 priority;
int key; int key;
/* FIXME: Remove the SysM3 & AppM3 workaround */
if (dst_proc_id == 2 || dst_proc_id == 3)
dst_proc_id = 1;
else
dst_proc_id = 0;
gt_2trace(messageq_dbgmask, GT_ENTER, "messageq_put", queue_id, msg); gt_2trace(messageq_dbgmask, GT_ENTER, "messageq_put", queue_id, msg);
BUG_ON(msg == NULL); BUG_ON(msg == NULL);
...@@ -1064,6 +1069,11 @@ int messageq_put(u32 queue_id, messageq_msg msg) ...@@ -1064,6 +1069,11 @@ int messageq_put(u32 queue_id, messageq_msg msg)
msg->dst_id = (u16)(queue_id); msg->dst_id = (u16)(queue_id);
msg->dst_proc = (u16)(queue_id >> 16); msg->dst_proc = (u16)(queue_id >> 16);
/* FIXME: Remove the SysM3 & AppM3 workaround */
if (msg->dst_proc == 2 || msg->dst_proc == 3)
msg->dst_proc = 1;
else
msg->dst_proc = 0;
if (dst_proc_id != multiproc_get_id(NULL)) { if (dst_proc_id != multiproc_get_id(NULL)) {
if (dst_proc_id >= multiproc_get_max_processors()) { if (dst_proc_id >= multiproc_get_max_processors()) {
/*! @retval MESSAGEQ_E_INVALIDPROCID /*! @retval MESSAGEQ_E_INVALIDPROCID
......
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