thesofproject / sof

Sound Open Firmware
Other
563 stars 319 forks source link

[FEATURE][meta] Use Zephyr native interfaces #5794

Open kv2019i opened 2 years ago

kv2019i commented 2 years ago

This is a meta issue to track work to move SOF code to use Zephyr native interfaces. The task is two-fold:

  1. move (audio) application code to use native Zephyr interfaces (this is the primary focus, affects all SOF users and configurations)
  2. move driver and hw platform code to Zephyr (this is secondary as new platforms will be Zephyr-only -- current we have some Intel and IMX platforms that support both XTOS and Zephyr and separate set of cleanups are needed for these platforms)

Change in brief: SOF application code will transition to Zephyr application interfaces. Change is done incrementally so that build with the "in-tree XTOS" continuous to work.

Guard rails:

Transition tools:

Ongoing work for generic code (affects all SOF configurations):

Ongoing work for SOF platform layer (affects all SOF configurations):

Ongoing work for specific platforms (Intel cAVS, NXP IMX)

From @dbaluta - For NXP we have on roadmap to port to Zephyr:

hongshui3000 commented 2 years ago

is there any plan to move code in sof/src/platform/ to zephyr? I want development drivers and platforms to be out of tree

lgirdwood commented 2 years ago

is there any plan to move code in sof/src/platform/ to zephyr? I want development drivers and platforms to be out of tree

Yes - we are just working out the stages for this. Topic at TSC tomorrow.

lenghonglin commented 2 years ago

is there any plan to move code in sof/src/platform/ to zephyr? I want development drivers and platforms to be out of tree

Yes - we are just working out the stages for this. Topic at TSC tomorrow.

Is there something news to share after TSC?

lgirdwood commented 2 years ago

@lenghonglin apologies, I and some other TSC member were travelling last week.

Please see minutes here. https://github.com/orgs/thesofproject/teams/steering-committee/discussions/31

lgirdwood commented 2 years ago

@kv2019i we should add the DAI/DMA integration here too ?

kv2019i commented 1 year ago

Marked multiple items as done. Added one new item for platform code init.

lgirdwood commented 1 year ago

@abonislawski @mwasko @dbaluta any items you can add/update here ?

kv2019i commented 1 year ago

A lot of work has been done to cleanup the XTOS/Zephyr split in SOF codebase for 2.5, and to continue the move to native calls in SOF application code. Some work is left though, so moving this meta item for v2.6 milestone. A few subitems are still queued for v2.5 and they will be included if they get merged to main before the cutoff.

lgirdwood commented 1 year ago

@abonislawski @lyakh @juimonen anything else still todo ? cache API ?

lyakh commented 1 year ago

@abonislawski @lyakh @juimonen anything else still todo ? cache API ?

@lgirdwood yes, moving over to the Zephyr native z_xtensa_cache_*() API is one of the remaining items. irq_local_*able() is another XTOS API that's still widely used in SOF.

kv2019i commented 1 year ago

Updated description of the transition tools and guarrails to include the new "{xtos/zephyr}/include/rtos" mechanism to abstract OS services.

Also added @lyakh the cache and local ireq control as tasks. Please do add items directly here as well. This will serve both as a tasklist, and will provide example how to do the transitions.

lgirdwood commented 1 year ago

@dbaluta any Zephyr related interfaces pending for NXP ?

iuliana-prodan commented 1 year ago

@dbaluta any Zephyr related interfaces pending for NXP ?

For NXP we have on roadmap to port to Zephyr:

We are now using the ones from SOF.

lgirdwood commented 1 year ago

@juimonen @dbaluta are we on track for v2.6 ? Can we close ?

kv2019i commented 1 year ago

@lgirdwood let's dis-engage this meta-item from the milestones and track the subitems with milestones instead. FYI for @dbaluta . This can be then used for other vendors as well to help with the Zephyr migration.

dbaluta commented 1 year ago

@kv2019i do you suggest on creating separate Issues for NXP for example, to track the switch to native interfaces?

Since Zephyr has a DAI interface, for us porting NXP DAIs should be low hanging fruits and doable for v2.6

We need to look into the DMA and also the IRQ controller as this could be trickier.

Cc: @iuliana-prodan

kv2019i commented 1 year ago

@dbaluta I think we can keep NXP issues here as well. We can assign subitems (like the DAI port) to milestones and track them at that level.

iuliana-prodan commented 1 year ago

@kv2019i @lgirdwood is the Zephyr native drivers for DAI, DMA, irq related with IPC4? Meaning, can we move to zephyr native drivers for DAI, DMA and still using IPC3? Or should we move to IPC4 also?

kv2019i commented 1 year ago

@iuliana-prodan the DAI/DMA interfaces are IPC agnostic, so no hard requirement to move to IPC4 to use native drivers. The main changes are in dai-zephyr.c/dai-legacy.c and host-zephyr.c/host-legacy.c. There are a few IPC specific bits, but those are related to IPC functionality like bind/unbind (only in IPC4), so the main code is completely shared. Of course with Intel targets moved to IPC4, testing coverage is better with IPC4 now (would be nice to have some IPC3 devices in upstream SOF CI so we'd catch issues sooner).

dbaluta commented 1 year ago

Cc: @LaurentiuM1234 who is working on this.

LaurentiuM1234 commented 1 year ago

Small update on NXP's side:

  1. Driver status
    • irqsteer driver was tested (nothing fancy, just checked if aplay works, will most likely require a stress test to make sure everything's fine) and is done. Zephyr PR: https://github.com/zephyrproject-rtos/zephyr/pull/62776.
    • DAI/EDMA drivers are mostly done. Will upstream once I make sure everything's fine.
  2. Switch to native drivers status
    • currently, I'm working on switching i.MX93 to using the Zephyr native drivers plus the dai-zephyr/host-zephyr combo.
    • so far no issue with the IPC version (as far as I can tell)
    • will probably have to tweak/rework the Zephyr DMA domain (unless we switch to the timer domain?) as things are a bit different now (e.g: IRQ management is done in the drivers, the state of the DMA channels is something internal to the driver and we can't query it ATM etc... + we have the option to use the DMA CB instead of enabling Zephyr shared interrupts and then registering dma_irq_handler)
  3. To dos
    • as far as I can tell right now, before we can switch we need to sort out the domain issue and implement the rest of the drivers (SDMA, ESAI and MU). Hopefully I didn't miss anything?
lgirdwood commented 1 year ago

@marcinszkudlinski @mwasko @abonislawski @softwarecki @kv2019i @lyakh any other nativization work that should be added to the main feature list as we are nearing completion of initial tasks.

kv2019i commented 7 months ago

Add:

LaurentiuM1234 commented 7 months ago

From NXP's side: imx8, imx93, and imx8ulp have all been ported to native Zephyr. All of these platforms have been switched to timer domain, which, so far, has been working well. For the switch, we've added drivers in Zephyr for the following IPs previously kept in SOF tree:

  1. IRQ_STEER
  2. SAI
  3. ESAI
  4. EDMA
lgirdwood commented 7 months ago

@dbaluta @LaurentiuM1234 @iuliana-prodan - Great work everybody :)

I guess this now means you can remove NXP xtos code in main and do similar code clean ups like @kv2019i is doing atm for Intel to simplify your code base.

kv2019i commented 1 week ago

Added a separate section for tasks related to "thinning out" the sof/src/platform layer for Zephyr builds. In short the the intention is to continue pruning this interface and move everything that is hardware specific, to Zephyr. This will reduce the work that needs to be done to add a new hardware target to SOF.