sof icon indicating copy to clipboard operation
sof copied to clipboard

[FEATURE] remove XTOS support from SOF mainline

Open kv2019i opened this issue 8 months ago • 23 comments

Is your feature request related to a problem? Please describe. Since 2022, SOF has been moving to Zephyr as its primary RTOS with work tracked in https://github.com/thesofproject/sof/issues/5794 Most SOF users have either completed the transition to Zephyr, or are in progress of adding support for Zephyr for their platforms.

This ticket is for removal of XTOS support from SOF main, leaving XTOS support only supported in release stable branches. There is a set of cleanups we can proceed with, once XTOS support is removed, so having a ticket to mark as a dependency is useful for tracking.

Describe the solution you'd like XTOS support removal from "main" branch

Feature Breakdown This feature cannot be performed as a single large PR as we have many platforms, drivers, features and abstractions based around the legacy xtos code and this means we will need to remove section by section and make any necessary adaptations as needed for each removal.

These lists are not exhaustive, but the starting point for xtos removal.

Xtos Platform removals

  • [x] Intel - platform headers and some platform drivers remain for Intel platforms.
  • [x] NXP - platform headers and some drivers remain for NXP platforms.
  • [x] AMD - platform headers and some drivers remain for AMD platforms.
  • [x] MTK - platform headers and some drivers remain for MTK platforms.

Xtos Peripheral Driver removals

  • [x] Intel - DMA drivers remain for Intel platforms.
  • [ ] NXP - DMA, SAI, IPC drivers remain for NXP platforms.
  • [ ] AMD - DAI, DMA, interrupt drivers remain for AMD platforms.
  • [ ] MTK - DAI, DMA, interrupt drivers remain for MTK platforms.

Xtos Feature/abstraction removals

  • [ ] DMA interface.
  • [ ] Clock API
  • [ ] IPC API.
  • [ ] coherent API.
  • [ ] wait API
  • [ ] C library duplications.
  • [ ] trace API

kv2019i avatar May 02 '25 12:05 kv2019i

@lgirdwood opened discussion at https://github.com/orgs/thesofproject/discussions/9993

kv2019i avatar May 07 '25 11:05 kv2019i

@thesofproject/amd @thesofproject/nxp @thesofproject/intel @thesofproject/google @thesofproject/mediatek pls comment/review and provide any feedback.

lgirdwood avatar May 07 '25 12:05 lgirdwood

@thesofproject/amd @thesofproject/nxp @thesofproject/intel @thesofproject/google @thesofproject/mediatek pls comment/review and provide any feedback. @lgirdwood : We are in transition to Zephyr. DMA scheduling is removed in Zephyr and we have an issue with timer scheduler working, So, till we resolve timer based scheduler issue we need to support XTOS on AMD platforms.

bhiregoudar avatar May 07 '25 12:05 bhiregoudar

@thesofproject/amd @thesofproject/nxp @thesofproject/intel @thesofproject/google @thesofproject/mediatek pls comment/review and provide any feedback. @lgirdwood : We are in transition to Zephyr. DMA scheduling is removed in Zephyr and we have an issue with timer scheduler working, So, till we resolve timer based scheduler issue we need to support XTOS on AMD platforms.

@bhiregoudar ok, do you have a schedule for fixing timer scheduling on AMD ?

Fwiw, we found DMA based scheduling would not scale beyond a few streams as stream start ordering meant DMA IRQs would fire in different sequences/times and could cause a lot of thrash and glitches...

Timer based scheduling works best when the DSP is clock master for the codecs (otherwise you need to add the ASRC), as all pipelines are executed from a single synchronous tick in a deterministic order. Feel free to create an issue and it should gather comments from others who have transitioned to timers for debug.

lgirdwood avatar May 07 '25 13:05 lgirdwood

@thesofproject/amd @thesofproject/nxp @thesofproject/intel @thesofproject/google @thesofproject/mediatek pls comment/review and provide any feedback.

From NXP's point of view, we have all platforms supported with Zephyr and timer domain. We can remove the XTOS.

@dbaluta @LaurentiuM1234 do you see any issues with this?

iuliana-prodan avatar May 08 '25 09:05 iuliana-prodan

@iuliana-prodan all good from my point of view.

dbaluta avatar May 08 '25 10:05 dbaluta

@andrew-mtk pls reply with any comments for Mediatek team. @andyross feedback welcome too.

lgirdwood avatar May 08 '25 13:05 lgirdwood

IMO all good from NXP's side. Although @lgirdwood already mentioned this I want to stress out the fact that all IMX platforms are still using the XTOS IPC driver so we need to watch out for that.

LaurentiuM1234 avatar May 09 '25 10:05 LaurentiuM1234

IMO all good from NXP's side. Although @lgirdwood already mentioned this I want to stress out the fact that all IMX platforms are still using the XTOS IPC driver so we need to watch out for that.

Yeah - that's something that @kv2019i is working on with Zephyr folks. We also need Zephyr clock driver too. We would need to keep the legacy drivers until Zephyr replacements were upstream.

lgirdwood avatar May 09 '25 11:05 lgirdwood

IMO all good from NXP's side. Although @lgirdwood already mentioned this I want to stress out the fact that all IMX platforms are still using the XTOS IPC driver so we need to watch out for that.

Yeah - that's something that @kv2019i is working on with Zephyr folks. We also need Zephyr clock driver too. We would need to keep the legacy drivers until Zephyr replacements were upstream.

  • IPC work tracked in https://github.com/thesofproject/sof/issues/9697
  • Clock work tracked in https://github.com/thesofproject/sof/issues/9541 (only Intel uses the more complex clock change interface, so this should be less of a blocker as there's no XTOS user left anyways)

kv2019i avatar May 09 '25 12:05 kv2019i

@thesofproject/amd @thesofproject/nxp @thesofproject/intel @thesofproject/google @thesofproject/mediatek pls comment/review and provide any feedback. @lgirdwood : We are in transition to Zephyr. DMA scheduling is removed in Zephyr and we have an issue with timer scheduler working, So, till we resolve timer based scheduler issue we need to support XTOS on AMD platforms.

@bhiregoudar ok, do you have a schedule for fixing timer scheduling on AMD ?

Fwiw, we found DMA based scheduling would not scale beyond a few streams as stream start ordering meant DMA IRQs would fire in different sequences/times and could cause a lot of thrash and glitches...

Timer based scheduling works best when the DSP is clock master for the codecs (otherwise you need to add the ASRC), as all pipelines are executed from a single synchronous tick in a deterministic order. Feel free to create an issue and it should gather comments from others who have transitioned to timers for debug.

@bhiregoudar any update here ?

lgirdwood avatar May 19 '25 15:05 lgirdwood

@andrew-mtk pls reply with any comments for Mediatek team. @andyross feedback welcome too.

@andrew-mtk @andyross ping.

lgirdwood avatar May 19 '25 15:05 lgirdwood

@thesofproject/amd @thesofproject/nxp @thesofproject/intel @thesofproject/google @thesofproject/mediatek pls comment/review and provide any feedback. @lgirdwood : We are in transition to Zephyr. DMA scheduling is removed in Zephyr and we have an issue with timer scheduler working, So, till we resolve timer based scheduler issue we need to support XTOS on AMD platforms.

@bhiregoudar ok, do you have a schedule for fixing timer scheduling on AMD ? Fwiw, we found DMA based scheduling would not scale beyond a few streams as stream start ordering meant DMA IRQs would fire in different sequences/times and could cause a lot of thrash and glitches... Timer based scheduling works best when the DSP is clock master for the codecs (otherwise you need to add the ASRC), as all pipelines are executed from a single synchronous tick in a deterministic order. Feel free to create an issue and it should gather comments from others who have transitioned to timers for debug.

@bhiregoudar any update here ?

We have started working on timer scheduler. One question is that, if XTOS is removed, can the already existing platforms continue with XTOS? What about the ToT driver support to the older platforms which uses XTOS? any dependency?

bhiregoudar avatar May 20 '25 16:05 bhiregoudar

@thesofproject/amd @thesofproject/nxp @thesofproject/intel @thesofproject/google @thesofproject/mediatek pls comment/review and provide any feedback. @lgirdwood : We are in transition to Zephyr. DMA scheduling is removed in Zephyr and we have an issue with timer scheduler working, So, till we resolve timer based scheduler issue we need to support XTOS on AMD platforms.

@bhiregoudar ok, do you have a schedule for fixing timer scheduling on AMD ? Fwiw, we found DMA based scheduling would not scale beyond a few streams as stream start ordering meant DMA IRQs would fire in different sequences/times and could cause a lot of thrash and glitches... Timer based scheduling works best when the DSP is clock master for the codecs (otherwise you need to add the ASRC), as all pipelines are executed from a single synchronous tick in a deterministic order. Feel free to create an issue and it should gather comments from others who have transitioned to timers for debug.

@bhiregoudar any update here ?

We have started working on timer scheduler. One question is that, if XTOS is removed, can the already existing platforms continue with XTOS? What about the ToT driver support to the older platforms which uses XTOS? any dependency?

Yes, already existing platforms can continue with SOF v2.13 release branch (Intel does this with SOF v2.2 release branch for older IPC3 platforms).

The main branch is for future/current platforms where we want to accelerate velocity and save effort using Zephyr RTOS.

lgirdwood avatar May 23 '25 11:05 lgirdwood

Work started in https://github.com/thesofproject/sof/pull/10075

kv2019i avatar Jul 01 '25 10:07 kv2019i

@lgirdwood You added a list of tasks including removal of SOF abstractions for dma/trace/memory. Do you want to track them here, or in https://github.com/thesofproject/sof/issues/5794 . I don't think we need to track in both places. XTOS is now removed, and remaining work is to reduce abstractions on SOF side.

kv2019i avatar Jul 03 '25 11:07 kv2019i

@thesofproject/amd @thesofproject/nxp @thesofproject/intel @thesofproject/google @thesofproject/mediatek pls comment/review and provide any feedback. @lgirdwood : We are in transition to Zephyr. DMA scheduling is removed in Zephyr and we have an issue with timer scheduler working, So, till we resolve timer based scheduler issue we need to support XTOS on AMD platforms.

...

We have started working on timer scheduler. One question is that, if XTOS is removed, can the already existing platforms continue with XTOS? What about the ToT driver support to the older platforms which uses XTOS? any dependency?

Yes, already existing platforms can continue with SOF v2.13 release branch (Intel does this with SOF v2.2 release branch for older IPC3 platforms).

The main branch is for future/current platforms where we want to accelerate velocity and save effort using Zephyr RTOS.

Could I regard this as the SOF mainline will no more support XTOS after v2.13. In other words, if one on main branch would like to build XTOS, it should base on the commit no later than v2.13 tag.

By the way, is the use of IPC4 bound together with Zephyr? From my understanding, they should be independent which means Zephyr build + IPC3 should be expected to work as well, is that correct? Is there a plan to remove IPC3?

johnylin76 avatar Jul 05 '25 14:07 johnylin76

@thesofproject/amd @thesofproject/nxp @thesofproject/intel @thesofproject/google @thesofproject/mediatek pls comment/review and provide any feedback. @lgirdwood : We are in transition to Zephyr. DMA scheduling is removed in Zephyr and we have an issue with timer scheduler working, So, till we resolve timer based scheduler issue we need to support XTOS on AMD platforms.

...

We have started working on timer scheduler. One question is that, if XTOS is removed, can the already existing platforms continue with XTOS? What about the ToT driver support to the older platforms which uses XTOS? any dependency?

Yes, already existing platforms can continue with SOF v2.13 release branch (Intel does this with SOF v2.2 release branch for older IPC3 platforms). The main branch is for future/current platforms where we want to accelerate velocity and save effort using Zephyr RTOS.

Could I regard this as the SOF mainline will no more support XTOS after v2.13. In other words, if one on main branch would like to build XTOS, it should base on the commit no later than v2.13 tag.

Yes, that correct. The v2.13 stable branch should be used for any xtos based platforms.

By the way, is the use of IPC4 bound together with Zephyr? From my understanding, they should be independent which means Zephyr build + IPC3 should be expected to work as well, is that correct? Is there a plan to remove IPC3?

No plans to remove IPC3 and Zephyr works well with IPC3.

lgirdwood avatar Jul 07 '25 09:07 lgirdwood

Updated the checkbox list for current work done in v2.14. Basicly XTOS platform support is completely removed, but there v2.14 keeps ability to use XTOS drivers in Zephyr and there are many drivers in the tree that use this. We have moved to many native APIs, but some SOF side abstractions remains.

kv2019i avatar Sep 30 '25 07:09 kv2019i

Updated the checkbox list for current work done in v2.14. Basicly XTOS platform support is completely removed, but there v2.14 keeps ability to use XTOS drivers in Zephyr and there are many drivers in the tree that use this. We have moved to many native APIs, but some SOF side abstractions remains.

@thesofproject/amd @thesofproject/nxp @thesofproject/mediatek whats your status with Zephyr native drivers ? Are you able to start deleting SOF FW drivers in SOF codebase ?

lgirdwood avatar Sep 30 '25 13:09 lgirdwood

Updated the checkbox list for current work done in v2.14. Basicly XTOS platform support is completely removed, but there v2.14 keeps ability to use XTOS drivers in Zephyr and there are many drivers in the tree that use this. We have moved to many native APIs, but some SOF side abstractions remains.

@thesofproject/amd @thesofproject/nxp @thesofproject/mediatek whats your status with Zephyr native drivers ? Are you able to start deleting SOF FW drivers in SOF codebase ?

We have moved to Native Zephyr drivers for DAI, DMA and interrupt. We haven't up streamed the code yet. We are in process of upstream. We need to look into other drivers like mailbaox drivers to move to native driver.

bhiregoudar avatar Oct 07 '25 11:10 bhiregoudar

@thesofproject/amd @thesofproject/nxp @thesofproject/mediatek whats your status with Zephyr native drivers ? Are you able to start deleting SOF FW drivers in SOF codebase ?

We are running with native interfaces on all NXP platforms. There is still the ${SOF_DRIVERS_PATH}/imx/ipc.c we are using from SOF code.

dbaluta avatar Oct 07 '25 12:10 dbaluta

@thesofproject/steering-committee lets make the removal of non Zephyr drivers a topic for next call.

lgirdwood avatar Oct 13 '25 11:10 lgirdwood