Skip to content

Commit 3b78ccd

Browse files
RanderWangabonislawski
authored andcommitted
ipc4: msg: simplify ipc message check for notification
Use list_is_empty to check the message is queued or not. The notify message is initialized to empty after deleting from the ipc msg list. We use the same idea in ipc_msg_send. Signed-off-by: Rander Wang <rander.wang@intel.com>
1 parent 4f8f483 commit 3b78ccd

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

src/ipc/ipc4/handler.c

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static struct ipc4_msg_data msg_data;
6767
/* fw sends a fw ipc message to send the status of the last host ipc message */
6868
static struct ipc_msg msg_reply = {0, 0, 0, 0, LIST_INIT(msg_reply.list)};
6969

70-
static struct ipc_msg msg_notify;
70+
static struct ipc_msg msg_notify = {0, 0, 0, 0, LIST_INIT(msg_notify.list)};
7171

7272
/*
7373
* Global IPC Operations.
@@ -1146,28 +1146,15 @@ void ipc_send_panic_notification(void)
11461146

11471147
#ifdef CONFIG_LOG_BACKEND_ADSP_MTRACE
11481148

1149-
static bool is_notification_queued(void)
1149+
static bool is_notification_queued(struct ipc_msg *msg)
11501150
{
11511151
struct ipc *ipc = ipc_get();
1152-
struct list_item *slist;
1153-
struct ipc_msg *msg;
11541152
k_spinlock_key_t key;
11551153
bool queued = false;
11561154

11571155
key = k_spin_lock(&ipc->lock);
1158-
if (list_is_empty(&ipc->msg_list))
1159-
goto out;
1160-
1161-
list_for_item(slist, &ipc->msg_list) {
1162-
msg = container_of(slist, struct ipc_msg, list);
1163-
1164-
if (msg == &msg_notify) {
1165-
queued = true;
1166-
break;
1167-
}
1168-
}
1169-
1170-
out:
1156+
if (!list_is_empty(&msg->list))
1157+
queued = true;
11711158
k_spin_unlock(&ipc->lock, key);
11721159

11731160
return queued;
@@ -1176,13 +1163,12 @@ static bool is_notification_queued(void)
11761163
void ipc_send_buffer_status_notify(void)
11771164
{
11781165
/* a single msg_notify object is used */
1179-
if (is_notification_queued())
1166+
if (is_notification_queued(&msg_notify))
11801167
return;
11811168

11821169
msg_notify.header = SOF_IPC4_NOTIF_HEADER(SOF_IPC4_NOTIFY_LOG_BUFFER_STATUS);
11831170
msg_notify.extension = 0;
11841171
msg_notify.tx_size = 0;
1185-
list_init(&msg_notify.list);
11861172

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

0 commit comments

Comments
 (0)