ipc: Added const specifier to protect IPC message content in sending functions.

Added the const specifier to protect the message passed to
ipc_platform_send_msg and ipc_prepare_to_send functions. The deletion of
the message from the list has been moved to ipc_send_queued_msg function.

Signed-off-by: Adrian Warecki <adrianx.warecki@intel.com>
This commit is contained in:
Adrian Warecki 2022-02-18 15:30:49 +01:00 committed by Liam Girdwood
parent 6b2e90ea0f
commit 42025e551a
15 changed files with 24 additions and 24 deletions

View File

@ -166,7 +166,7 @@ void ipc_platform_complete_cmd(struct ipc *ipc)
}
}
int ipc_platform_send_msg(struct ipc_msg *msg)
int ipc_platform_send_msg(const struct ipc_msg *msg)
{
int ret = 0;
acp_sw_intr_trig_t sw_intr_trig;
@ -198,7 +198,7 @@ int ipc_platform_send_msg(struct ipc_msg *msg)
goto out;
/* Write new message in the mailbox */
mailbox_dspbox_write(0, msg->tx_data, msg->tx_size);
list_item_del(&msg->list);
/* Need to set DSP message flag */
sof_ipc_dsp_msg_set();
/* now interrupt host to tell it we have sent a message */

View File

@ -123,7 +123,7 @@ void ipc_platform_complete_cmd(struct ipc *ipc)
}
}
int ipc_platform_send_msg(struct ipc_msg *msg)
int ipc_platform_send_msg(const struct ipc_msg *msg)
{
struct ipc *ipc = ipc_get();
int ret = 0;
@ -137,7 +137,7 @@ int ipc_platform_send_msg(struct ipc_msg *msg)
/* now send the message */
mailbox_dspbox_write(0, msg->tx_data, msg->tx_size);
list_item_del(&msg->list);
tr_dbg(&ipc_tr, "ipc: msg tx -> 0x%x", msg->header);
ipc->is_notification_pending = true;

View File

@ -111,7 +111,7 @@ void ipc_platform_complete_cmd(struct ipc *ipc)
shim_write(SHIM_IMRD, shim_read(SHIM_IMRD) & ~SHIM_IMRD_BUSY);
}
int ipc_platform_send_msg(struct ipc_msg *msg)
int ipc_platform_send_msg(const struct ipc_msg *msg)
{
struct ipc *ipc = ipc_get();
int ret = 0;
@ -125,7 +125,7 @@ int ipc_platform_send_msg(struct ipc_msg *msg)
/* now send the message */
mailbox_dspbox_write(0, msg->tx_data, msg->tx_size);
list_item_del(&msg->list);
tr_dbg(&ipc_tr, "ipc: msg tx -> 0x%x", msg->header);
ipc->is_notification_pending = true;

View File

@ -214,7 +214,7 @@ void ipc_platform_complete_cmd(struct ipc *ipc)
ipc_write(IPC_DIPCCTL, ipc_read(IPC_DIPCCTL) | IPC_DIPCCTL_IPCTBIE);
}
int ipc_platform_send_msg(struct ipc_msg *msg)
int ipc_platform_send_msg(const struct ipc_msg *msg)
{
struct ipc *ipc = ipc_get();
ipc_cmd_hdr *hdr;
@ -231,7 +231,6 @@ int ipc_platform_send_msg(struct ipc_msg *msg)
goto out;
}
list_item_del(&msg->list);
tr_dbg(&ipc_tr, "ipc: msg tx -> 0x%x", msg->header);
ipc->is_notification_pending = true;

View File

@ -65,11 +65,11 @@ void ipc_platform_complete_cmd(struct ipc *ipc)
{
}
int ipc_platform_send_msg(struct ipc_msg *msg)
int ipc_platform_send_msg(const struct ipc_msg *msg)
{
/* now send the message */
mailbox_dspbox_write(0, msg->tx_data, msg->tx_size);
list_item_del(&msg->list);
tr_dbg(&ipc_tr, "ipc: msg tx -> 0x%x", msg->header);
/* now interrupt host to tell it we have message sent */

View File

@ -113,7 +113,7 @@ void ipc_platform_complete_cmd(struct ipc *ipc)
}
int ipc_platform_send_msg(struct ipc_msg *msg)
int ipc_platform_send_msg(const struct ipc_msg *msg)
{
struct ipc *ipc = ipc_get();
int ret = 0;
@ -127,7 +127,7 @@ int ipc_platform_send_msg(struct ipc_msg *msg)
/* now send the message */
mailbox_dspbox_write(0, msg->tx_data, msg->tx_size);
list_item_del(&msg->list);
tr_dbg(&ipc_tr, "ipc: msg tx -> 0x%x", msg->header);
ipc->is_notification_pending = true;

View File

@ -89,7 +89,7 @@ void ipc_platform_complete_cmd(struct ipc *ipc)
wait_for_interrupt(0);
}
int ipc_platform_send_msg(struct ipc_msg *msg)
int ipc_platform_send_msg(const struct ipc_msg *msg)
{
struct ipc *ipc = ipc_get();
@ -98,7 +98,7 @@ int ipc_platform_send_msg(struct ipc_msg *msg)
/* now send the message */
mailbox_dspbox_write(0, msg->tx_data, msg->tx_size);
list_item_del(&msg->list);
ipc->is_notification_pending = true;
/* now interrupt host to tell it we have sent a message */

View File

@ -88,7 +88,7 @@ void ipc_platform_complete_cmd(struct ipc *ipc)
wait_for_interrupt(0);
}
int ipc_platform_send_msg(struct ipc_msg *msg)
int ipc_platform_send_msg(const struct ipc_msg *msg)
{
struct ipc *ipc = ipc_get();
@ -97,7 +97,7 @@ int ipc_platform_send_msg(struct ipc_msg *msg)
/* now send the message */
mailbox_dspbox_write(0, msg->tx_data, msg->tx_size);
list_item_del(&msg->list);
ipc->is_notification_pending = true;
/* now interrupt host to tell it we have sent a message */

View File

@ -178,7 +178,7 @@ int ipc_compact_write_msg(ipc_cmd_hdr *hdr);
* @param[in] msg The ipc msg.
* @return pointer to raw header or NULL.
*/
ipc_cmd_hdr *ipc_prepare_to_send(struct ipc_msg *msg);
ipc_cmd_hdr *ipc_prepare_to_send(const struct ipc_msg *msg);
/**
* \brief Validate mailbox contents for valid IPC header.

View File

@ -50,7 +50,7 @@ void ipc_platform_complete_cmd(struct ipc *ipc);
* @param msg The IPC message to send to host.
* @return 0 on success.
*/
int ipc_platform_send_msg(struct ipc_msg *msg);
int ipc_platform_send_msg(const struct ipc_msg *msg);
/**
* \brief Retrieves the ipc_data_host_buffer allocated by the platform ipc.

View File

@ -187,8 +187,9 @@ void ipc_send_queued_msg(void)
msg = list_first_item(&ipc->msg_list, struct ipc_msg,
list);
ipc_platform_send_msg(msg);
if (ipc_platform_send_msg(msg) == 0)
/* Remove the message from the list if it has been successfully sent. */
list_item_del(&msg->list);
out:
k_spin_unlock(&ipc->lock, key);
}

View File

@ -1538,7 +1538,7 @@ ipc_cmd_hdr *ipc_compact_read_msg(void)
#endif
/* prepare the message using ABI major layout */
ipc_cmd_hdr *ipc_prepare_to_send(struct ipc_msg *msg)
ipc_cmd_hdr *ipc_prepare_to_send(const struct ipc_msg *msg)
{
static uint32_t hdr[2];

View File

@ -828,7 +828,7 @@ ipc_cmd_hdr *ipc_compact_read_msg(void)
return ipc_to_hdr(msg_data.msg_in);
}
ipc_cmd_hdr *ipc_prepare_to_send(struct ipc_msg *msg)
ipc_cmd_hdr *ipc_prepare_to_send(const struct ipc_msg *msg)
{
uint32_t size;

View File

@ -68,7 +68,7 @@ static inline void platform_wait_for_interrupt(int level)
arch_wait_for_interrupt(level);
}
static inline int ipc_platform_send_msg(struct ipc_msg *msg) { return 0; }
static inline int ipc_platform_send_msg(const struct ipc_msg *msg) { return 0; }
#endif /* __PLATFORM_PLATFORM_H__ */

View File

@ -219,7 +219,7 @@ void WEAK ipc_platform_complete_cmd(struct ipc *ipc)
}
#if !CONFIG_LIBRARY
int WEAK ipc_platform_send_msg(struct ipc_msg *msg)
int WEAK ipc_platform_send_msg(const struct ipc_msg *msg)
{
return 0;
}