Skip to content

Commit 42025e5

Browse files
Adrian Wareckilgirdwood
authored andcommitted
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>
1 parent 6b2e90e commit 42025e5

File tree

15 files changed

+24
-24
lines changed

15 files changed

+24
-24
lines changed

src/drivers/amd/renoir/ipc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ void ipc_platform_complete_cmd(struct ipc *ipc)
166166
}
167167
}
168168

169-
int ipc_platform_send_msg(struct ipc_msg *msg)
169+
int ipc_platform_send_msg(const struct ipc_msg *msg)
170170
{
171171
int ret = 0;
172172
acp_sw_intr_trig_t sw_intr_trig;
@@ -198,7 +198,7 @@ int ipc_platform_send_msg(struct ipc_msg *msg)
198198
goto out;
199199
/* Write new message in the mailbox */
200200
mailbox_dspbox_write(0, msg->tx_data, msg->tx_size);
201-
list_item_del(&msg->list);
201+
202202
/* Need to set DSP message flag */
203203
sof_ipc_dsp_msg_set();
204204
/* now interrupt host to tell it we have sent a message */

src/drivers/imx/ipc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void ipc_platform_complete_cmd(struct ipc *ipc)
123123
}
124124
}
125125

126-
int ipc_platform_send_msg(struct ipc_msg *msg)
126+
int ipc_platform_send_msg(const struct ipc_msg *msg)
127127
{
128128
struct ipc *ipc = ipc_get();
129129
int ret = 0;
@@ -137,7 +137,7 @@ int ipc_platform_send_msg(struct ipc_msg *msg)
137137

138138
/* now send the message */
139139
mailbox_dspbox_write(0, msg->tx_data, msg->tx_size);
140-
list_item_del(&msg->list);
140+
141141
tr_dbg(&ipc_tr, "ipc: msg tx -> 0x%x", msg->header);
142142

143143
ipc->is_notification_pending = true;

src/drivers/intel/baytrail/ipc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void ipc_platform_complete_cmd(struct ipc *ipc)
111111
shim_write(SHIM_IMRD, shim_read(SHIM_IMRD) & ~SHIM_IMRD_BUSY);
112112
}
113113

114-
int ipc_platform_send_msg(struct ipc_msg *msg)
114+
int ipc_platform_send_msg(const struct ipc_msg *msg)
115115
{
116116
struct ipc *ipc = ipc_get();
117117
int ret = 0;
@@ -125,7 +125,7 @@ int ipc_platform_send_msg(struct ipc_msg *msg)
125125

126126
/* now send the message */
127127
mailbox_dspbox_write(0, msg->tx_data, msg->tx_size);
128-
list_item_del(&msg->list);
128+
129129
tr_dbg(&ipc_tr, "ipc: msg tx -> 0x%x", msg->header);
130130

131131
ipc->is_notification_pending = true;

src/drivers/intel/cavs/ipc.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ void ipc_platform_complete_cmd(struct ipc *ipc)
214214
ipc_write(IPC_DIPCCTL, ipc_read(IPC_DIPCCTL) | IPC_DIPCCTL_IPCTBIE);
215215
}
216216

217-
int ipc_platform_send_msg(struct ipc_msg *msg)
217+
int ipc_platform_send_msg(const struct ipc_msg *msg)
218218
{
219219
struct ipc *ipc = ipc_get();
220220
ipc_cmd_hdr *hdr;
@@ -231,7 +231,6 @@ int ipc_platform_send_msg(struct ipc_msg *msg)
231231
goto out;
232232
}
233233

234-
list_item_del(&msg->list);
235234
tr_dbg(&ipc_tr, "ipc: msg tx -> 0x%x", msg->header);
236235

237236
ipc->is_notification_pending = true;

src/drivers/intel/cavs/sue-ipc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ void ipc_platform_complete_cmd(struct ipc *ipc)
6565
{
6666
}
6767

68-
int ipc_platform_send_msg(struct ipc_msg *msg)
68+
int ipc_platform_send_msg(const struct ipc_msg *msg)
6969
{
7070
/* now send the message */
7171
mailbox_dspbox_write(0, msg->tx_data, msg->tx_size);
72-
list_item_del(&msg->list);
72+
7373
tr_dbg(&ipc_tr, "ipc: msg tx -> 0x%x", msg->header);
7474

7575
/* now interrupt host to tell it we have message sent */

src/drivers/intel/haswell/ipc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void ipc_platform_complete_cmd(struct ipc *ipc)
113113

114114
}
115115

116-
int ipc_platform_send_msg(struct ipc_msg *msg)
116+
int ipc_platform_send_msg(const struct ipc_msg *msg)
117117
{
118118
struct ipc *ipc = ipc_get();
119119
int ret = 0;
@@ -127,7 +127,7 @@ int ipc_platform_send_msg(struct ipc_msg *msg)
127127

128128
/* now send the message */
129129
mailbox_dspbox_write(0, msg->tx_data, msg->tx_size);
130-
list_item_del(&msg->list);
130+
131131
tr_dbg(&ipc_tr, "ipc: msg tx -> 0x%x", msg->header);
132132

133133
ipc->is_notification_pending = true;

src/drivers/mediatek/mt8186/ipc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void ipc_platform_complete_cmd(struct ipc *ipc)
8989
wait_for_interrupt(0);
9090
}
9191

92-
int ipc_platform_send_msg(struct ipc_msg *msg)
92+
int ipc_platform_send_msg(const struct ipc_msg *msg)
9393
{
9494
struct ipc *ipc = ipc_get();
9595

@@ -98,7 +98,7 @@ int ipc_platform_send_msg(struct ipc_msg *msg)
9898

9999
/* now send the message */
100100
mailbox_dspbox_write(0, msg->tx_data, msg->tx_size);
101-
list_item_del(&msg->list);
101+
102102
ipc->is_notification_pending = true;
103103

104104
/* now interrupt host to tell it we have sent a message */

src/drivers/mediatek/mt8195/ipc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void ipc_platform_complete_cmd(struct ipc *ipc)
8888
wait_for_interrupt(0);
8989
}
9090

91-
int ipc_platform_send_msg(struct ipc_msg *msg)
91+
int ipc_platform_send_msg(const struct ipc_msg *msg)
9292
{
9393
struct ipc *ipc = ipc_get();
9494

@@ -97,7 +97,7 @@ int ipc_platform_send_msg(struct ipc_msg *msg)
9797

9898
/* now send the message */
9999
mailbox_dspbox_write(0, msg->tx_data, msg->tx_size);
100-
list_item_del(&msg->list);
100+
101101
ipc->is_notification_pending = true;
102102

103103
/* now interrupt host to tell it we have sent a message */

src/include/sof/ipc/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ int ipc_compact_write_msg(ipc_cmd_hdr *hdr);
178178
* @param[in] msg The ipc msg.
179179
* @return pointer to raw header or NULL.
180180
*/
181-
ipc_cmd_hdr *ipc_prepare_to_send(struct ipc_msg *msg);
181+
ipc_cmd_hdr *ipc_prepare_to_send(const struct ipc_msg *msg);
182182

183183
/**
184184
* \brief Validate mailbox contents for valid IPC header.

src/include/sof/ipc/driver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void ipc_platform_complete_cmd(struct ipc *ipc);
5050
* @param msg The IPC message to send to host.
5151
* @return 0 on success.
5252
*/
53-
int ipc_platform_send_msg(struct ipc_msg *msg);
53+
int ipc_platform_send_msg(const struct ipc_msg *msg);
5454

5555
/**
5656
* \brief Retrieves the ipc_data_host_buffer allocated by the platform ipc.

0 commit comments

Comments
 (0)