From adaebb3e43b726d899989172e009853b697a2aad Mon Sep 17 00:00:00 2001 From: "Dobrowolski, PawelX" Date: Wed, 31 Aug 2022 10:14:23 +0200 Subject: [PATCH] library manager: allow sending IPC message if buffer is already prepared. System service functionality used by 3rd party modules expects that IPC data buffer will be filled with data during notification preparation. To avoid additional data copy, provide message buffer directly to module. This requires that ipc_msg_send() function will not fail if source data pointer will be equal to destination one. Signed-off-by: Stelter, Jaroslaw Signed-off-by: Dobrowolski, PawelX --- src/ipc/ipc-common.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ipc/ipc-common.c b/src/ipc/ipc-common.c index 2fe2d4070..b98eb998c 100644 --- a/src/ipc/ipc-common.c +++ b/src/ipc/ipc-common.c @@ -190,8 +190,9 @@ void ipc_msg_send(struct ipc_msg *msg, void *data, bool high_priority) key = k_spin_lock(&ipc->lock); - /* copy mailbox data to message */ - if (msg->tx_size > 0 && msg->tx_size < SOF_IPC_MSG_MAX_SIZE) { + /* copy mailbox data to message if not already copied */ + if ((msg->tx_size > 0 && msg->tx_size < SOF_IPC_MSG_MAX_SIZE) && + msg->tx_data != data) { ret = memcpy_s(msg->tx_data, msg->tx_size, data, msg->tx_size); assert(!ret); }