Repository navigation
treewide: remove k_spinlock_init() - #11599
Merged
lgirdwood merged 1 commit intoDec 4, 2026
Merged
Conversation
lgirdwood
force-pushed
the
topic/zn-rtos-spinlock-init
branch
from
December 4, 2026 13:08
40d1b7e to
cbadb44
Compare
lgirdwood
marked this pull request as ready for review
December 4, 2026 13:49
lgirdwood
requested review from
abonislawski,
bardliao,
bhiregoudar,
dbaluta,
fkwasowi,
iganakov,
iuliana-prodan,
kv2019i,
lbetlej,
lyakh,
mmaka1,
pblaszko,
plbossart,
sunilkumardommati and
tmleman
as code owners
December 4, 2026 13:49
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The spinlock header retains an orphaned Doxygen block that contradicts the zero-initialization contract and should be removed.
1 open issue
What changed in this PR
Removes SOF’s k_spinlock_init() wrapper as part of the transition to native Zephyr APIs in #11517, relying on existing zero-initialization.
Changes:
- Removes the Zephyr initializer and host stub.
- Deletes redundant initialization calls and lock-only loops.
- Preserves mutex initialization where required.
| File | Description |
|---|---|
| zephyr/lib/dma.c | Removes lock initialization loop; scopes remaining loop variable. |
| zephyr/include/rtos/spinlock.h | Removes Zephyr initializer wrapper. |
| src/lib/notifier.c | Removes notifier lock initialization. |
| src/kernel/platform/amd/rembrandt/lib/dma.c | Removes DMA lock initialization loop. |
| src/kernel/platform/amd/rembrandt/lib/dai.c | Removes DAI lock initialization loops. |
| src/kernel/lib/cpu-clk-manager.c | Removes KCPS lock initialization. |
| src/kernel/ipc/ipc-common-kernel.c | Removes IPC lock initialization. |
| src/kernel/drivers/interrupt.c | Removes interrupt cascade lock initialization. |
| src/kernel/debug/telemetry/performance_monitor.c | Removes monitor lock initialization. |
| src/include/sof/schedule/ll_schedule_domain.h | Removes spinlock initialization; retains mutex setup. |
| src/include/sof/coherent.h | Removes coherent-object lock initialization. |
| src/audio/pipeline/pipeline-graph.c | Removes position spinlock initialization; retains mutex setup. |
| src/audio/module_adapter/module/dolby/dax.c | Removes DAX lock initialization. |
| src/audio/kpb.c | Replaces host initializer call with explanatory comment. |
| src/audio/dai-zephyr.c | Removes DAI lock initialization. |
| posix/include/rtos/spinlock.h | Removes no-op host initializer macro. |
| posix/include/rtos/mutex.h | Removes redundant host spinlock initializer call. |
Review effort: Balanced
| #endif | ||
| } | ||
|
|
||
| #endif /* __ZEPHYR_RTOS_SPINLOCK_H__ */ |
Member
Author
There was a problem hiding this comment.
Fixed in c58f933: the block is gone, the file brief no longer mentions initialization, and in its place the header notes that Zephyr has no spinlock initializer and that a zero-filled struct k_spinlock is unlocked. I also checked the other removed calls for leftover comments; there were none.
Zephyr has no spinlock initializer: a struct k_spinlock is ready to use when its memory is zero. k_spinlock_init() is an SOF addition that clears the locked flag on SMP builds, and does nothing on the host. Every lock it initializes is already zero: the containers come from rzalloc() or mod_zalloc(), are memset() after allocation (dai_get(), domain_init()) or are static (the DMA and AMD DAI tables, the kcps and I/O performance monitor data, the pipeline position and IRQ cascade root). Where an init function can run again, the lock is not held, and Zephyr leaves an unlocked spinlock all zero. Remove the calls and both definitions. Loops that only initialized the locks go with them. 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-spinlock-init
branch
from
December 4, 2026 16:10
cbadb44 to
c58f933
Compare
kv2019i
approved these changes
Dec 4, 2026
Member
Author
|
CI infra issues on internal CI. |
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.

Remove
k_spinlock_init(). Part of #11517 (step 2).Zephyr has no spinlock initializer: a
struct k_spinlockis ready to use when its memory is zero.k_spinlock_init()is an SOF addition that clears the locked flag on SMP builds and does nothing on the host.Why removing it is safe
Every lock it initializes is already zero:
dai_get()), schedule domain (domain_init())memset()orrzalloc()rzalloc()mod_zalloc()k_mutex_init()Where an init function can run again, the lock is not held at that point. Zephyr leaves an unlocked spinlock all zero (
lockedis 0, and theCONFIG_SPIN_VALIDATEowner is cleared on unlock), so the call did nothing there either.The loops that only initialized the locks are removed with the calls.
The Zephyr
rtos/spinlock.hnow only notes that Zephyr has no spinlock initializer and that a zero-filledstruct k_spinlockis unlocked.Functional change
None. The Zephyr builds no longer store a zero into locks that are already zero.
Testing
domain_init()and the coherent API, where the zero stores are removed.host-testbench.sh) pass all 19 component tests.🤖 Generated with Claude Code