Repository navigation
Phase 1 (part 3): cache helpers, component_ext.h and LL scheduler header cleanup - #11364
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The review has no active issues requiring changes.
No open issues 🎉
What changed in this PR
Continues SOF’s kernel/user-space separation from #11306 by reducing audio code’s dependency on platform memory maps and kernel-facing headers. The diff also includes the stacked cleanup from #11345.
Changes:
- Centralizes cache alias helpers and cold-code attributes in dedicated headers.
- Moves channel and stream limits into Kconfig and updates components, tests, and host tools.
- Separates DAI configuration and public low-latency scheduler helpers from broader headers, removing unused includes and adding explicit dependencies.
| File | Description |
|---|---|
zephyr/lib/pm_runtime.c |
Adds explicit CPU dependency. |
zephyr/include/sof/lib/memory.h |
Delegates cache and cold-code definitions. |
zephyr/include/sof/lib/cold.h |
Extracts cold-code attributes and checks. |
zephyr/include/rtos/sof.h |
Uses cache header for alignment. |
zephyr/include/rtos/cache.h |
Centralizes alignment and cache alias helpers. |
zephyr/include/rtos/alloc.h |
Uses cache header for alignment. |
tools/testbench/utils_ipc4.c |
Uses configured channel limits. |
test/cmocka/src/audio/mux/mux_get_processing_function.c |
Updates test channel limit. |
test/cmocka/src/audio/mux/mux_copy.c |
Updates mux test dimensions and loops. |
test/cmocka/src/audio/mux/demux_copy.c |
Updates demux test dimensions and loops. |
test/cmocka/src/audio/mixer/mixer_test.c |
Uses configured stream limit. |
test/cmocka/src/audio/dcblock/dcblock_process.c |
Updates test channel limits. |
src/schedule/schedule.c |
Includes cold-code definitions explicitly. |
src/samples/audio/smart_amp_test_ipc3.c |
Uses configured channel bounds. |
src/probe/probe.c |
Removes unused component extension include. |
src/platform/tigerlake/include/platform/platform.h |
Removes limits moved to Kconfig. |
src/platform/qemu_xtensa/include/platform/platform.h |
Removes limits moved to Kconfig. |
src/platform/qemu_xtensa/include/platform/lib/memory.h |
Removes local cache alignment definition. |
src/platform/posix/include/platform/platform.h |
Removes limits moved to Kconfig. |
src/platform/posix/include/platform/lib/memory.h |
Removes local alignment and alias definitions. |
src/platform/novalake/include/platform/platform.h |
Removes limits moved to Kconfig. |
src/platform/novalake/include/platform/lib/memory.h |
Removes duplicated cold-code attributes. |
src/platform/mtk/include/platform/platform.h |
Removes limits moved to Kconfig. |
src/platform/mtk/include/platform/lib/memory.h |
Uses centralized cache definitions. |
src/platform/meteorlake/include/platform/platform.h |
Removes limits moved to Kconfig. |
src/platform/meteorlake/include/platform/lib/memory.h |
Removes duplicated cold-code attributes. |
src/platform/lunarlake/include/platform/platform.h |
Removes limits moved to Kconfig. |
src/platform/lunarlake/include/platform/lib/memory.h |
Removes duplicated cold-code attributes. |
src/platform/library/include/platform/platform.h |
Removes limits moved to Kconfig. |
src/platform/library/include/platform/lib/memory.h |
Removes relocated host alias helpers. |
src/platform/Kconfig |
Defines platform channel and stream limits. |
src/platform/intel/cavs/include/cavs/lib/memory.h |
Removes centralized cache definitions. |
src/platform/intel/ace/include/ace/lib/memory.h |
Removes centralized cache definitions. |
src/platform/imx95/include/platform/platform.h |
Removes limits moved to Kconfig. |
src/platform/imx95/include/platform/lib/memory.h |
Removes centralized cache definitions. |
src/platform/imx93_a55/include/platform/platform.h |
Removes limits moved to Kconfig. |
src/platform/imx93_a55/include/platform/lib/memory.h |
Removes centralized cache definitions. |
src/platform/imx8ulp/include/platform/platform.h |
Removes limits moved to Kconfig. |
src/platform/imx8ulp/include/platform/lib/memory.h |
Removes centralized cache definitions. |
src/platform/imx8m/include/platform/platform.h |
Removes limits moved to Kconfig. |
src/platform/imx8m/include/platform/lib/memory.h |
Removes centralized cache definitions. |
src/platform/imx8m_cm7/include/platform/platform.h |
Removes limits moved to Kconfig. |
src/platform/imx8m_cm7/include/platform/lib/memory.h |
Removes centralized cache definitions. |
src/platform/imx8/include/platform/platform.h |
Removes limits moved to Kconfig. |
src/platform/imx8/include/platform/lib/memory.h |
Removes centralized cache definitions. |
src/platform/amd/rembrandt/include/platform/platform.h |
Removes limits moved to Kconfig. |
src/platform/amd/rembrandt/include/platform/lib/memory.h |
Removes centralized cache definitions. |
src/platform/amd/acp_7_x/include/platform/platform.h |
Removes limits moved to Kconfig. |
src/platform/amd/acp_7_x/include/platform/lib/memory.h |
Removes centralized cache definitions. |
src/platform/amd/acp_7_0/include/platform/platform.h |
Removes limits moved to Kconfig. |
src/platform/amd/acp_7_0/include/platform/lib/memory.h |
Removes centralized cache definitions. |
src/platform/ace30/include/platform/platform.h |
Removes limits moved to Kconfig. |
src/platform/ace30/include/platform/lib/memory.h |
Removes duplicated cold-code attributes. |
src/library_manager/lib_manager.c |
Adds explicit DMA dependency. |
src/ipc/ipc4/logging.c |
Adds explicit CPU dependency. |
src/ipc/ipc3/handler.c |
Adds explicit DAI dependency. |
src/ipc/ipc3/dai.c |
Includes extracted DAI component helper. |
src/ipc/ipc-helper.c |
Removes unused platform include. |
src/include/user/smart_amp.h |
Uses configured channel-map dimensions. |
src/include/user/eq.h |
Updates channel-limit names in comments only. |
src/include/sof/tlv.h |
Adds explicit RTOS string dependency. |
src/include/sof/schedule/ll_schedule.h |
Receives timer constants and user lock helpers. |
src/include/sof/schedule/ll_schedule_domain.h |
Delegates public helpers to scheduler header. |
src/include/sof/samples/audio/smart_amp_test.h |
Uses configured channel-map dimensions. |
src/include/sof/ipc/msg.h |
Removes unused platform and memory includes. |
src/include/sof/drivers/mu.h |
Adds explicit memory-map dependency. |
src/include/sof/coherent.h |
Gets alias helpers from cache header. |
src/include/sof/audio/smart_amp/smart_amp.h |
Removes unused platform include. |
src/include/sof/audio/rtnr/rtnr.h |
Removes unused platform include. |
src/include/sof/audio/igo_nr/igo_nr_comp.h |
Removes unused platform include. |
src/include/sof/audio/component.h |
Includes cold-code definitions explicitly. |
src/include/sof/audio/component_ext.h |
Removes DAI helper and driver dependency. |
src/include/sof/audio/component_dai.h |
Houses extracted DAI configuration helper. |
src/idc/zephyr_idc.c |
Adds explicit CPU and memory dependencies. |
src/audio/volume/volume.c |
Uses configured channels and trims includes. |
src/audio/volume/volume_riscv.c |
Uses configured channel array size. |
src/audio/volume/volume_riscv_with_peakvol.c |
Uses configured channel array size. |
src/audio/volume/volume_ipc4.c |
Removes unused broad includes. |
src/audio/volume/volume_ipc3.c |
Updates channel limits and trims includes. |
src/audio/volume/volume_arm.c |
Uses configured channel array size. |
src/audio/volume/volume_arm_with_peakvol.c |
Uses configured channel array size. |
src/audio/up_down_mixer/up_down_mixer.h |
Removes unused component extension include. |
src/audio/up_down_mixer/up_down_mixer_hifi3.c |
Includes panic API for fallback stubs. |
src/audio/tone/tone.h |
Uses configured channel state size. |
src/audio/tone/tone.c |
Removes unused platform include. |
src/audio/tone/tone-ipc4.c |
Updates channel loops and trims includes. |
src/audio/tone/tone-ipc3.c |
Updates channel bounds and trims includes. |
src/audio/tensorflow/tflm-classify.c |
Removes unused platform include. |
src/audio/template/template.h |
Uses configured channel-map size. |
src/audio/tdfb/tdfb.h |
Uses configured microphone limit. |
src/audio/tdfb/tdfb.c |
Updates channel limits and trims includes. |
src/audio/tdfb/tdfb_comp.h |
Updates buffer and channel-state dimensions. |
src/audio/stft_process/stft_process.h |
Uses configured per-channel state sizes. |
src/audio/src/src.c |
Uses configured channel-based delay limits. |
src/audio/src/src_lite.c |
Uses configured channel-based delay limits. |
src/audio/src/src_ipc4.c |
Uses public scheduler header; trims includes. |
src/audio/src/src_ipc3.c |
Removes unused platform include. |
src/audio/src/src_common.c |
Uses configured channel validation limit. |
src/audio/sound_dose/sound_dose.h |
Uses configured per-channel state sizes. |
src/audio/rtnr/rtnr.c |
Removes unused platform include. |
src/audio/pipeline/static_pipeline_modules.c |
Removes unused component extension include. |
src/audio/pipeline/static_pipeline_loader.c |
Includes extracted DAI component helper. |
src/audio/pipeline/pipeline-xrun.c |
Removes unused component extension include. |
src/audio/pipeline/pipeline-stream.c |
Uses public scheduler header. |
src/audio/pipeline/pipeline-schedule.c |
Removes scheduling-domain include. |
src/audio/pipeline/pipeline-graph.c |
Uses public scheduler header. |
src/audio/phase_vocoder/phase_vocoder.h |
Uses configured per-channel state sizes. |
src/audio/mux/mux.h |
Updates channel and stream limits. |
src/audio/mux/mux.c |
Updates channel loops and trims includes. |
src/audio/mux/mux_ipc4.c |
Uses configured channel validation limit. |
src/audio/mux/mux_ipc3.c |
Updates channel loops and trims includes. |
src/audio/mux/mux_generic.c |
Updates lookup-table channel loops. |
src/audio/multiband_drc/multiband_drc.h |
Uses configured per-channel state sizes. |
src/audio/multiband_drc/multiband_drc.c |
Updates channel limits and trims includes. |
src/audio/multiband_drc/multiband_drc_generic.c |
Updates channel dimensions and strides. |
src/audio/module_adapter/module/cadence_ipc4.c |
Uses public scheduler header. |
src/audio/module_adapter/module_adapter.c |
Updates stream limits and scheduler dependency. |
src/audio/module_adapter/module_adapter_ipc4.c |
Updates channel validation; removes platform include. |
src/audio/module_adapter/module_adapter_ipc3.c |
Removes unused platform include. |
src/audio/mixin_mixout/mixin_mixout.h |
Removes unused platform include. |
src/audio/mixin_mixout/mixin_mixout.c |
Removes unused platform include. |
src/audio/mixer/mixer.h |
Removes unused platform include. |
src/audio/mixer/mixer.c |
Uses configured stream limits. |
src/audio/mixer/mixer_hifi3.c |
Uses configured pointer-array dimensions. |
src/audio/mixer/mixer_generic.c |
Uses configured pointer-array dimensions. |
src/audio/mixer/mixer_arm.c |
Uses configured pointer-array dimensions. |
src/audio/mfcc/mfcc.c |
Removes unused platform include. |
src/audio/intel_uaol.c |
Replaces broad include with logging dependency. |
src/audio/igo_nr/igo_nr.c |
Removes unused platform include. |
src/audio/eq_iir/eq_iir.h |
Uses configured filter-state dimensions. |
src/audio/eq_iir/eq_iir.c |
Updates channel limits and trims includes. |
src/audio/eq_iir/eq_iir_riscv.c |
Removes unused platform include. |
src/audio/eq_iir/eq_iir_ipc4.c |
Removes unused platform include. |
src/audio/eq_iir/eq_iir_ipc3.c |
Removes unused platform include. |
src/audio/eq_iir/eq_iir_generic.c |
Removes unused platform include. |
src/audio/eq_iir/eq_iir_arm.c |
Removes unused platform include. |
src/audio/eq_fir/eq_fir.h |
Uses configured filter-state dimensions. |
src/audio/eq_fir/eq_fir.c |
Updates channel limits and trims includes. |
src/audio/drc/drc.h |
Uses configured delay-buffer dimensions. |
src/audio/drc/drc.c |
Updates channel loop; removes platform include. |
src/audio/drc/drc_algorithm.h |
Removes unused platform include. |
src/audio/dcblock/dcblock.h |
Uses configured state and coefficient dimensions. |
src/audio/dcblock/dcblock.c |
Updates channel loop; removes platform include. |
src/audio/crossover/crossover.h |
Uses configured filter-state dimensions. |
src/audio/crossover/crossover.c |
Updates channel limits and trims includes. |
src/audio/copier/ipcgtw_copier.h |
Removes unused component extension include. |
src/audio/copier/host_copier.h |
Removes unused component extension include. |
src/audio/copier/copier.c |
Uses focused DAI, scheduler, and cold headers. |
src/audio/copier/copier_ipcgtw.c |
Removes unused component extension include. |
src/audio/copier/copier_host.c |
Replaces broad includes with cold header. |
src/audio/copier/copier_hifi.c |
Uses cold header; trims component includes. |
src/audio/copier/copier_generic.c |
Replaces broad includes with cold header. |
src/audio/copier/copier_gain.c |
Adds focused cold, component, and DAI dependencies. |
src/audio/copier/copier_dai.c |
Uses extracted helper and explicit platform dependency. |
src/audio/chain_dma.c |
Removes unused component and domain includes. |
src/audio/asrc/asrc.h |
Uses configured channel-pointer dimensions. |
src/audio/asrc/asrc.c |
Removes unused platform include. |
src/audio/aria/aria.h |
Removes unused component extension include. |
posix/include/sof/lib/memory.h |
Delegates cache and cold-code definitions. |
posix/include/sof/lib/cold.h |
Extracts host cold-code stubs. |
posix/include/rtos/cache.h |
Houses host cache alias helpers. |
Review effort: Balanced
3c2a9ed to
a84a130
Compare
| /* invalidate data */ | ||
| #define CACHE_INVALIDATE 1 | ||
|
|
||
| /* |
There was a problem hiding this comment.
And we really should/could be using just the Zephyr functions. Not sure if there are any actual need for these SOF side macros...
There was a problem hiding this comment.
there is not, they will go away soon.
a84a130 to
03253ac
Compare
|
Pushed a fix for the internal CI build failure in "audio: drop unused component_ext.h includes" removed The fix includes |
uncache_to_cache(), cache_to_uncache() and is_uncached() were defined by each platform memory header, so code converting between the cached and uncached alias of an address, such as sof/coherent.h, had to include the platform memory map. Define them once in rtos/cache.h: ACE uses the Zephyr cache API as before, cAVS keeps its SRAM alias arithmetic, and the other Zephyr platforms, which have no uncached alias, use the address unchanged with is_uncached() returning 0, as they did. The host library keeps its own definitions in the posix rtos/cache.h, and both sof/lib/memory.h variants include rtos/cache.h so existing users are unaffected. No functional change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
sof/coherent.h only needs PLATFORM_DCACHE_ALIGN, DCACHE_LINE_SIZE, the cache maintenance calls and the cached/uncached alias helpers, all of which rtos/cache.h now provides. Including sof/lib/memory.h instead made every user of the buffer and component API depend on the platform memory map. Include rtos/cache.h instead. Components relied on this path for the cold code attributes, so include sof/lib/cold.h from component.h, which is where they are used. No functional change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
comp_dai_config() is the only part of component_ext.h that needs the DAI driver definitions, and only the copier DAI, the static pipeline loader and the IPC3 DAI code use it. Move it to a new sof/audio/component_dai.h so that component_ext.h no longer includes sof/lib/dai.h and, through it, the DMA and Zephyr DAI driver headers. Files that used DAI or DMA definitions they got through component_ext.h now include sof/lib/dai.h or sof/lib/dma.h directly. No functional change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
PLATFORM_MAX_STREAMS is only used by audio processing code (mixer, mux, module adapter) to size per-stream state, but it was defined in every platform header, so that code depended on sof/platform.h. Add CONFIG_PLATFORM_MAX_STREAMS with defaults that match the existing values (5 for the i.MX, MediaTek and AMD Zephyr builds, 8 for i.MX8M and qemu_xtensa, 16 otherwise, including the host library and unit tests, which used the library platform), use it everywhere and drop the per-platform definitions. Like CONFIG_PLATFORM_MAX_CHANNELS it has no prompt. No functional change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
They only used PLATFORM_MAX_STREAMS from it, which is now a Kconfig option. No functional change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
Audio code uses LL_TIMER_PERIOD_US and, in user-space LL builds, the user_ll_lock_sched(), user_ll_unlock_sched() and user_ll_assert_locked() helpers, but these are declared in ll_schedule_domain.h, which also holds the scheduling domain driver interface and pulls in the clock and memory map headers. Move them to ll_schedule.h, the LL scheduler API, and include it from ll_schedule_domain.h so that existing users are unaffected. No functional change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
The audio components and the pipeline only need the LL period and the user LL lock helpers, which are now in ll_schedule.h, or nothing from it at all. Include ll_schedule.h instead of ll_schedule_domain.h, or drop the include. No functional change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
tlv.h uses memcpy_s() but relied on its users including rtos/string.h first. No functional change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
intel_uaol.c uses LOG_MODULE_REGISTER() but got zephyr/logging/log.h only indirectly. No functional change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
The stubs used without HiFi3 call sof_panic() but got rtos/panic.h only indirectly. No functional change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
The aria, up/down mixer, volume, probe, UAOL, chain DMA and most of the copier sources, the pipeline xrun code and the static pipeline module list include sof/audio/component_ext.h but use nothing from it. It pulls in rtos/idc.h for its cross-core helpers, and through that the platform memory map and clock headers. Drop the includes; copier_gain.c and copier_generic.c now include sof/audio/component.h, which they used through it (copier_generic.c only included it itself for the generic, non-HiFi copier). No functional change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
The copier sources only use __cold from sof/lib/memory.h. Include sof/lib/cold.h instead. No functional change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
03253ac to
b183701
Compare
PR 11364: test resultsRun date: 2026-11-01 18:35 UTC Tested commit: b183701e303c2c24075c8cc450b6330a9b3a008b |
Phase 1 of #11306 (kernel / user-space partition), third part: more user-space code stops including the platform memory map and the DAI, IDC and scheduling domain headers. Follows #11345.
Patches
Cache alias helpers in
rtos/cache.h:uncache_to_cache(),cache_to_uncache()andis_uncached()are defined once instead of in every platform memory header:sys_cache_*_ptr_get()/sys_cache_is_ptr_cached()API, as before;is_uncached()still returns 0.The host library keeps its own definitions.
sof/coherent.h: includesrtos/cache.hinstead of the platform memory map.comp_dai_config(): moved fromcomponent_ext.hto a newsof/audio/component_dai.h, socomponent_ext.hno longer includessof/lib/dai.hand the DMA and DAI driver headers behind it.CONFIG_PLATFORM_MAX_STREAMS(new): replaces the per-platformPLATFORM_MAX_STREAMS, followingCONFIG_PLATFORM_MAX_CHANNELSfrom Phase 1 (part 2): stop user-space code depending on the platform memory map and headers #11345. The defaults equal today's values: 5 for the i.MX, MediaTek and AMD Zephyr builds, 8 for i.MX8M and qemu_xtensa, and 16 otherwise, including the host library and unit tests. Like the channel option, it has no prompt. The mixer, mux and module adapter then dropsof/platform.h.LL scheduler:
LL_TIMER_PERIOD_USand the user LL lock helpers (user_ll_lock_sched(),user_ll_unlock_sched(),user_ll_assert_locked()) move fromll_schedule_domain.htoll_schedule.h. Audio code then stops including the scheduling domain header, which holds the domain driver interface and pulls in the clock headers.component_ext.h: dropped from the 18 sources and headers that use nothing from it. It includesrtos/idc.hfor its cross-core helpers, and only the pipeline, KPB,component.c, IPC and IDC code use those.Copier: includes
sof/lib/cold.hinstead ofsof/lib/memory.h;__coldis all it used.Missing includes: three of them were hidden by the indirect includes removed here (
tlv.h→rtos/string.h,intel_uaol.c→ the logging header, the non-HiFi3 up/down mixer stubs →rtos/panic.h). Each gets its own patch, ahead of the patch that exposed it.Files that still use something from the headers they no longer get indirectly now include those headers themselves.
Functional change
None. Every patch leaves the generated code unchanged.
Effect
Measured with
scripts/check_kernel_includes.pyon PTL, as the number of user-space sources including each header, before and after this PR:sof/lib/memory.h(platform memory map)zephyr/drivers/dma.h,sof/lib/io.hrtos/idc.hrtos/clk.hsof/platform.hWhat remains is mostly real kernel dependencies, which later parts need to replace with syscalls or move to the kernel:
component_ext.h, used by the pipeline;dai-zephyr.h;Testing
CONFIG_SOF_USERSPACE_PROXY=n, and PTL and MTL withos_linux_overlay.conf;llext_relocatable.conf.CSWTCH,.str.N) that are numbered differently because fewer headers are included. In the ASan fuzz builds those names are stored as strings.platform.c, which embeds the git version, and the PTL LLEXT link addresses, which also differ between two builds of the same commit.All of the above was run on cbbff04 (current main).
🤖 Generated with Claude Code