Skip to content

Commit 7bd9403

Browse files
lrgirdwoclaude
authored andcommitted
schedule: move zephyr_ll_user.c to src/kernel/schedule
zephyr_ll_user.c creates the memory domain and heap of the user-space LL scheduler thread and checks the heap pointers passed to the heap system calls. Despite its name it runs in kernel mode. Move it to src/kernel/schedule, where it is built into the sof_kernel library. Update the schedule and user-space READMEs, and stop giving it as an example of a user-side file. Only Zephyr builds it, for CONFIG_SOF_USERSPACE_LL. No functional change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent c84c27b commit 7bd9403

6 files changed

Lines changed: 13 additions & 8 deletions

File tree

‎src/include/sof/userspace/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ its subdirectories span all tiers.
7575
| Tier | Meaning | Directories |
7676
|------|---------|-------------|
7777
| **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/` * |
78-
| **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`, `zephyr_ll.c` vs `zephyr_ll_user.c`). | `schedule/`, `ipc/`, `debug/debug_stream/` *, and (in the Zephyr integration tree) `zephyr/syscall/` |
78+
| **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/` |
7979
| **Application** | Audio pipeline / component logic that runs in user threads under userspace configs. | `audio/` |
8080
| **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/` |
8181
| **Mixed** | A directory whose files span more than one tier; see its own README for per-file classification. | `lib/` |
@@ -152,7 +152,7 @@ marker at its declaration site.* Conversely, marked data is **user-writable**, s
152152
must never trust it — re-validate on every use. DP modules running under
153153
`SOF_USERSPACE_APPLICATION` access data through their per-module memory domain set up by the
154154
proxy or DP thread infrastructure, not through `APP_TASK_*` / `APP_SYSUSER_*` markers. See
155-
[`schedule/zephyr_ll_user.c`](../../../schedule/zephyr_ll_user.c): `zephyr_ll_user_heap()`
155+
[`kernel/schedule/zephyr_ll_user.c`](../../../kernel/schedule/zephyr_ll_user.c): `zephyr_ll_user_heap()`
156156
returns the address of the kernel-only heap object rather than a pointer stored in
157157
user-writable memory, and `zephyr_ll_user_heap_verify()` checks the heap pointer that user
158158
threads pass to the heap system calls.

‎src/kernel/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ add_subdirectory(lib)
1919
add_subdirectory(library_manager)
2020
add_subdirectory(logging)
2121
add_subdirectory(probe)
22+
add_subdirectory(schedule)

‎src/kernel/schedule/CMakeLists.txt‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
3+
is_zephyr(zephyr)
4+
if(zephyr)
5+
zephyr_library_sources_ifdef(CONFIG_SOF_USERSPACE_LL
6+
zephyr_ll_user.c
7+
)
8+
endif()

‎src/schedule/CMakeLists.txt‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,4 @@ zephyr_library_sources_ifdef(CONFIG_ZEPHYR_TWB_SCHEDULER
5454
zephyr_twb_schedule.c
5555
)
5656

57-
zephyr_library_sources_ifdef(CONFIG_SOF_USERSPACE_LL
58-
zephyr_ll_user.c
59-
)
60-
6157
endif()

‎src/schedule/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# SOF Scheduling Architecture
22

33
> **Runs in:** Boundary / bridge — this directory owns the LL/DP schedulers and their thread +
4-
> memory-domain setup. `zephyr_ll.c` and `zephyr_domain.c` are kernel-side; `zephyr_ll_user.c`
5-
> sets up the LL user memory domain (kernel-executed) and supports the LL user thread.
4+
> memory-domain setup. `zephyr_ll.c` and `zephyr_domain.c` are kernel-side; the LL user memory
5+
> domain and heap are set up by `src/kernel/schedule/zephyr_ll_user.c`.
66
> `zephyr_dp_schedule_thread.c` is boundary code that can create and manage both kernel and
77
> `K_USER` DP threads depending on configuration; `zephyr_dp_schedule_application.c` is the
88
> DP application-mode path. This directory hosts the `zephyr_ll_task_sem_*` and

0 commit comments

Comments
 (0)