Skip to content

IPC4: fix ipc_send_queued_msg() logic - #6243

Closed
kv2019i wants to merge 1 commit into
thesofproject:mainfrom
kv2019i:topic/ipc4-tx-queued
Closed

kv2019i wants to merge 1 commit into
thesofproject:mainfrom
kv2019i:topic/ipc4-tx-queued

Conversation

@kv2019i

@kv2019i kv2019i commented Sep 2, 2022

Copy link
Copy Markdown
Collaborator

Fix issues with ipc_send_queued_msg() both in generic IPC4 code, as well as a seperate problem in Zephyr SOF builds.

FYI @bardliao @abonislawski @marcinszkudlinski

@lgirdwood

Copy link
Copy Markdown
Member

@mwasko fyi - pls review

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kv2019i fix for v2.3 ? or IPC4 only

@kv2019i
kv2019i force-pushed the topic/ipc4-tx-queued branch from 42e21a6 to 6a11915 Compare September 2, 2022 08:59
@kv2019i

kv2019i commented Sep 2, 2022

Copy link
Copy Markdown
Collaborator Author

@lgirdwood wrote:

@kv2019i fix for v2.3 ? or IPC4 only

The other commit could hit Zephyr+IPC3 combo if you have a source of frequency notifications on Zephyr side (e.g. DMA trace, IPC stream position updates enabled or something similar). So potentially for 2.3 as well.

@kv2019i

kv2019i commented Sep 2, 2022

Copy link
Copy Markdown
Collaborator Author

V2 uploaded:

  • one DEBUG trace left accidentally in the code, now removed
  • no other changes

@kv2019i
kv2019i force-pushed the topic/ipc4-tx-queued branch from 6a11915 to 0bc8ab0 Compare September 2, 2022 09:04
@kv2019i

kv2019i commented Sep 2, 2022

Copy link
Copy Markdown
Collaborator Author

V3 update:

  • improved the commit message

@kv2019i
kv2019i marked this pull request as draft September 2, 2022 09:49
@kv2019i

kv2019i commented Sep 2, 2022

Copy link
Copy Markdown
Collaborator Author

Convert back to draft. The EDF scheduler usage is not correct. This is now relying on a peculiar implementation of EDF scheduler on Zephyr, and we should not increase such code in SOF. I'll figure out a another solution for the delayed work here.

@kv2019i
kv2019i force-pushed the topic/ipc4-tx-queued branch from 0bc8ab0 to 7e369c0 Compare September 2, 2022 10:45
@kv2019i
kv2019i marked this pull request as ready for review September 2, 2022 10:46
@kv2019i

kv2019i commented Sep 2, 2022

Copy link
Copy Markdown
Collaborator Author

V4 update:

  • the ifdefs for ZEPHYR become too ugly, so I now modified implementation for both XTOS and Zephyr and move it up to IPC layer
  • the EDF scheduler usage in earlier versions was misusing the interface (start field should be ignored by EDF scheduler but it's not on Zephyr now), so drop this and use a regular LL task instead

@kv2019i
kv2019i force-pushed the topic/ipc4-tx-queued branch from 7e369c0 to 5e82164 Compare September 2, 2022 10:49
@kv2019i
kv2019i requested a review from mrajwa as a code owner September 2, 2022 10:49
@kv2019i
kv2019i force-pushed the topic/ipc4-tx-queued branch from 5e82164 to c8bd2b9 Compare September 2, 2022 16:02
Comment thread src/ipc/ipc-common.c Resolved
@kv2019i

kv2019i commented Sep 2, 2022 •

Copy link
Copy Markdown
Collaborator Author

V5 update (back as DRAFT again):

  • there is some unfortunate onion-peeling effect here
  • now that TX queueing works (and is automatic if EBUSY is seen), this uncovers a bug in IPC4 logging where a single notify message object was not properly protected for concurrent access
  • added one additional commit to address above issue. the fix is not super clean, but we need to have some protection or otherwise we cannot fix the TX queueing -- I don't think we have any real need to queue multiple notifications, so dynamic allocation of notify msgs seems overkill as a solution
  • UPDATE: still more issues, need to take back as draft -- overall resuming send_queued_msgs() is bringing too many new issues

@kv2019i
kv2019i marked this pull request as draft September 2, 2022 16:42
@kv2019i
kv2019i force-pushed the topic/ipc4-tx-queued branch from c8bd2b9 to 9bb2e27 Compare September 5, 2022 12:18
@kv2019i
kv2019i marked this pull request as ready for review September 5, 2022 12:18
@kv2019i

kv2019i commented Sep 5, 2022

Copy link
Copy Markdown
Collaborator Author

V6 update:

  • back to ready-for-review
  • one bugfix to the re-schedule logic

Comment thread src/ipc/ipc4/handler.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment this should be OK as the only notification provider is mtrace, but in future if we have other notification sources then either each will have it's own static struct or we need to dynamically allocate notification messages..

@kv2019i
kv2019i force-pushed the topic/ipc4-tx-queued branch from 9bb2e27 to 8ce7899 Compare September 5, 2022 16:28
@kv2019i

kv2019i commented Sep 5, 2022

Copy link
Copy Markdown
Collaborator Author

V7 update:

  • this adds two fixes to mtrace logging that address a problem of high rate buffer-status notifies when mtrace is enabled but no mtrace-reader is running during use-cases

@lgirdwood

Copy link
Copy Markdown
Member

SOFCI TEST

@kv2019i

kv2019i commented Sep 6, 2022

Copy link
Copy Markdown
Collaborator Author

@lgirdwood The first patch affects XTOS builds (moves IPC late sending from OS main loop to LL scheduler) and it is possible this is now failing cases (e.g. the Intel CI builds).

@lgirdwood

Copy link
Copy Markdown
Member

@lgirdwood The first patch affects XTOS builds (moves IPC late sending from OS main loop to LL scheduler) and it is possible this is now failing cases (e.g. the Intel CI builds).

Zephyr build was failing on the zephyr.h issues, fix now merged but it looks like build still problematic. Maybe needs a rebase and force push ?

@kv2019i

kv2019i commented Sep 6, 2022 •

Copy link
Copy Markdown
Collaborator Author

@lgirdwood wrote:

Zephyr build was failing on the zephyr.h issues, fix now merged but it looks like build still problematic. Maybe needs a rebase and force push ?

I think you need to ignore these GH tests that test with "main" of Zephyr. These are "informational" (for us), but it's is normal and expected that upstream Zephyr has merged patches that does not build with current SOF main. I.e. these checks will pass again when we make a SOF PR that updates the manifest (and potential local changes to SOF).

The XTOS/IPC3 failure is more worrying. There seems to be a IPC panic in a multicore test.

@kv2019i

kv2019i commented Sep 6, 2022

Copy link
Copy Markdown
Collaborator Author

Hmm, let me fork out the changes that do not have any impact to IPC3/XTOS.

Comment thread src/ipc/ipc4/logging.c Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here updating mtrace_notify_last_sent is intended?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damn, rebasing brought it back. Will address.

Comment thread src/ipc/ipc4/logging.c Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the answer to the above is "yes," then this shouldn't be needed

Comment thread src/ipc/ipc4/handler.c Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list_item() is kind of nicer for this

Comment thread src/ipc/ipc-common.c Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be ok to just call schedule_task() under the spinlock?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, indeed that seems to be safe (or at least done elsewhere in the code. I'll move it.

Comment thread src/ipc/ipc-common.c Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather use an affirmative condition check :-)

Comment thread src/ipc/ipc-common.c Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must be confusing this with something else, wasn't this supposed to be an EDF task?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I dropped that approached and used LL task instead. We should not rely on the "task start" field in EDF scheduling (it's a feature of the Zephyr SOF EDF scheduler implementation, not part of the interface).

@kv2019i

kv2019i commented Sep 6, 2022

Copy link
Copy Markdown
Collaborator Author

I'll close this to not waste reviewers time. There's a repeating failure in XTOS/IPC3 tests with this series and this probably relates to the first patch that also touches the XTOS primary core main loop (moving the IPC flushing from OS main loop to a normal LL scheduler task). Until I figure this out, we can't merge this. The other fixes are important though, so let's get them merged at a faster speed. -> #6260

Sorry for the churn all reviewers.

@kv2019i kv2019i closed this Sep 6, 2022
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>
@kv2019i kv2019i reopened this Sep 7, 2022
@kv2019i
kv2019i force-pushed the topic/ipc4-tx-queued branch from 8ce7899 to d3d1836 Compare September 7, 2022 10:12
@kv2019i
kv2019i marked this pull request as draft September 7, 2022 10:12
@kv2019i

kv2019i commented Sep 7, 2022

Copy link
Copy Markdown
Collaborator Author

V8 update:

  • reopened the PR
  • 4/5 commits merged in another PR, now only one commit left in this PR
  • marking as draft until the XTOS/IPC3 failure in CI is rootcaused

@kv2019i

kv2019i commented Sep 7, 2022

Copy link
Copy Markdown
Collaborator Author

Still failing in the multicore IPC3/XTOS tests.

@kv2019i

kv2019i commented Sep 7, 2022

Copy link
Copy Markdown
Collaborator Author

It turns out this change is overlapping with c194125 @marc-hb did last year. So IOW, Zephyr+IPC3 combination is good after all (which makes a lot more sense). Combined with the errors found on XTOS by CI, I'll close this again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants