Skip to content

Commit 128f23a

Browse files
Shahid AkhtarLuis Henriques
authored andcommitted
SYSLINK: IPC - changes for messageQ unblock
Added a new command in messageq to unblock. A new variable is also added to the messageq object to unblock the messageq. The purpose of unblock is to unblock the messageq_get() when it is pending for a new message with MessageQ_FOREVER timeout. The messageq_unblock is intended for use before deletion of messageq and it unblocks messageq_get() with MessageQ_FOREVER timeout value for termination. Signed-off-by: Shahid Akhtar <[email protected]>
1 parent 86c1d0e commit 128f23a

File tree

5 files changed

+77
-2
lines changed

5 files changed

+77
-2
lines changed

arch/arm/plat-omap/include/syslink/ipc_ioctl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ enum ipc_command_count {
3434
SHAREDREGION_CMD_NOS = 13,
3535
GATEMP_CMD_NOS = 13,
3636
LISTMP_CMD_NOS = 19,
37-
MESSAGEQ_CMD_NOS = 18,
37+
MESSAGEQ_CMD_NOS = 19,
3838
IPC_CMD_NOS = 5,
3939
SYSMEMMGR_CMD_NOS = 6,
4040
HEAPMEMMP_CMD_NOS = 15,

arch/arm/plat-omap/include/syslink/messageq.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@
166166
* @brief Operation is successful.
167167
*/
168168
#define MESSAGEQ_E_CANNOTFREESTATICMSG -18
169+
/*!
170+
* @def MESSAGEQ_E_UNBLOCKED
171+
* @brief The resource is now unblocked
172+
*/
173+
#define MESSAGEQ_E_UNBLOCKED -20
169174

170175

171176
/* =============================================================================
@@ -436,5 +441,7 @@ int messageq_register_transport(void *imessageq_transport_handle,
436441
/* Unregister a transport with MessageQ */
437442
void messageq_unregister_transport(u16 proc_id, u32 priority);
438443

444+
/* Unblock messageq to prevent waiting forever */
445+
int messageq_unblock(void *messageq_handle);
439446

440447
#endif /* _MESSAGEQ_H_ */

arch/arm/plat-omap/include/syslink/messageq_ioctl.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ enum messageq_drv_cmd {
5050
MESSAGEQ_ATTACH,
5151
MESSAGEQ_DETACH,
5252
MESSAGEQ_GET,
53-
MESSAGEQ_SHAREDMEMREQ
53+
MESSAGEQ_SHAREDMEMREQ,
54+
MESSAGEQ_UNBLOCK
5455
};
5556

5657
/* ----------------------------------------------------------------------------
@@ -120,6 +121,11 @@ enum messageq_drv_cmd {
120121
_IOWR(MESSAGEQ_IOC_MAGIC, MESSAGEQ_PUT, \
121122
struct messageq_cmd_args)
122123

124+
/* Command for messageq_unblock */
125+
#define CMD_MESSAGEQ_UNBLOCK \
126+
_IOWR(MESSAGEQ_IOC_MAGIC, MESSAGEQ_UNBLOCK, \
127+
struct messageq_cmd_args)
128+
123129
/* Command for messageq_register_heap */
124130
#define CMD_MESSAGEQ_REGISTERHEAP \
125131
_IOWR(MESSAGEQ_IOC_MAGIC, MESSAGEQ_REGISTERHEAP, \
@@ -237,6 +243,11 @@ struct messageq_cmd_args {
237243
struct {
238244
u16 remote_proc_id;
239245
} detach;
246+
247+
struct {
248+
void *messageq_handle;
249+
} unblock;
250+
240251
} args;
241252

242253
int api_status;

drivers/dsp/syslink/multicore_ipc/messageq.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ struct messageq_object {
179179
/* NameServer key */
180180
struct semaphore *synchronizer;
181181
/* Semaphore used for synchronizing message events */
182+
bool unblocked;
183+
/* Whether MessageQ is unblocked */
182184
};
183185

184186

@@ -573,6 +575,9 @@ void *messageq_create(char *name, const struct messageq_params *params)
573575
}
574576
}
575577

578+
/* Whether messageq is blocked */
579+
obj->unblocked = false;
580+
576581
exit:
577582
if (unlikely(status < 0)) {
578583
messageq_delete((void **)&obj);
@@ -814,6 +819,12 @@ int messageq_get(void *messageq_handle, messageq_msg *msg,
814819
*msg = NULL;
815820
break;
816821
}
822+
if (obj->unblocked) {
823+
*msg = NULL;
824+
status = MESSAGEQ_E_UNBLOCKED;
825+
obj->unblocked = false;
826+
break;
827+
}
817828
}
818829
status = mutex_lock_interruptible(
819830
messageq_module->gate_handle);
@@ -1196,6 +1207,36 @@ int messageq_unregister_heap(u16 heap_id)
11961207
}
11971208
EXPORT_SYMBOL(messageq_unregister_heap);
11981209

1210+
/* Unblock messageq to prevent waiting forever */
1211+
int messageq_unblock(void *messageq_handle)
1212+
{
1213+
int status = 0;
1214+
struct messageq_object *obj = (struct messageq_object *)messageq_handle;
1215+
1216+
if (WARN_ON(unlikely(atomic_cmpmask_and_lt(
1217+
&(messageq_module->ref_count),
1218+
MESSAGEQ_MAKE_MAGICSTAMP(0),
1219+
MESSAGEQ_MAKE_MAGICSTAMP(1)) == true))) {
1220+
status = -ENODEV;
1221+
goto exit;
1222+
}
1223+
if (WARN_ON(unlikely(obj == NULL)) || (WARN_ON(unlikely(
1224+
obj->synchronizer == NULL)))) {
1225+
status = -EINVAL;
1226+
goto exit;
1227+
}
1228+
/* Set instance to 'unblocked' state */
1229+
obj->unblocked = true;
1230+
up(obj->synchronizer);
1231+
1232+
exit:
1233+
if (status < 0) {
1234+
pr_err("messageq_unblock failed! status = 0x%x\n",
1235+
status);
1236+
}
1237+
return status;
1238+
}
1239+
11991240
/* Register a transport */
12001241
int messageq_register_transport(void *messageq_transportshm_handle,
12011242
u16 proc_id, u32 priority)

drivers/dsp/syslink/multicore_ipc/messageq_ioctl.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,18 @@ static inline int messageq_ioctl_get_config(struct messageq_cmd_args *cargs)
393393
return retval;
394394
}
395395

396+
/*
397+
* ======== messageq_ioctl_unblock ========
398+
* Purpose:
399+
* This ioctl interface to messageq_unblock function
400+
*/
401+
static inline int messageq_ioctl_unblock(struct messageq_cmd_args *cargs)
402+
{
403+
cargs->api_status = messageq_unblock(cargs->args.unblock.messageq_handle);
404+
405+
return 0;
406+
}
407+
396408
/*
397409
* ======== messageq_ioctl_setup ========
398410
* Purpose:
@@ -631,6 +643,10 @@ int messageq_ioctl(struct inode *inode, struct file *filp,
631643
status = messageq_ioctl_get_config(&cargs);
632644
break;
633645

646+
case CMD_MESSAGEQ_UNBLOCK:
647+
status = messageq_ioctl_unblock(&cargs);
648+
break;
649+
634650
case CMD_MESSAGEQ_SETUP:
635651
status = messageq_ioctl_setup(&cargs);
636652
if (status >= 0)

0 commit comments

Comments
 (0)