Repository navigation
Conversation
b1333f3 to
8edd6d5
Compare
|
Intention is that user modules should use posix style assert macros, but kernel modules or code should use native zephyr. Pls check and rework the PR. |
On Zephyr, rtos/panic.h includes <zephyr/kernel.h>, so code that includes it for assert() also gets __ASSERT() and __ASSERT_NO_MSG(). Include the <zephyr/sys/__assert.h> stub from the host rtos/panic.h, so that the kernel code that is also built for the host can use the Zephyr macros without new includes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Kernel code uses the native Zephyr API, while user code, such as the audio modules, keeps the POSIX assert() so that it can be shared with POSIX programs. The kernel-only code that the Zephyr builds alone compile already uses __ASSERT_NO_MSG(). Convert the remaining kernel code, which is also built for the host: the IPC handlers, the IPC3 DAI code, the IPC4 notifications and the dummy DMA driver. The host provides the Zephyr assert macros through rtos/panic.h. On Zephyr, assert() is defined as __ASSERT_NO_MSG(). No lines are added or removed, so __LINE__ in verbose asserts does not change. No functional change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
8edd6d5 to
4d4fc69
Compare
|
Reworked in 4d4fc69: only the kernel code is converted now (9 sites in the IPC handlers, the IPC3 DAI code, the IPC4 notifications and the dummy DMA driver), and the user code keeps the POSIX |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the kernel assertion migration to native Zephyr APIs.
No open issues 🎉
What changed in this PR
Continues SOF’s migration to native Zephyr APIs by updating assertions in kernel code that also builds on the host, while leaving user-code assertions unchanged.
Changes:
- Replace kernel
assert()calls with__ASSERT_NO_MSG(). - Expose the host Zephyr assertion stub through
rtos/panic.h.
| File | Description |
|---|---|
src/kernel/ipc/ipc4/notification.c |
Convert the unsupported-event assertion. |
src/kernel/ipc/ipc4/handler-kernel.c |
Convert reply-copy and core-ID assertions. |
src/kernel/ipc/ipc3/handler.c |
Convert IPC copy assertions. |
src/kernel/ipc/ipc3/dai.c |
Convert the configuration-pointer assertion. |
src/kernel/ipc/ipc-common-kernel.c |
Convert message-copy assertions. |
src/kernel/drivers/generic/dummy-dma.c |
Convert the DMA-copy assertion. |
posix/include/rtos/panic.h |
Include the host Zephyr assertion stub. |
Review effort: Balanced
PR 11597: test resultsRun date: 2026-12-05 16:00 UTC Tested commit: 4d4fc696f37d06feffbfca84b28a7368e12c19ea |
Use the Zephyr
__ASSERT_NO_MSG()instead ofassert()in the kernel code that is also built for the host. Part of #11517 (step 6).Reworked after review: kernel code uses the native Zephyr API, while user code, such as the audio modules, keeps the POSIX
assert()so that it can be shared with POSIX programs. The earlier version of this PR also converted the user code; that part is dropped.Patches
posix: the hostrtos/panic.hincludes the<zephyr/sys/__assert.h>stub, asrtos/panic.hgets the Zephyr macros through<zephyr/kernel.h>on Zephyr. The kernel code that is also built for the host then needs no new includes.kernel:assert()→__ASSERT_NO_MSG()in the remaining kernel code (9 sites): the IPC handlers (ipc-common-kernel.c, IPC3handler.c, IPC4handler-kernel.c), the IPC3 DAI code, the IPC4 notifications and the dummy DMA driver. No lines are added or removed, so__LINE__in verbose asserts does not change. The kernel-only code that only the Zephyr builds compile was converted in zephyr: use the Zephyr assert and panic macros in kernel-only code #11572.Not in this PR
User code (
src/audio,src/ipc,src/lib,src/module,src/samplesand the shared headers insrc/include) keepsassert().Functional change
None on Zephyr, where
assert()is defined as__ASSERT_NO_MSG(). On the host, these kernel asserts always end in the SOF panic.Testing
Tested together with #11598 on main 73a7797:
host-testbench.sh) pass all 19 component tests.🤖 Generated with Claude Code