Repository navigation
Conversation
In IPC4 protocol, responses are sent over a separate set of mailbox registers. This creates the following problem: a) msg received, IPC IRQ b) IRQ masked c) handle IPC command, possible in separate core d) when command handled, send the IPC reply e) IPC driver complete callback called f) acknowledge the message (by writing BUSY + DONE) g) unmask IRQ The problem is that the acknowledgement in step (f) is optional part of the protocol, and in fact, driver in IPC4 mode will consider the reply in step (d) as a signal that it can send more messages. If driver sends a new message in quick succession, this may be lost. This patch addresses the problem by moving the acknowledge step earlier so that the sequence becomes: A) msg received, IPC IRQ B) IRQ masked C) acknowledge the message (by writing BUSY + DONE) D) handle IPC command, possible in separate core E) when command handled, send the IPC reply F) IPC driver complete callback called G) unmask IRQ BugLink: thesofproject#6173 Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
The list fields in the ipc_msg objects used by IPC4 stack, are not initialized properly. This breaks the queueing logic in ipc_msg_send() when it checks for "if (list_is_empty(&msg->list))". As a result, if a IPC could not be sent immediately as the driver is busy, it would not properly be resent later. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
lyakh
left a comment
There was a problem hiding this comment.
very nice! Great work! Just would be good to understand why and how can messages be submitted to the queue repeatedly... Perhaps the reason is that SOF IPC messages are persistent objects, and the same object can be sent again by the owner while it is still in processing from the previous sending attempt and so it's on the queue. But maybe then owners should be fixed to not do that...
| msg_notify.header = SOF_IPC4_NOTIF_HEADER(SOF_IPC4_NOTIFY_LOG_BUFFER_STATUS); | ||
| msg_notify.extension = 0; | ||
| msg_notify.tx_size = 0; | ||
| list_init(&msg_notify.list); |
There was a problem hiding this comment.
I see that it affects the test in ipc_msg_send() but why is that test needed at all? Why is it possible to call that function for a message, that is already queued?..
There was a problem hiding this comment.
Is it OK to list_init() every time?
The problem is that we have single, local msg_notify and msg_reply.
If for example the notify got delayed, put to the list and you will have another notification: you change that message which was queued, list_init it again and things will be in an interesting state, no?
There was a problem hiding this comment.
@lyakh We might have contention between FW->HOST replies and FW->HOST notifications. Kernel needs to ack both and until kernel ack is received, ipc_msg_send() will return EBUSY.
There was a problem hiding this comment.
@kv2019i Just for the record - you probably mean ipc_platform_msg_send(). Ok, so apparently either there's no waiting for the host response or the wait can be preempted.
There was a problem hiding this comment.
to the commit message: "the platform driver returns -EBUSY?"
There was a problem hiding this comment.
It is a test. I prefer to do it in ipc4/handler.c without ifdef.
There was a problem hiding this comment.
@RanderWang Not sure I follow. This is writing to IPC hw registers and it thus should be done in the driver, not the protocol code in ipc4/handler.c. Right? The ifdef is needed as same driver is used for IPC3 and there the semantics are different ACK/REPLY are the same thing, so the proper place to do is later.
6cf62c8 to
abe8ea5
Compare
ipc_send_buffer_status_notify() uses a static ipc_msg object to send the notifications. In normal circumstances, notifications are never queued as they are sent as high-priority messages, but this is still possible. Requeing the same object can potentially lead to memory corruption as the caller is modifying the message object, while it may in fact be in use still. To avoid this, check in ipc_send_buffer_status_notify() whether the IPC message queue has the notify object, and if yes, skip the message. The buffer status notifications can be safely dropped in error case, as host can read the log buffer status directly from the SRAM window. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
The IPC send queue is used when a message cannot be sent immediately and/or the platform driver returns -EBUSY. This mechanism has been broken in Zephyr SOF builds. In XTOS builds, the ipc_send_queued_msg() was called directly from the operating system main task in src/schedule/task.c:task_main_primary_core(). This mainloop functionality is moved to Zephyr, so same implementation cannot be used on Zephyr. This commit unifies the implementation and uses a normal LL scheduler task to manage the send queue. This task is managed by IPC code, so low-level OS code does not need to call IPC stack directly. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
|
Closing this at least for now. #6239 won't be merged in its current form. |
A collection of multiple IPC4 timeout fixes. This PR is for testing to share the fixes and to get testing widers results. I'll probably submit these as separate PRs as they are independent fixes to different parts of the codebase.
This PR is for TESTING.
The more mature fixses are submitted for review separate at #6243
I will close this PR once testing is completed.