Repository navigation
Conversation
dcache_writeback_region(), dcache_invalidate_region() and icache_invalidate_region() are inline wrappers of sys_cache_data_flush_range(), sys_cache_data_invd_range() and sys_cache_instr_invd_range(). Call the Zephyr functions directly in the code that only Zephyr builds: the library and LLEXT managers, the probes, firmware init, the cAVS IMR layout update, the L3 heap save and fast-get. The callers used to cast their pointers to __sparse_cache only to match the wrapper prototypes. Pointers that really are __sparse_cache keep a __sparse_force cast, integer addresses get a plain (void *) cast, and other pointers are passed as they are. The shared code also builds on the host, so it keeps the wrappers until the host has a <zephyr/cache.h> stub. No functional change. With one inline function less, GCC allocates registers and lays out branches differently in a few of the callers, such as the probe buffer copies and fast_get(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
This was referenced Dec 1, 2026
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the migration to native Zephyr cache APIs.
No open issues 🎉
What changed in this PR
This PR advances #11517’s migration to native Zephyr APIs by replacing SOF cache wrappers in Zephyr-only code. Shared, host-built code retains the wrappers; no functional change is intended.
Changes:
- Replace cache writeback and invalidation wrappers with direct Zephyr cache calls.
- Simplify pointer casts while preserving required sparse address-space conversions.
- Add Zephyr cache headers where needed.
| File | Description |
|---|---|
zephyr/lib/fast-get.c |
Use direct cache calls for fast-memory access and copies. |
zephyr/lib/alloc.c |
Flush saved L3 heap state through Zephyr. |
src/kernel/probe/probe.c |
Use Zephyr cache calls for probe buffers and headers. |
src/kernel/platform/intel/cavs/platform.c |
Use Zephyr cache calls when updating the IMR layout. |
src/kernel/library_manager/llext_manager.c |
Replace data and instruction cache wrappers during extension loading. |
src/kernel/library_manager/llext_manager_dram.c |
Flush saved library state through Zephyr. |
src/kernel/library_manager/lib_manager.c |
Use direct cache flushes when loading and storing libraries. |
src/kernel/init/init.c |
Flush unpacked LP SRAM data through Zephyr. |
Review effort: Balanced
lgirdwood
marked this pull request as ready for review
December 1, 2026 20:21
lgirdwood
requested review from
abonislawski,
dabekjakub,
dbaluta,
iuliana-prodan,
kv2019i,
lbetlej,
lyakh,
mmaka1 and
plbossart
as code owners
December 1, 2026 20:21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Call the Zephyr cache API directly in the code that only Zephyr builds. Part of #11517 (step 2, "Kernel-only code: switch to Zephyr APIs directly").
Changes
dcache_writeback_region(),dcache_invalidate_region()andicache_invalidate_region()are inline wrappers ofsys_cache_data_flush_range(),sys_cache_data_invd_range()andsys_cache_instr_invd_range(). Their callers in Zephyr-only code now call the Zephyr functions directly:lp_sram_unpack());The callers used to cast to
__sparse_cacheonly to match the wrapper prototypes. Pointers that really are__sparse_cachekeep a__sparse_forcecast, integer addresses get a plain(void *)cast, and other pointers are passed as they are.Not in this PR
coherent.h,audio_stream.h, the buffers, the mailbox, IPC): it also builds on the host, so it keeps the wrappers until the host has a<zephyr/cache.h>stub.uncache_to_cache(),cache_to_uncache()andis_uncached(): cAVS uses its own address alias arithmetic for these, so they need a Zephyr change and a TGL test first.Functional change
None. With one inline function less, GCC allocates registers and lays out branches differently in a few of the callers, such as the probe buffer copies and
fast_get().Testing
🤖 Generated with Claude Code