Skip to content

Commit 8ad171f

Browse files
committed
modules: hal_nordic: nrfs: Optimize communication
It is not needed to use always the system work queue to send a message over IPC. In thread context IPC service can be called directly. It speeds up the communication and allows to use nrfs from the system work queue. Legacy approach could easily lead to the deadlock if user would call nrfs from work queue and pend on semaphore until response is received. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent fcbf70f commit 8ad171f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

modules/hal_nordic/nrfs/backends/nrfs_backend_ipc_service.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ nrfs_err_t nrfs_backend_send(void *message, size_t size)
176176

177177
nrfs_err_t nrfs_backend_send_ex(void *message, size_t size, k_timeout_t timeout, bool high_prio)
178178
{
179-
if (size <= MAX_PACKET_DATA_SIZE) {
179+
if (!k_is_in_isr() && nrfs_backend_connected()) {
180+
return ipc_service_send(&ipc_cpusys_channel_config.ipc_ept, message, size) ?
181+
NRFS_SUCCESS : NRFS_ERR_IPC;
182+
} else if (size <= MAX_PACKET_DATA_SIZE) {
180183
int err;
181184
struct ipc_data_packet tx_data;
182185

0 commit comments

Comments
 (0)