Skip to content

Commit 33e5dc0

Browse files
committed
ipc: Remove unnecessary cache manipulation
The buffer containing the payload of the sent IPC message should always be placed in shared memory (non-cached). Remove the unnecessary is_shared field from the ipc_msg structure and the code responsible for performing cache memory operations. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
1 parent 2987e09 commit 33e5dc0

File tree

4 files changed

+4
-27
lines changed

4 files changed

+4
-27
lines changed

src/include/sof/ipc/msg.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ struct ipc_msg {
3434
uint32_t header; /* specific to platform */
3535
uint32_t extension; /* extension specific to platform */
3636
uint32_t tx_size; /* payload size in bytes */
37-
void *tx_data; /* pointer to payload data */
38-
bool is_shared; /* the message is shared cross-core */
37+
void *tx_data; /* pointer to payload data, must be in a non-cached memory */
3938
struct list_item list;
4039
};
4140

src/ipc/ipc-common.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,6 @@ void ipc_msg_send(struct ipc_msg *msg, void *data, bool high_priority)
216216
msg->tx_data != data) {
217217
ret = memcpy_s(msg->tx_data, msg->tx_size, data, msg->tx_size);
218218
assert(!ret);
219-
if (!cpu_is_primary(cpu_get_id())) {
220-
/* Write back data to memory to maintain coherence between cores.
221-
* The response was prepared on a secondary core but will be sent
222-
* to the host from the primary core.
223-
*/
224-
dcache_writeback_region((__sparse_force void __sparse_cache *)msg->tx_data,
225-
msg->tx_size);
226-
msg->is_shared = true;
227-
}
228219
}
229220

230221
/*

src/ipc/ipc4/handler.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ struct ipc4_msg_data {
7272
static struct ipc4_msg_data msg_data;
7373

7474
/* fw sends a fw ipc message to send the status of the last host ipc message */
75-
static struct ipc_msg msg_reply = {0, 0, 0, 0, false, LIST_INIT(msg_reply.list)};
75+
static struct ipc_msg msg_reply = {0, 0, 0, 0, LIST_INIT(msg_reply.list)};
7676

77-
static struct ipc_msg msg_notify = {0, 0, 0, 0, false, LIST_INIT(msg_notify.list)};
77+
static struct ipc_msg msg_notify = {0, 0, 0, 0, LIST_INIT(msg_notify.list)};
7878

7979
#if CONFIG_LIBRARY
8080
static inline struct ipc4_message_request *ipc4_get_message_request(void)
@@ -1471,18 +1471,8 @@ struct ipc_cmd_hdr *ipc_prepare_to_send(const struct ipc_msg *msg)
14711471
msg_data.msg_out.pri = msg->header;
14721472
msg_data.msg_out.ext = msg->extension;
14731473

1474-
if (msg->tx_size) {
1475-
/* Invalidate cache to ensure we read the latest data from memory.
1476-
* The response was prepared on a secondary core but will be sent
1477-
* to the host from the primary core.
1478-
*/
1479-
if (msg->is_shared) {
1480-
dcache_invalidate_region((__sparse_force void __sparse_cache *)msg->tx_data,
1481-
msg->tx_size);
1482-
}
1483-
1474+
if (msg->tx_size)
14841475
mailbox_dspbox_write(0, (uint32_t *)msg->tx_data, msg->tx_size);
1485-
}
14861476

14871477
return &msg_data.msg_out;
14881478
}
@@ -1515,7 +1505,6 @@ void ipc_send_panic_notification(void)
15151505
{
15161506
msg_notify.header = SOF_IPC4_NOTIF_HEADER(SOF_IPC4_EXCEPTION_CAUGHT);
15171507
msg_notify.extension = cpu_get_id();
1518-
msg_notify.is_shared = !cpu_is_primary(cpu_get_id());
15191508
msg_notify.tx_size = 0;
15201509
msg_notify.tx_data = NULL;
15211510
list_init(&msg_notify.list);
@@ -1548,7 +1537,6 @@ void ipc_send_buffer_status_notify(void)
15481537
msg_notify.header = SOF_IPC4_NOTIF_HEADER(SOF_IPC4_NOTIFY_LOG_BUFFER_STATUS);
15491538
msg_notify.extension = 0;
15501539
msg_notify.tx_size = 0;
1551-
msg_notify.is_shared = false;
15521540

15531541
tr_dbg(&ipc_tr, "tx-notify\t: %#x|%#x", msg_notify.header, msg_notify.extension);
15541542

src/library_manager/lib_notification.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ struct ipc_msg *lib_notif_msg_init(uint32_t header, uint32_t size)
7373
/* Update header and size, since message handle can be reused */
7474
msg->header = header;
7575
msg->tx_size = size;
76-
msg->is_shared = !cpu_is_primary(cpu_get_id());
7776
return msg;
7877
}
7978

0 commit comments

Comments
 (0)