@@ -124,6 +124,7 @@ syscall by subsystem:
124124| Scheduling | ` zephyr_ll_task_sem_alloc ` , ` zephyr_ll_task_sem_free ` , ` scheduler_dp_internal_free ` , ` scheduler_dp_ll_tick ` , ` scheduler_dp_kick ` | ` sof/schedule/ll_schedule_domain.h ` , ` sof/schedule/dp_schedule.h ` | scattered: ` kernel/schedule/zephyr_ll-kernel.c ` , ` kernel/schedule/zephyr_dp_schedule*-kernel.c ` |
125125| Debug | ` debug_stream_slot_send_record ` | ` user/debug_stream_slot.h ` | ` kernel/debug/debug_stream/debug_stream_slot.c ` |
126126| KPB | ` kpb_notifier_schedule ` | ` sof/audio/kpb.h ` | ` zephyr/syscall/kpb.c ` / ` audio/kpb.c ` |
127+ | fast_get | ` fast_get_ll ` , ` fast_put_ll ` | ` sof/lib/fast-get.h ` | scattered: ` zephyr/lib/fast-get.c ` |
127128
128129### Allowed callers
129130
@@ -156,8 +157,9 @@ syscalls or to vregion, DMA, DAI or scheduler syscalls.
156157Modules call the module resource functions without the ` dp ` prefix (` mod_alloc_ext() ` ,
157158` mod_free() ` , ` mod_fast_get() ` and so on), which are plain functions. For an LL module in the
158159LL or IPC user thread they run in user mode, on the module's resource pool and the LL user
159- heap, under a ` sys_mutex ` in LL memory. ` mod_fast_get() ` then makes a private copy, as the
160- shared copies are kernel state. For DP modules, and in kernel code, they call the ` mod_dp_* `
160+ heap, under a ` sys_mutex ` in LL memory. ` mod_fast_get() ` then gets a shared read-only copy
161+ with the ` fast_get_ll() ` syscall, see below, or makes a private copy when the fast_get area is
162+ full. For DP modules, and in kernel code, they call the ` mod_dp_* `
161163syscalls. Those validators reject LL modules and DP modules whose allocation context has no
162164live vregion, and pin the vregion during the call. They still read the context from DP memory,
163165so a DP thread that rewrites it during the call is not stopped.
@@ -186,6 +188,7 @@ With `CONFIG_SOF_USERSPACE_LL`, the memory of the LL and IPC user threads is one
186188| Part | Mapping in the LL memory domain | Allocator |
187189| ------| ---------------------------------| -----------|
188190| Kernel RO area (` CONFIG_SOF_ZEPHYR_LL_KAREA_RO_SIZE ` ) | read-only | ` zephyr_ll_karea_alloc(ZEPHYR_LL_KAREA_RO, ...) ` |
191+ | fast_get area (` CONFIG_SOF_ZEPHYR_LL_FG_AREA_SIZE ` ) | read-only, cached alias only | ` zephyr_ll_fg_alloc() ` , ` zephyr_ll_fg_free() ` |
189192| Kernel RW area (` CONFIG_SOF_ZEPHYR_LL_KAREA_RW_SIZE ` ) | read-write | ` zephyr_ll_karea_alloc(ZEPHYR_LL_KAREA_RW, ...) ` |
190193| LL user heap (the rest) | read-write | ` sof_heap_alloc(sof_sys_user_heap_get(), ...) ` , in user mode only |
191194
@@ -237,10 +240,21 @@ heap. A user thread that corrupts the heap can only make LL and IPC user threads
237240` zephyr_ll_user_heap() ` returns a kernel-only ` struct k_heap ` that is never initialised: its
238241address only selects the LL user heap.
239242
240- Large ` fast_get() ` copies for DP modules are taken from ` vpage_alloc() ` instead of the heap of
241- the module allocation context, which is the LL user heap, and mapped read-only into the domain
242- of each user. Kernel code still follows some pointers stored in user-writable memory, for
243- example ` task->sch ` and the domain ` ops ` .
243+ The fast_get area holds the ` fast_get() ` copies of the LL modules, such as SRC coefficients.
244+ LL and IPC user threads get them with the ` fast_get_ll() ` and ` fast_put_ll() ` syscalls, and all
245+ users of the same data share a copy. The allocator is a bitmap of 256-byte blocks in kernel
246+ memory, and the entries of the copies are in kernel memory too, marked as LL copies, which
247+ ` fast_get() ` and ` fast_put() ` never use. Only the cached alias of the area is mapped into the
248+ LL memory domain, so kernel code writes a copy through the uncached alias, also in the
249+ syscall, and invalidates the cached alias on the calling core at every get, as the core may
250+ still hold lines of an earlier copy at the same address. LL threads cannot change a shared
251+ copy. A user thread can release copies that other LL modules use, which only affects LL
252+ modules.
253+
254+ DP modules keep their copies in their own memory: small copies in the module vregion, and
255+ large copies from ` vpage_alloc() ` instead of the heap of the module allocation context, which
256+ is the LL user heap, mapped read-only into the domain of each user. Kernel code still follows
257+ some pointers stored in user-writable memory, for example ` task->sch ` and the domain ` ops ` .
244258
245259## Memory-partition markers
246260
0 commit comments