Repository navigation
IPC4: Improve TX resend logic on Zephyr - #6275
Conversation
There was a problem hiding this comment.
do we need logic similar to the present one to avoid scheduling IPCs when preparing to suspend?
There was a problem hiding this comment.
@lyakh Good question. ipc_send_queued_msg() won't send anything in we are going to D0. Not sure if rescheduling the task would block D0 sequence (if the flag is set, we've already made the decision to power off). I guess it wouldn't hurt.
There was a problem hiding this comment.
I pushed V2 that stops re-queuing if D3 request flag is set to keep the old behaviour.
There was a problem hiding this comment.
so you'd retry every 100us?.. I think previously IPC_PERIOD_USEC was actually unused - it was "used" as a task period for the IPC task, but the IPC task was an EDF task, and the EDF scheduler ignores period...
There was a problem hiding this comment.
@lyakh yes. this is fairly reasonable as we are mostly waiting for the kernel side to ACK the previous message and this should be very fast. OTOH, we could also trigger resend from the IPC driver and use a much slower timer to handle any lingering cases (maybe just to log an error). I can see from history that there was something like this in the old times, but Keyon removed it. Downside is that this needs to be added to all IPC drivers, while this logic is common for all.
899698a to
0c2b5c1
Compare
|
V2 update:
I think I do agree with @lyakh that we should look at removing this delayed-sending and instead trigger the sends directly from IRQ handler (immediately when channel becomes free). But given that was explicitly removed in commit "cavs-ipc: remove the superfluous message sending", this is probably for another PR to handle. Given current codebase does not do resends correct when LL scheduler domain is not running, I think this PR is valuable addition to the codebase. This also reduces the rate of notification that get sent every LL/1msec cycle. |
There was a problem hiding this comment.
sorry for a late comment, but how about
if (!list_is_empty(&ipc->msg_list) || ipc->pm_prepare_D3)
schedule_ipc_worker();
and removing the goto and the label?
There was a problem hiding this comment.
@lyakh I actually put this in just for you :D not to have a double-negative check. The full check needs to be
if (!list_is_empty(&ipc->msg_list) && !ipc->pm_prepare_D3)
schedule_ipc_worker();
I actually prefer that, so I'll change.
if (!(list_is_empty(&ipc->msg_list) || ipc->pm_prepare_D3))
schedule_ipc_worker();
... I find that harder to read myself.
There was a problem hiding this comment.
@lyakh, I think this would be the correct check:
if (!list_is_empty(&ipc->msg_list) && !ipc->pm_prepare_D3)
schedule_ipc_worker();There was a problem hiding this comment.
V3 update:
- goto out, double negative check in
- no changes otherwise
There was a problem hiding this comment.
@lyakh I actually put this in just for you :D
:-D sure, where removing a negation simplifies the code I'm all for it, in cases like
if (!a)
x();
else
y();
and similar. But without an else I usually prefer a negation over a goto. Of course, there are exceptions: for error handling, when the label is already there etc.
There was a problem hiding this comment.
My rule of thumb for deciding between !(A || B) versus !A && !B is: how closely related are A and B? If they're mostly independent of each then !A && !B is more readable, otherwise it's !(A || B). I think this approach makes the code closer to plain English / more readable.
My 2 cents; as long as there is no double negation then either is fine :-)
In many places of SOF code, assumption is that code is only run on a specific core. This allows to reduce overhead of cache coherency management. For example this is used in the IPC stack. In Zephyr, we can force threads to be pinned by default using the CONFIG_SCHED_CPU_MASK_PIN_ONLY setting. Enable this setting for all SOF builds. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Continue changes in commit c194125 ("zephyr: add notifier_register(ipc_send_queued_msg) in task_main_start()") and implement the delayed IPC msg sending in Zephyr work queue. The old implementation did not cover cases where IPC needed to be resent when no active LL scheduler tasks were active. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
0c2b5c1 to
cea53ec
Compare
ujfalusi
left a comment
There was a problem hiding this comment.
Testing along with thesofproject/linux#3843 looks really good locally.
|
@lgirdwood fixed :) |
After realizing we have a competing "TX sender" in zephyr/wrapper.c, I've modified the approach in #6243 . This takes benefit of the Zephyr CONFIG_SCHED_CPU_MASK_PIN_ONLY feature which allows to pin systems threads to specific cores of the system. In practise we can simply use the Zephyr system work queue, instead of using a LL-scheduler task, or a LL_POST_RUN notifier, to flush out pending IPC messages.
This fixes the issues with current codebase (Zephyr builds) where IPC TX messages were not flushed out if no LL task was running.
This also cleans up code from zephyr/wrapper.c.