Repository navigation
treewide: use the Zephyr atomic names and remove rtos/atomic.h - #11596
Merged
lgirdwood merged 2 commits intoDec 4, 2026
Merged
Conversation
lgirdwood
force-pushed
the
topic/zn-rtos-atomic-names
branch
from
December 3, 2026 12:08
8048431 to
0214abc
Compare
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the migration to native Zephyr atomic APIs.
No open issues 🎉
What changed in this PR
Migrates SOF’s atomic usage to native Zephyr APIs as part of #11517, including the host compatibility groundwork from #11583.
Changes:
- Replaces legacy atomic names and includes, removing both
rtos/atomic.hwrappers. - Adds host atomic, cache, assertion and panic compatibility support.
- Adds native_sim tests for host stub behavior and Zephyr-compatible atomic return values.
| File | Description |
|---|---|
zephyr/include/sof/lib/dma.h |
Uses Zephyr’s atomic header. |
zephyr/include/rtos/atomic.h |
Removes the Zephyr wrapper. |
test/ztest/unit/host_stubs/testcase.yaml |
Registers native_sim tests. |
test/ztest/unit/host_stubs/test_host_stubs_ztest.c |
Tests stub behavior and compatibility. |
test/ztest/unit/host_stubs/prj.conf |
Configures the test application. |
test/ztest/unit/host_stubs/host_stubs.h |
Defines the host-test interface. |
test/ztest/unit/host_stubs/host_stubs.c |
Exercises stubs with host headers. |
test/ztest/unit/host_stubs/CMakeLists.txt |
Separates host and Zephyr compilation. |
src/schedule/zephyr_ll.c |
Uses atomic_get() for task counts. |
src/lib/dma.c |
Uses Zephyr’s atomic header. |
src/kernel/schedule/zephyr_domain-kernel.c |
Migrates atomic task-count reads. |
src/kernel/platform/amd/acp_7_x/lib/clk.c |
Uses Zephyr’s atomic header. |
src/kernel/platform/amd/acp_7_0/lib/clk.c |
Uses Zephyr’s atomic header. |
src/kernel/lib/dma-kernel.c |
Migrates atomic includes and reads. |
src/kernel/lib/agent.c |
Initializes counters with atomic_set(). |
src/kernel/ipc/ipc4/handler-user-kernel.c |
Uses Zephyr’s atomic header. |
src/kernel/ipc/ipc4/handler-ll-user.c |
Uses Zephyr’s atomic header. |
src/kernel/ipc/ipc4/handler-ll-kernel.c |
Uses Zephyr’s atomic header. |
src/kernel/ipc/ipc4/handler-kernel.c |
Migrates delayed-reply atomic reads. |
src/kernel/drivers/generic/dummy-dma.c |
Migrates atomic includes and initialization. |
src/kernel/drivers/amd/rembrandt/acp_sp_dma.c |
Uses Zephyr’s atomic header. |
src/kernel/drivers/amd/rembrandt/acp_hs_dma.c |
Migrates atomic includes and initialization. |
src/kernel/drivers/amd/rembrandt/acp_dmic_dma.c |
Uses Zephyr’s atomic header. |
src/kernel/drivers/amd/rembrandt/acp_bt_dma.c |
Migrates atomic includes and initialization. |
src/kernel/drivers/amd/common/acp_sp_dma.c |
Migrates atomic includes and initialization. |
src/kernel/drivers/amd/common/acp_dmic_dma.c |
Migrates atomic includes and initialization. |
src/kernel/arch/host/include/arch/atomic.h |
Aligns atomic return values with Zephyr. |
src/ipc/ipc4/handler-user.c |
Uses Zephyr’s atomic header. |
src/include/sof/schedule/ll_schedule_domain.h |
Migrates domain counter initialization. |
src/include/sof/lib/agent.h |
Migrates panic-counter reads. |
src/audio/module_adapter/module/dolby/dax.h |
Uses Zephyr’s atomic header. |
src/audio/module_adapter/module/dolby/dax.c |
Migrates host processing-flag reads. |
posix/include/zephyr/sys/atomic.h |
Adds host atomic API stubs. |
posix/include/zephyr/sys/__assert.h |
Adds host assertion macros. |
posix/include/zephyr/cache.h |
Adds unsupported-cache operation stubs. |
posix/include/sof/lib/dma.h |
Uses the host Zephyr atomic header. |
posix/include/sof/lib/agent.h |
Migrates host panic-counter reads. |
posix/include/rtos/panic.h |
Adds host k_panic() support. |
posix/include/rtos/atomic.h |
Removes the host atomic wrapper. |
Review effort: Balanced
atomic_read() and atomic_init() are SOF names for the Zephyr atomic_get() and atomic_set(). Now that the host builds have a <zephyr/sys/atomic.h> stub with the Zephyr names and semantics, use the Zephyr names in all code and remove the SOF ones from both versions of rtos/atomic.h. atomic_set() returns the previous value where atomic_init() returned nothing; no caller uses it. The Zephyr atomic_read() cast the value to long for the printf formats, but atomic_get() returns long on Zephyr already, so the formats are unaffected. No functional change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Both versions of rtos/atomic.h only include <zephyr/sys/atomic.h> now: Zephyr's header on Zephyr, the posix stub on the host. Include it directly and remove rtos/atomic.h. The host arch atomics are now only included from the stub. No functional change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
lgirdwood
force-pushed
the
topic/zn-rtos-atomic-names
branch
from
December 4, 2026 13:08
0214abc to
325fa95
Compare
lgirdwood
marked this pull request as ready for review
December 4, 2026 13:42
lgirdwood
requested review from
LaurentiuM1234,
abonislawski,
bardliao,
bhiregoudar,
dbaluta,
iuliana-prodan,
kv2019i,
lbetlej,
lyakh,
marcinszkudlinski,
mmaka1,
pblaszko,
plbossart,
sunilkumardommati and
tmleman
as code owners
December 4, 2026 13:42
PR 11596: test resultsRun date: 2026-12-04 14:01 UTC Tested commit: 325fa9561d4d2090aa7e33b4b489f1804722af3d |
Member
Author
|
CI unrelated |
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.
Use the Zephyr atomic names in all code and remove
rtos/atomic.h. Part of #11517 (steps 4 and 16). It uses the host<zephyr/sys/atomic.h>stub from #11583.Patches
treewide:atomic_read()/atomic_init()→atomic_get()/atomic_set()(22 call sites), and remove the SOF names from both versions ofrtos/atomic.h.atomic_set()returns the previous value whereatomic_init()returned nothing; no caller uses it.atomic_read()cast its value tolongfor the%ldlog formats.atomic_get()already returnslongon Zephyr, so the formats are unaffected.treewide: include<zephyr/sys/atomic.h>and removertos/atomic.h. Both versions only included<zephyr/sys/atomic.h>after patch 1: Zephyr's header on Zephyr, the stub on the host. The host arch atomics are now only included from the stub.Functional change
None.
Testing
host-testbench.sh) pass all 19 component tests.🤖 Generated with Claude Code