From 4830bea796e8024576ee5d9d38a17148a0e5d938 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 6 Nov 2026 20:14:38 +0000 Subject: [PATCH 1/7] kernel: add src/kernel to the host builds The next moves bring kernel code that the host builds (testbench, host library) also compile to src/kernel. Add src/kernel to src/CMakeLists.txt, which only the host builds use; Zephyr adds it from zephyr/CMakeLists.txt. Everything in src/kernel so far is only built for Zephyr, so add those subdirectories only for Zephyr builds. No functional change: the host builds compile the same files as before. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/CMakeLists.txt | 1 + src/kernel/CMakeLists.txt | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cd068b8b5edc..5dbe65d29a51 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,6 +13,7 @@ if(CONFIG_SAMPLES) endif() add_subdirectory(drivers) +add_subdirectory(kernel) if (CONFIG_TRACE) add_subdirectory(trace) diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt index da1df9328654..2b315cb7d4d3 100644 --- a/src/kernel/CMakeLists.txt +++ b/src/kernel/CMakeLists.txt @@ -2,21 +2,25 @@ # Code that only runs in kernel mode, see scripts/kernel_user_partition.txt. +# Zephyr adds this directory from zephyr/CMakeLists.txt, the host builds +# (testbench, host library) from src/CMakeLists.txt. + is_zephyr(zephyr) if(zephyr) # Build everything below into the sof_kernel library created in # zephyr/CMakeLists.txt instead of modules_sof. This only sets the # variable for this directory and its subdirectories. set(ZEPHYR_CURRENT_LIBRARY sof_kernel) -endif() -add_subdirectory(audio) -add_subdirectory(debug) -add_subdirectory(idc) -add_subdirectory(init) -add_subdirectory(ipc) -add_subdirectory(lib) -add_subdirectory(library_manager) -add_subdirectory(logging) -add_subdirectory(probe) -add_subdirectory(schedule) + # Only built for Zephyr + add_subdirectory(audio) + add_subdirectory(debug) + add_subdirectory(idc) + add_subdirectory(init) + add_subdirectory(ipc) + add_subdirectory(lib) + add_subdirectory(library_manager) + add_subdirectory(logging) + add_subdirectory(probe) + add_subdirectory(schedule) +endif() From d2926b2d221003e1f85f31cff6b6d3871074b7d4 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 6 Nov 2026 20:15:48 +0000 Subject: [PATCH 2/7] ipc: move ipc3 to src/kernel/ipc/ipc3 The IPC3 handler runs in kernel mode. Move it to src/kernel/ipc/ipc3, where Zephyr builds it into the sof_kernel library. The host builds (the IPC3 testbench and host library) now get it from src/kernel/ipc, which is added for them as well. Update the cmocka and ztest unit tests that build ipc3/helper.c, the example patch in fuzz.sh, the comments that name the files and the user-space README. Give src/kernel/ipc the same CODEOWNERS as src/ipc. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- CODEOWNERS | 1 + scripts/fuzz.sh | 4 ++-- src/audio/dai-zephyr.c | 6 +++--- src/include/sof/userspace/README.md | 2 +- src/ipc/CMakeLists.txt | 6 ++---- src/kernel/CMakeLists.txt | 4 +++- src/kernel/ipc/CMakeLists.txt | 4 ++++ src/{ => kernel}/ipc/ipc3/CMakeLists.txt | 0 src/{ => kernel}/ipc/ipc3/README.md | 0 src/{ => kernel}/ipc/ipc3/dai.c | 0 src/{ => kernel}/ipc/ipc3/handler.c | 0 src/{ => kernel}/ipc/ipc3/helper.c | 0 src/{ => kernel}/ipc/ipc3/host-page-table.c | 0 src/lib/dai.c | 4 ++-- test/cmocka/src/audio/buffer/CMakeLists.txt | 8 ++++---- test/cmocka/src/audio/component/CMakeLists.txt | 2 +- test/cmocka/src/audio/dcblock/CMakeLists.txt | 2 +- test/cmocka/src/audio/eq_fir/CMakeLists.txt | 2 +- test/cmocka/src/audio/eq_iir/CMakeLists.txt | 2 +- test/cmocka/src/audio/mixer/CMakeLists.txt | 2 +- test/cmocka/src/audio/mux/CMakeLists.txt | 2 +- test/cmocka/src/audio/pcm_converter/CMakeLists.txt | 2 +- test/cmocka/src/audio/pipeline/CMakeLists.txt | 6 +++--- test/cmocka/src/audio/selector/CMakeLists.txt | 2 +- test/cmocka/src/audio/volume/CMakeLists.txt | 2 +- test/cmocka/src/math/fft/CMakeLists.txt | 2 +- test/ztest/unit/audio/drc/CMakeLists.txt | 2 +- test/ztest/unit/math/fft/CMakeLists.txt | 2 +- 28 files changed, 37 insertions(+), 32 deletions(-) rename src/{ => kernel}/ipc/ipc3/CMakeLists.txt (100%) rename src/{ => kernel}/ipc/ipc3/README.md (100%) rename src/{ => kernel}/ipc/ipc3/dai.c (100%) rename src/{ => kernel}/ipc/ipc3/handler.c (100%) rename src/{ => kernel}/ipc/ipc3/helper.c (100%) rename src/{ => kernel}/ipc/ipc3/host-page-table.c (100%) diff --git a/CODEOWNERS b/CODEOWNERS index 88e3eab8d843..846bf54e2136 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -60,6 +60,7 @@ src/drivers/mediatek/** @yaochunhung @kuanhsuncheng # other libs src/math/* @singalsu src/ipc/* @bardliao @tmleman @pblaszko +src/kernel/ipc/** @bardliao @tmleman @pblaszko # src/lib/* TODO src/schedule @pblaszko @marcinszkudlinski @dbaluta @LaurentiuM1234 diff --git a/scripts/fuzz.sh b/scripts/fuzz.sh index 27ff96dc637f..d6b69e7501c9 100755 --- a/scripts/fuzz.sh +++ b/scripts/fuzz.sh @@ -68,8 +68,8 @@ EOFHELP # To test this test, make the following change locally: : < Date: Fri, 6 Nov 2026 20:17:38 +0000 Subject: [PATCH 3/7] ipc4: move the kernel-only IPC4 files to src/kernel/ipc/ipc4 handler-kernel.c is the kernel IPC4 dispatcher and holds the kernel half of the compound-message and reply system calls, notification.c sends notifications to the host and holds the kernel half of send_resource_notif(), and logging.c drives the mtrace log buffer notifications. All three run in kernel mode. Move them to src/kernel/ipc/ipc4, where Zephyr builds them into the sof_kernel library; the host builds get them from src/kernel/ipc as well. The user-side files handler-user.c, notification-user.c, helper.c, dai.c and ams_helpers.c stay in src/ipc/ipc4. Update the IPC READMEs, the user-space README and a comment in the posix IPC fuzzing harness. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/include/sof/userspace/README.md | 2 +- src/ipc/README.md | 5 +++-- src/ipc/ipc4/CMakeLists.txt | 3 --- src/ipc/ipc4/README.md | 7 ++++--- src/kernel/ipc/CMakeLists.txt | 2 ++ src/kernel/ipc/ipc4/CMakeLists.txt | 8 ++++++++ src/{ => kernel}/ipc/ipc4/handler-kernel.c | 0 src/{ => kernel}/ipc/ipc4/logging.c | 0 src/{ => kernel}/ipc/ipc4/notification.c | 0 src/platform/posix/ipc.c | 2 +- 10 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 src/kernel/ipc/ipc4/CMakeLists.txt rename src/{ => kernel}/ipc/ipc4/handler-kernel.c (100%) rename src/{ => kernel}/ipc/ipc4/logging.c (100%) rename src/{ => kernel}/ipc/ipc4/notification.c (100%) diff --git a/src/include/sof/userspace/README.md b/src/include/sof/userspace/README.md index e4cf7481472d..9747fb604c3f 100644 --- a/src/include/sof/userspace/README.md +++ b/src/include/sof/userspace/README.md @@ -116,7 +116,7 @@ syscall by subsystem: | Subsystem | Syscalls | Declared in | Validator (`z_vrfy_`) / logic (`z_impl_`) | |-----------|----------|-------------|-------------------------------------------| -| IPC | `ipc_msg_send`, `ipc_msg_list_remove`, `ipc_msg_reply`, `ipc_compound_pre_start`, `ipc_compound_post_start`, `ipc_wait_for_compound_msg`, `send_resource_notif` | `sof/ipc/msg.h`, `sof/ipc/ipc_reply.h`, `ipc4/handler.h`, `ipc4/notification.h` | scattered: `ipc/ipc-common.c`, `kernel/ipc/ipc3/helper.c`, `ipc/ipc4/handler-kernel.c`, `ipc/ipc4/notification.c` | +| IPC | `ipc_msg_send`, `ipc_msg_list_remove`, `ipc_msg_reply`, `ipc_compound_pre_start`, `ipc_compound_post_start`, `ipc_wait_for_compound_msg`, `send_resource_notif` | `sof/ipc/msg.h`, `sof/ipc/ipc_reply.h`, `ipc4/handler.h`, `ipc4/notification.h` | scattered: `ipc/ipc-common.c`, `kernel/ipc/ipc3/helper.c`, `kernel/ipc/ipc4/handler-kernel.c`, `kernel/ipc/ipc4/notification.c` | | Heap alloc | `sof_heap_alloc`, `sof_heap_free` | `rtos/alloc.h` | `zephyr/syscall/alloc.c` / `zephyr/lib/alloc.c` | | Virtual regions | `vregion_create_map`, `vregion_set_interim`, `vregion_get`, `vregion_put`, `vregion_alloc_align`, `vregion_alloc_coherent_align`, `vregion_free` | `sof/lib/vregion.h` | `zephyr/syscall/vregion.c` / `zephyr/lib/vregion.c` | | DMA | `sof_dma_get`, `sof_dma_put`, `sof_dma_get_attribute`, `sof_dma_request_channel`, `sof_dma_release_channel`, `sof_dma_config`, `sof_dma_start`, `sof_dma_stop`, `sof_dma_get_status`, `sof_dma_reload`, `sof_dma_suspend`, `sof_dma_resume` | `sof/lib/sof_dma.h` | `zephyr/syscall/sof_dma.c` / `lib/dma.c` (get/put); remaining 10 are `static inline z_impl_*` in `sof/lib/sof_dma.h` | diff --git a/src/ipc/README.md b/src/ipc/README.md index f2a13ff1ce57..844c13a84f1b 100644 --- a/src/ipc/README.md +++ b/src/ipc/README.md @@ -2,8 +2,9 @@ > **Runs in:** Boundary / bridge — the kernel receives and dispatches IPC, then forwards > module-facing commands to a user thread. The split is visible in the file names -> (`ipc4/handler-kernel.c` vs `ipc4/handler-user.c`, `ipc4/notification-user.c`), and this -> subsystem hosts the `ipc_msg_*`, `ipc_compound_*` and `send_resource_notif` syscalls. See +> (`src/kernel/ipc/ipc4/handler-kernel.c` vs `ipc4/handler-user.c`, +> `ipc4/notification-user.c`), and this subsystem hosts the `ipc_msg_*`, `ipc_compound_*` and +> `send_resource_notif` syscalls. See > [User/kernel split](../include/sof/userspace/README.md). This directory contains the common foundation for all Inter-Processor Communication (IPC) within the Sound Open Firmware (SOF) project. It bridges the gap between hardware mailbox interrupts and the version-specific (IPC3/IPC4) message handlers. diff --git a/src/ipc/ipc4/CMakeLists.txt b/src/ipc/ipc4/CMakeLists.txt index c9f9fcb5710d..cd7984becd40 100644 --- a/src/ipc/ipc4/CMakeLists.txt +++ b/src/ipc/ipc4/CMakeLists.txt @@ -3,10 +3,7 @@ # Files common to Zephyr and XTOS add_local_sources(sof handler-user.c - handler-kernel.c helper.c - logging.c - notification.c notification-user.c ) diff --git a/src/ipc/ipc4/README.md b/src/ipc/ipc4/README.md index 955042576c8a..237a7c1ecb36 100644 --- a/src/ipc/ipc4/README.md +++ b/src/ipc/ipc4/README.md @@ -1,8 +1,9 @@ # IPC4 Architecture -> **Runs in:** Boundary / bridge — `handler-kernel.c` runs in the kernel dispatcher; -> `handler-user.c` and `notification-user.c` run in the user thread that services modules. The -> `z_vrfy_`/`z_impl_` pairs for the compound-message and reply syscalls live here. See +> **Runs in:** Boundary / bridge — `handler-user.c` and `notification-user.c` run in the user +> thread that services modules. Their kernel counterparts, `handler-kernel.c` (the kernel +> dispatcher) and `notification.c`, are in `src/kernel/ipc/ipc4`, together with the +> `z_vrfy_`/`z_impl_` pairs for the compound-message, reply and notification syscalls. See > [User/kernel split](../../include/sof/userspace/README.md). This directory holds the handlers and topology parsing logic for Inter-Processor Communication Version 4. IPC4 introduces a significantly denser, compound-command structure heavily based around the concept of "pipelines" and dynamic "modules" rather than static DSP stream roles. diff --git a/src/kernel/ipc/CMakeLists.txt b/src/kernel/ipc/CMakeLists.txt index 6d9c37029e8f..ef3e57f01113 100644 --- a/src/kernel/ipc/CMakeLists.txt +++ b/src/kernel/ipc/CMakeLists.txt @@ -2,6 +2,8 @@ if (CONFIG_IPC_MAJOR_3) add_subdirectory(ipc3) +elseif (CONFIG_IPC_MAJOR_4) + add_subdirectory(ipc4) endif() is_zephyr(zephyr) diff --git a/src/kernel/ipc/ipc4/CMakeLists.txt b/src/kernel/ipc/ipc4/CMakeLists.txt new file mode 100644 index 000000000000..53a37d553675 --- /dev/null +++ b/src/kernel/ipc/ipc4/CMakeLists.txt @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: BSD-3-Clause + +# Files common to Zephyr and the host library +add_local_sources(sof + handler-kernel.c + logging.c + notification.c +) diff --git a/src/ipc/ipc4/handler-kernel.c b/src/kernel/ipc/ipc4/handler-kernel.c similarity index 100% rename from src/ipc/ipc4/handler-kernel.c rename to src/kernel/ipc/ipc4/handler-kernel.c diff --git a/src/ipc/ipc4/logging.c b/src/kernel/ipc/ipc4/logging.c similarity index 100% rename from src/ipc/ipc4/logging.c rename to src/kernel/ipc/ipc4/logging.c diff --git a/src/ipc/ipc4/notification.c b/src/kernel/ipc/ipc4/notification.c similarity index 100% rename from src/ipc/ipc4/notification.c rename to src/kernel/ipc/ipc4/notification.c diff --git a/src/platform/posix/ipc.c b/src/platform/posix/ipc.c index 64fb21358962..2989e9637e7b 100644 --- a/src/platform/posix/ipc.c +++ b/src/platform/posix/ipc.c @@ -352,7 +352,7 @@ static void fuzz_isr(const void *arg) // The harness also mirrors the framed message into MAILBOX_HOSTBOX so // that handlers reading payload directly from the hostbox region // (large_config_set/get, set_dx, set_pipeline_state, vendor_config and -// friends in ipc4/handler-user.c and ipc4/handler-kernel.c) observe +// friends in ipc4/handler-user.c and kernel/ipc/ipc4/handler-kernel.c) observe // the fuzz bytes rather than stale or zero-filled memory. // // The two IPC majors split header and payload differently: From 9fbb31f46b87356adb0e884fb06cc1eed608a691 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 6 Nov 2026 20:18:06 +0000 Subject: [PATCH 4/7] ipc: move notification_pool.c to src/kernel/ipc The notification message pool is used by the kernel IPC4 notification code and takes a spinlock. Move it to src/kernel/ipc, where Zephyr builds it into the sof_kernel library; the host builds get it from src/kernel/ipc as well. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/ipc/CMakeLists.txt | 1 - src/kernel/ipc/CMakeLists.txt | 3 +++ src/{ => kernel}/ipc/notification_pool.c | 0 3 files changed, 3 insertions(+), 1 deletion(-) rename src/{ => kernel}/ipc/notification_pool.c (100%) diff --git a/src/ipc/CMakeLists.txt b/src/ipc/CMakeLists.txt index 80b804ebc7cf..f12ac465acd0 100644 --- a/src/ipc/CMakeLists.txt +++ b/src/ipc/CMakeLists.txt @@ -8,7 +8,6 @@ endif() add_local_sources(sof ipc-common.c ipc-helper.c - notification_pool.c ) is_zephyr(zephyr) diff --git a/src/kernel/ipc/CMakeLists.txt b/src/kernel/ipc/CMakeLists.txt index ef3e57f01113..0f9d63c0aee6 100644 --- a/src/kernel/ipc/CMakeLists.txt +++ b/src/kernel/ipc/CMakeLists.txt @@ -6,6 +6,9 @@ elseif (CONFIG_IPC_MAJOR_4) add_subdirectory(ipc4) endif() +# Files common to Zephyr and the host library +add_local_sources(sof notification_pool.c) + is_zephyr(zephyr) if(zephyr) if (CONFIG_SOC_SERIES_INTEL_CAVS_V25 OR CONFIG_SOC_SERIES_INTEL_ADSP_ACE) diff --git a/src/ipc/notification_pool.c b/src/kernel/ipc/notification_pool.c similarity index 100% rename from src/ipc/notification_pool.c rename to src/kernel/ipc/notification_pool.c From 0689bff065ae076712ca11831542e6af352eb5eb Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 6 Nov 2026 20:18:27 +0000 Subject: [PATCH 5/7] lib: move agent.c to src/kernel/lib The system agent checks the timing of the LL scheduler from a timer task and runs in kernel mode. Move it to src/kernel/lib, where Zephyr builds it into the sof_kernel library for CONFIG_HAVE_AGENT. The host library, which always builds it, now gets it from src/kernel/lib, which keeps the early return for CONFIG_LIBRARY so that the host builds compile nothing else from there. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/kernel/CMakeLists.txt | 2 +- src/kernel/lib/CMakeLists.txt | 9 +++++++++ src/{ => kernel}/lib/agent.c | 0 src/lib/CMakeLists.txt | 5 ----- 4 files changed, 10 insertions(+), 6 deletions(-) rename src/{ => kernel}/lib/agent.c (100%) diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt index 3e95a9d821ff..700289d418e6 100644 --- a/src/kernel/CMakeLists.txt +++ b/src/kernel/CMakeLists.txt @@ -17,7 +17,6 @@ if(zephyr) add_subdirectory(debug) add_subdirectory(idc) add_subdirectory(init) - add_subdirectory(lib) add_subdirectory(library_manager) add_subdirectory(logging) add_subdirectory(probe) @@ -26,3 +25,4 @@ endif() # Built for Zephyr and for the host add_subdirectory(ipc) +add_subdirectory(lib) diff --git a/src/kernel/lib/CMakeLists.txt b/src/kernel/lib/CMakeLists.txt index 6f9861ed59f0..efe6347d02e1 100644 --- a/src/kernel/lib/CMakeLists.txt +++ b/src/kernel/lib/CMakeLists.txt @@ -1,5 +1,14 @@ # SPDX-License-Identifier: BSD-3-Clause +if(CONFIG_LIBRARY) + add_local_sources(sof agent.c) + return() +endif() + +if(CONFIG_HAVE_AGENT) + add_local_sources(sof agent.c) +endif() + if(CONFIG_AMS) add_local_sources(sof ams.c) endif() diff --git a/src/lib/agent.c b/src/kernel/lib/agent.c similarity index 100% rename from src/lib/agent.c rename to src/kernel/lib/agent.c diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index f92e467d970f..47e7984c952b 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -5,16 +5,11 @@ set(common_files notifier.c dma.c dai.c objpool.c) if(CONFIG_LIBRARY) add_local_sources(sof lib.c - agent.c ${common_files} ) return() endif() -if(CONFIG_HAVE_AGENT) - add_local_sources(sof agent.c) -endif() - is_zephyr(zephyr) if(zephyr) ### Zephyr ### From f48b4c71239e879dd61af11ae41fa3479dfa6c84 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 6 Nov 2026 20:20:10 +0000 Subject: [PATCH 6/7] drivers: move src/drivers to src/kernel/drivers The platform drivers (i.MX, AMD and MediaTek IPC, DMA and DAI drivers, the generic dummy DMA, the legacy interrupt layer and the host library's IPC and timer) access hardware and run in kernel mode. Move them to src/kernel/drivers. The Zephyr build lists the drivers in zephyr/CMakeLists.txt, so point SOF_DRIVERS_PATH there and use it for the entries that spelled the path out. They are still built into modules_sof, like the platform code listed next to them. The host builds now get drivers/host from src/kernel. The drivers Kconfig is sourced from src/kernel/Kconfig instead of src/Kconfig; the option values are unchanged. Update CODEOWNERS, the drivers README, the kernel-only directory lists in the docs and a comment in the IPC3 host page table code. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- AGENTS.md | 2 +- CODEOWNERS | 6 +++--- src/CMakeLists.txt | 1 - src/Kconfig | 2 -- src/audio/README.md | 3 ++- src/include/sof/userspace/README.md | 2 +- src/kernel/CMakeLists.txt | 1 + src/kernel/Kconfig | 2 ++ src/{ => kernel}/drivers/CMakeLists.txt | 0 src/{ => kernel}/drivers/Kconfig | 0 src/{ => kernel}/drivers/README.md | 4 ++-- src/{ => kernel}/drivers/amd/Kconfig | 0 src/{ => kernel}/drivers/amd/acp_7_x/ipc.c | 0 src/{ => kernel}/drivers/amd/common/acp_bt_dai.c | 0 src/{ => kernel}/drivers/amd/common/acp_dma.c | 0 .../drivers/amd/common/acp_dmic_dai.c | 0 .../drivers/amd/common/acp_dmic_dma.c | 0 src/{ => kernel}/drivers/amd/common/acp_sp_dma.c | 0 src/{ => kernel}/drivers/amd/common/ipc.c | 0 .../drivers/amd/rembrandt/acp_bt_dma.c | 0 src/{ => kernel}/drivers/amd/rembrandt/acp_dma.c | 0 .../drivers/amd/rembrandt/acp_dmic_dma.c | 0 .../drivers/amd/rembrandt/acp_hs_dai.c | 0 .../drivers/amd/rembrandt/acp_hs_dma.c | 0 .../drivers/amd/rembrandt/acp_sp_dai.c | 0 .../drivers/amd/rembrandt/acp_sp_dma.c | 0 .../drivers/amd/rembrandt/interrupt.c | 0 src/{ => kernel}/drivers/amd/rembrandt/ipc.c | 0 src/{ => kernel}/drivers/generic/dummy-dma.c | 0 src/{ => kernel}/drivers/host/CMakeLists.txt | 0 src/{ => kernel}/drivers/host/ipc.c | 0 src/{ => kernel}/drivers/host/timer.c | 0 src/{ => kernel}/drivers/imx/ipc.c | 0 src/{ => kernel}/drivers/interrupt.c | 0 src/{ => kernel}/drivers/mediatek/afe/afe-dai.c | 0 src/{ => kernel}/drivers/mediatek/afe/afe-drv.c | 0 .../drivers/mediatek/afe/afe-memif.c | 0 .../drivers/mediatek/afe/zephyr_mtk_afe_memif.c | 0 .../drivers/mediatek/afe/zephyr_mtk_dai.c | 0 .../drivers/mediatek/afe/zephyr_mtk_host_dma.c | 0 src/kernel/ipc/ipc3/host-page-table.c | 2 +- zephyr/CMakeLists.txt | 16 ++++++++-------- 42 files changed, 21 insertions(+), 20 deletions(-) rename src/{ => kernel}/drivers/CMakeLists.txt (100%) rename src/{ => kernel}/drivers/Kconfig (100%) rename src/{ => kernel}/drivers/README.md (85%) rename src/{ => kernel}/drivers/amd/Kconfig (100%) rename src/{ => kernel}/drivers/amd/acp_7_x/ipc.c (100%) rename src/{ => kernel}/drivers/amd/common/acp_bt_dai.c (100%) rename src/{ => kernel}/drivers/amd/common/acp_dma.c (100%) rename src/{ => kernel}/drivers/amd/common/acp_dmic_dai.c (100%) rename src/{ => kernel}/drivers/amd/common/acp_dmic_dma.c (100%) rename src/{ => kernel}/drivers/amd/common/acp_sp_dma.c (100%) rename src/{ => kernel}/drivers/amd/common/ipc.c (100%) rename src/{ => kernel}/drivers/amd/rembrandt/acp_bt_dma.c (100%) rename src/{ => kernel}/drivers/amd/rembrandt/acp_dma.c (100%) rename src/{ => kernel}/drivers/amd/rembrandt/acp_dmic_dma.c (100%) rename src/{ => kernel}/drivers/amd/rembrandt/acp_hs_dai.c (100%) rename src/{ => kernel}/drivers/amd/rembrandt/acp_hs_dma.c (100%) rename src/{ => kernel}/drivers/amd/rembrandt/acp_sp_dai.c (100%) rename src/{ => kernel}/drivers/amd/rembrandt/acp_sp_dma.c (100%) rename src/{ => kernel}/drivers/amd/rembrandt/interrupt.c (100%) rename src/{ => kernel}/drivers/amd/rembrandt/ipc.c (100%) rename src/{ => kernel}/drivers/generic/dummy-dma.c (100%) rename src/{ => kernel}/drivers/host/CMakeLists.txt (100%) rename src/{ => kernel}/drivers/host/ipc.c (100%) rename src/{ => kernel}/drivers/host/timer.c (100%) rename src/{ => kernel}/drivers/imx/ipc.c (100%) rename src/{ => kernel}/drivers/interrupt.c (100%) rename src/{ => kernel}/drivers/mediatek/afe/afe-dai.c (100%) rename src/{ => kernel}/drivers/mediatek/afe/afe-drv.c (100%) rename src/{ => kernel}/drivers/mediatek/afe/afe-memif.c (100%) rename src/{ => kernel}/drivers/mediatek/afe/zephyr_mtk_afe_memif.c (100%) rename src/{ => kernel}/drivers/mediatek/afe/zephyr_mtk_dai.c (100%) rename src/{ => kernel}/drivers/mediatek/afe/zephyr_mtk_host_dma.c (100%) diff --git a/AGENTS.md b/AGENTS.md index 095ec828115f..6a2f4cdfee5b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -31,7 +31,7 @@ moving code, follow it: * **Place code in the right tier.** OS/HAL/boot/inter-core → a kernel-only directory (`kernel/`, which is built into the `sof_kernel` library, and the directories not yet - moved there: `arch/`, `drivers/`, `platform/`, `trace/`); audio + moved there: `arch/`, `platform/`, `trace/`); audio application logic → `audio/`; reusable pure code → a shared-library directory (`lib/`, `math/`, `module/`) kept free of privileged operations. Each top-level directory's `README.md` states its tier in a "Runs in:" banner — keep it accurate. diff --git a/CODEOWNERS b/CODEOWNERS index 846bf54e2136..baf65513a2a1 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -53,9 +53,9 @@ src/platform/mtk/** @yaochunhung @kuanhsuncheng # drivers src/drivers/intel/dmic.c @singalsu -src/drivers/imx/** @dbaluta -src/drivers/amd/* @bhiregoudar @sunilkumardommati -src/drivers/mediatek/** @yaochunhung @kuanhsuncheng +src/kernel/drivers/imx/** @dbaluta +src/kernel/drivers/amd/* @bhiregoudar @sunilkumardommati +src/kernel/drivers/mediatek/** @yaochunhung @kuanhsuncheng # other libs src/math/* @singalsu diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5dbe65d29a51..a4d31797de8f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,7 +12,6 @@ if(CONFIG_SAMPLES) add_subdirectory(samples) endif() -add_subdirectory(drivers) add_subdirectory(kernel) if (CONFIG_TRACE) diff --git a/src/Kconfig b/src/Kconfig index f7d5dbbb64bc..6dbd3c396c04 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -4,8 +4,6 @@ rsource "arch/Kconfig" rsource "platform/Kconfig" -rsource "drivers/Kconfig" - rsource "audio/Kconfig" rsource "trace/Kconfig" diff --git a/src/audio/README.md b/src/audio/README.md index 83550a4ca783..73a48ec7520e 100644 --- a/src/audio/README.md +++ b/src/audio/README.md @@ -15,4 +15,5 @@ modules in user context. When adding a component here, keep it inside the application tier: allocate through the module allocation syscalls (`mod_*`), mark any globals shared with the kernel using the partition -markers, and never call kernel-only subsystems (`drivers/`, `platform/`, `kernel/idc/`) directly. +markers, and never call kernel-only subsystems (`kernel/drivers/`, `platform/`, `kernel/idc/`) +directly. diff --git a/src/include/sof/userspace/README.md b/src/include/sof/userspace/README.md index 9747fb604c3f..d342bbc941f7 100644 --- a/src/include/sof/userspace/README.md +++ b/src/include/sof/userspace/README.md @@ -74,7 +74,7 @@ its subdirectories span all tiers. | Tier | Meaning | Directories | |------|---------|-------------| -| **Kernel-only** | OS integration, HAL, boot, inter-core. Never executes in a user thread. Must not be reached directly from user code — only via a syscall. | `kernel/` (see [its README](../../../kernel/README.md)), `arch/`, `drivers/`, `platform/`, `trace/` * | +| **Kernel-only** | OS integration, HAL, boot, inter-core. Never executes in a user thread. Must not be reached directly from user code — only via a syscall. | `kernel/` (see [its README](../../../kernel/README.md)), `arch/`, `platform/`, `trace/` * | | **Boundary / bridge** | Owns the syscalls and the thread / memory-domain setup. Split internally: some translation units run kernel-side, some user-side (e.g. `handler-kernel.c` vs `handler-user.c`). | `schedule/`, `ipc/`, `debug/debug_stream/` *, and (in the Zephyr integration tree) `zephyr/syscall/` | | **Application** | Audio pipeline / component logic that runs in user threads under userspace configs. | `audio/` | | **Shared library** | Context-agnostic code linked into whichever context calls it. Must stay "user-safe": no privileged operations (no direct MMIO, no spinlocks held across syscalls, no raw kernel object access) so it is safe when pulled into a user build. | `math/`, `module/` | diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt index 700289d418e6..b14881ad3b7a 100644 --- a/src/kernel/CMakeLists.txt +++ b/src/kernel/CMakeLists.txt @@ -24,5 +24,6 @@ if(zephyr) endif() # Built for Zephyr and for the host +add_subdirectory(drivers) add_subdirectory(ipc) add_subdirectory(lib) diff --git a/src/kernel/Kconfig b/src/kernel/Kconfig index 5a8920dd9b1f..f92df62d911a 100644 --- a/src/kernel/Kconfig +++ b/src/kernel/Kconfig @@ -4,6 +4,8 @@ rsource "debug/telemetry/Kconfig" +rsource "drivers/Kconfig" + rsource "idc/Kconfig" rsource "library_manager/Kconfig" diff --git a/src/drivers/CMakeLists.txt b/src/kernel/drivers/CMakeLists.txt similarity index 100% rename from src/drivers/CMakeLists.txt rename to src/kernel/drivers/CMakeLists.txt diff --git a/src/drivers/Kconfig b/src/kernel/drivers/Kconfig similarity index 100% rename from src/drivers/Kconfig rename to src/kernel/drivers/Kconfig diff --git a/src/drivers/README.md b/src/kernel/drivers/README.md similarity index 85% rename from src/drivers/README.md rename to src/kernel/drivers/README.md index 546a4a41994d..5e8eeedf4fc0 100644 --- a/src/drivers/README.md +++ b/src/kernel/drivers/README.md @@ -1,9 +1,9 @@ -# Device Drivers (`src/drivers`) +# Device Drivers (`src/kernel/drivers`) > **Runs in:** Kernel-only — hardware/HAL access runs in supervisor context and is never > executed from a user thread. User-space audio code reaches driver functionality only through > SOF syscalls (e.g. the `sof_dma_*` and `dai_get_device` calls). See -> [User/kernel split](../include/sof/userspace/README.md). +> [User/kernel split](../../include/sof/userspace/README.md). This directory contains low-level device drivers and hardware abstraction. Because it touches MMIO, interrupts and other privileged resources, nothing here is mapped into a user memory diff --git a/src/drivers/amd/Kconfig b/src/kernel/drivers/amd/Kconfig similarity index 100% rename from src/drivers/amd/Kconfig rename to src/kernel/drivers/amd/Kconfig diff --git a/src/drivers/amd/acp_7_x/ipc.c b/src/kernel/drivers/amd/acp_7_x/ipc.c similarity index 100% rename from src/drivers/amd/acp_7_x/ipc.c rename to src/kernel/drivers/amd/acp_7_x/ipc.c diff --git a/src/drivers/amd/common/acp_bt_dai.c b/src/kernel/drivers/amd/common/acp_bt_dai.c similarity index 100% rename from src/drivers/amd/common/acp_bt_dai.c rename to src/kernel/drivers/amd/common/acp_bt_dai.c diff --git a/src/drivers/amd/common/acp_dma.c b/src/kernel/drivers/amd/common/acp_dma.c similarity index 100% rename from src/drivers/amd/common/acp_dma.c rename to src/kernel/drivers/amd/common/acp_dma.c diff --git a/src/drivers/amd/common/acp_dmic_dai.c b/src/kernel/drivers/amd/common/acp_dmic_dai.c similarity index 100% rename from src/drivers/amd/common/acp_dmic_dai.c rename to src/kernel/drivers/amd/common/acp_dmic_dai.c diff --git a/src/drivers/amd/common/acp_dmic_dma.c b/src/kernel/drivers/amd/common/acp_dmic_dma.c similarity index 100% rename from src/drivers/amd/common/acp_dmic_dma.c rename to src/kernel/drivers/amd/common/acp_dmic_dma.c diff --git a/src/drivers/amd/common/acp_sp_dma.c b/src/kernel/drivers/amd/common/acp_sp_dma.c similarity index 100% rename from src/drivers/amd/common/acp_sp_dma.c rename to src/kernel/drivers/amd/common/acp_sp_dma.c diff --git a/src/drivers/amd/common/ipc.c b/src/kernel/drivers/amd/common/ipc.c similarity index 100% rename from src/drivers/amd/common/ipc.c rename to src/kernel/drivers/amd/common/ipc.c diff --git a/src/drivers/amd/rembrandt/acp_bt_dma.c b/src/kernel/drivers/amd/rembrandt/acp_bt_dma.c similarity index 100% rename from src/drivers/amd/rembrandt/acp_bt_dma.c rename to src/kernel/drivers/amd/rembrandt/acp_bt_dma.c diff --git a/src/drivers/amd/rembrandt/acp_dma.c b/src/kernel/drivers/amd/rembrandt/acp_dma.c similarity index 100% rename from src/drivers/amd/rembrandt/acp_dma.c rename to src/kernel/drivers/amd/rembrandt/acp_dma.c diff --git a/src/drivers/amd/rembrandt/acp_dmic_dma.c b/src/kernel/drivers/amd/rembrandt/acp_dmic_dma.c similarity index 100% rename from src/drivers/amd/rembrandt/acp_dmic_dma.c rename to src/kernel/drivers/amd/rembrandt/acp_dmic_dma.c diff --git a/src/drivers/amd/rembrandt/acp_hs_dai.c b/src/kernel/drivers/amd/rembrandt/acp_hs_dai.c similarity index 100% rename from src/drivers/amd/rembrandt/acp_hs_dai.c rename to src/kernel/drivers/amd/rembrandt/acp_hs_dai.c diff --git a/src/drivers/amd/rembrandt/acp_hs_dma.c b/src/kernel/drivers/amd/rembrandt/acp_hs_dma.c similarity index 100% rename from src/drivers/amd/rembrandt/acp_hs_dma.c rename to src/kernel/drivers/amd/rembrandt/acp_hs_dma.c diff --git a/src/drivers/amd/rembrandt/acp_sp_dai.c b/src/kernel/drivers/amd/rembrandt/acp_sp_dai.c similarity index 100% rename from src/drivers/amd/rembrandt/acp_sp_dai.c rename to src/kernel/drivers/amd/rembrandt/acp_sp_dai.c diff --git a/src/drivers/amd/rembrandt/acp_sp_dma.c b/src/kernel/drivers/amd/rembrandt/acp_sp_dma.c similarity index 100% rename from src/drivers/amd/rembrandt/acp_sp_dma.c rename to src/kernel/drivers/amd/rembrandt/acp_sp_dma.c diff --git a/src/drivers/amd/rembrandt/interrupt.c b/src/kernel/drivers/amd/rembrandt/interrupt.c similarity index 100% rename from src/drivers/amd/rembrandt/interrupt.c rename to src/kernel/drivers/amd/rembrandt/interrupt.c diff --git a/src/drivers/amd/rembrandt/ipc.c b/src/kernel/drivers/amd/rembrandt/ipc.c similarity index 100% rename from src/drivers/amd/rembrandt/ipc.c rename to src/kernel/drivers/amd/rembrandt/ipc.c diff --git a/src/drivers/generic/dummy-dma.c b/src/kernel/drivers/generic/dummy-dma.c similarity index 100% rename from src/drivers/generic/dummy-dma.c rename to src/kernel/drivers/generic/dummy-dma.c diff --git a/src/drivers/host/CMakeLists.txt b/src/kernel/drivers/host/CMakeLists.txt similarity index 100% rename from src/drivers/host/CMakeLists.txt rename to src/kernel/drivers/host/CMakeLists.txt diff --git a/src/drivers/host/ipc.c b/src/kernel/drivers/host/ipc.c similarity index 100% rename from src/drivers/host/ipc.c rename to src/kernel/drivers/host/ipc.c diff --git a/src/drivers/host/timer.c b/src/kernel/drivers/host/timer.c similarity index 100% rename from src/drivers/host/timer.c rename to src/kernel/drivers/host/timer.c diff --git a/src/drivers/imx/ipc.c b/src/kernel/drivers/imx/ipc.c similarity index 100% rename from src/drivers/imx/ipc.c rename to src/kernel/drivers/imx/ipc.c diff --git a/src/drivers/interrupt.c b/src/kernel/drivers/interrupt.c similarity index 100% rename from src/drivers/interrupt.c rename to src/kernel/drivers/interrupt.c diff --git a/src/drivers/mediatek/afe/afe-dai.c b/src/kernel/drivers/mediatek/afe/afe-dai.c similarity index 100% rename from src/drivers/mediatek/afe/afe-dai.c rename to src/kernel/drivers/mediatek/afe/afe-dai.c diff --git a/src/drivers/mediatek/afe/afe-drv.c b/src/kernel/drivers/mediatek/afe/afe-drv.c similarity index 100% rename from src/drivers/mediatek/afe/afe-drv.c rename to src/kernel/drivers/mediatek/afe/afe-drv.c diff --git a/src/drivers/mediatek/afe/afe-memif.c b/src/kernel/drivers/mediatek/afe/afe-memif.c similarity index 100% rename from src/drivers/mediatek/afe/afe-memif.c rename to src/kernel/drivers/mediatek/afe/afe-memif.c diff --git a/src/drivers/mediatek/afe/zephyr_mtk_afe_memif.c b/src/kernel/drivers/mediatek/afe/zephyr_mtk_afe_memif.c similarity index 100% rename from src/drivers/mediatek/afe/zephyr_mtk_afe_memif.c rename to src/kernel/drivers/mediatek/afe/zephyr_mtk_afe_memif.c diff --git a/src/drivers/mediatek/afe/zephyr_mtk_dai.c b/src/kernel/drivers/mediatek/afe/zephyr_mtk_dai.c similarity index 100% rename from src/drivers/mediatek/afe/zephyr_mtk_dai.c rename to src/kernel/drivers/mediatek/afe/zephyr_mtk_dai.c diff --git a/src/drivers/mediatek/afe/zephyr_mtk_host_dma.c b/src/kernel/drivers/mediatek/afe/zephyr_mtk_host_dma.c similarity index 100% rename from src/drivers/mediatek/afe/zephyr_mtk_host_dma.c rename to src/kernel/drivers/mediatek/afe/zephyr_mtk_host_dma.c diff --git a/src/kernel/ipc/ipc3/host-page-table.c b/src/kernel/ipc/ipc3/host-page-table.c index 8a90c8919a49..4e42b21ac825 100644 --- a/src/kernel/ipc/ipc3/host-page-table.c +++ b/src/kernel/ipc/ipc3/host-page-table.c @@ -19,7 +19,7 @@ LOG_MODULE_DECLARE(ipc, CONFIG_SOF_LOG_LEVEL); /* * Size in bytes of the DSP-side buffer that receives the compressed host page * table. DSP targets define PLATFORM_PAGE_TABLE_SIZE; the host/library builds - * (e.g. testbench, fuzzer) allocate it as HOST_PAGE_SIZE in drivers/host/ipc.c + * (e.g. testbench, fuzzer) allocate it as HOST_PAGE_SIZE in kernel/drivers/host/ipc.c * and do not define PLATFORM_PAGE_TABLE_SIZE, so fall back to that. */ #ifndef PLATFORM_PAGE_TABLE_SIZE diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index ea8f312f435b..8da2dc47fdc5 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -157,7 +157,7 @@ cmake_path(SET sof_top_dir NORMALIZE "${CMAKE_CURRENT_SOURCE_DIR}/..") set(SOF_SRC_PATH "${sof_top_dir}/src") set(SOF_PLATFORM_PATH "${SOF_SRC_PATH}/platform") -set(SOF_DRIVERS_PATH "${SOF_SRC_PATH}/drivers") +set(SOF_DRIVERS_PATH "${SOF_SRC_PATH}/kernel/drivers") set(SOF_TRACE_PATH "${SOF_SRC_PATH}/trace") set(RIMAGE_TOP ${sof_top_dir}/tools/rimage) @@ -479,7 +479,7 @@ if (CONFIG_SOC_ACP_6_0) # SOF core infrastructure - runs on top of Zephyr zephyr_library_sources( - ${SOF_SRC_PATH}/drivers/interrupt.c + ${SOF_DRIVERS_PATH}/interrupt.c ) zephyr_include_directories(${SOF_PLATFORM_PATH}/amd/rembrandt/include) @@ -524,23 +524,23 @@ if (CONFIG_SOC_FAMILY_MTK) zephyr_library_sources( ${SOF_PLATFORM_PATH}/mtk/platform.c ${SOF_PLATFORM_PATH}/mtk/dai.c - ${SOF_SRC_PATH}/drivers/mediatek/afe/afe-drv.c + ${SOF_DRIVERS_PATH}/mediatek/afe/afe-drv.c ) if (CONFIG_ZEPHYR_NATIVE_DRIVERS) # Native Zephyr DMA/DAI path zephyr_library_sources( lib/dma.c - ${SOF_SRC_PATH}/drivers/mediatek/afe/zephyr_mtk_afe_memif.c - ${SOF_SRC_PATH}/drivers/mediatek/afe/zephyr_mtk_host_dma.c - ${SOF_SRC_PATH}/drivers/mediatek/afe/zephyr_mtk_dai.c + ${SOF_DRIVERS_PATH}/mediatek/afe/zephyr_mtk_afe_memif.c + ${SOF_DRIVERS_PATH}/mediatek/afe/zephyr_mtk_host_dma.c + ${SOF_DRIVERS_PATH}/mediatek/afe/zephyr_mtk_dai.c ) else() # Legacy DMA path zephyr_library_sources( ${SOF_DRIVERS_PATH}/generic/dummy-dma.c - ${SOF_SRC_PATH}/drivers/mediatek/afe/afe-memif.c - ${SOF_SRC_PATH}/drivers/mediatek/afe/afe-dai.c + ${SOF_DRIVERS_PATH}/mediatek/afe/afe-memif.c + ${SOF_DRIVERS_PATH}/mediatek/afe/afe-dai.c ) endif() endif() From 986201f0d23fa45074c91ae95ce7591f8ab321d7 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 6 Nov 2026 20:20:23 +0000 Subject: [PATCH 7/7] CODEOWNERS: keep the scheduler owners for src/kernel/schedule zephyr_ll_user.c moved from src/schedule to src/kernel/schedule and lost its code owners. Give src/kernel/schedule the same owners as src/schedule. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- CODEOWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/CODEOWNERS b/CODEOWNERS index baf65513a2a1..543435d5f3c3 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -63,6 +63,7 @@ src/ipc/* @bardliao @tmleman @pblaszko src/kernel/ipc/** @bardliao @tmleman @pblaszko # src/lib/* TODO src/schedule @pblaszko @marcinszkudlinski @dbaluta @LaurentiuM1234 +src/kernel/schedule @pblaszko @marcinszkudlinski @dbaluta @LaurentiuM1234 # samples samples/audio/detect_test.c @iganakov