From 484c885b3aa721d4439d77e056546c74922e4e4e Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Fri, 13 Feb 2026 15:56:18 +0100 Subject: [PATCH 1/2] dp: thread: only grant access to thread when userspace is used Kernel threads have access to all the memory, no need to additionally grant access to them. Signed-off-by: Guennadi Liakhovetski --- src/schedule/zephyr_dp_schedule.c | 2 -- src/schedule/zephyr_dp_schedule_thread.c | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/schedule/zephyr_dp_schedule.c b/src/schedule/zephyr_dp_schedule.c index 3c88573b92e5..4b2df1cfd6d3 100644 --- a/src/schedule/zephyr_dp_schedule.c +++ b/src/schedule/zephyr_dp_schedule.c @@ -60,9 +60,7 @@ void scheduler_dp_unlock(unsigned int key) void scheduler_dp_grant(k_tid_t thread_id, uint16_t core) { -#if CONFIG_USERSPACE k_thread_access_grant(thread_id, &dp_lock[core]); -#endif } /* dummy LL task - to start LL on secondary cores */ diff --git a/src/schedule/zephyr_dp_schedule_thread.c b/src/schedule/zephyr_dp_schedule_thread.c index e21644797310..a2d703528b33 100644 --- a/src/schedule/zephyr_dp_schedule_thread.c +++ b/src/schedule/zephyr_dp_schedule_thread.c @@ -269,9 +269,6 @@ int scheduler_dp_task_init(struct task **task, stack_size, dp_thread_fn, *task, NULL, NULL, CONFIG_DP_THREAD_PRIORITY, (*task)->flags, K_FOREVER); - k_thread_access_grant(pdata->thread_id, pdata->event); - scheduler_dp_grant(pdata->thread_id, cpu_get_id()); - /* pin the thread to specific core */ ret = k_thread_cpu_pin(pdata->thread_id, core); if (ret < 0) { @@ -280,6 +277,9 @@ int scheduler_dp_task_init(struct task **task, } #ifdef CONFIG_USERSPACE + k_thread_access_grant(pdata->thread_id, pdata->event); + scheduler_dp_grant(pdata->thread_id, cpu_get_id()); + if ((*task)->flags & K_USER) { ret = user_memory_init_shared(pdata->thread_id, pdata->mod); if (ret < 0) { From ae5d71372609f930b396d34fc7f73c6cb713f78c Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Fri, 13 Feb 2026 15:50:38 +0100 Subject: [PATCH 2/2] fast-get: limit scope fast-get is only needed when DRAM is used, i.e. when CONFIG_COLD_STORE_EXECUTE_DRAM is selectef. It's also unneeded in modules when CONFIG_LLEXT_TYPE_ELF_SHAREDLIB is used, i.e. in gcc builds, because also in those builds no .cold and .coldrodata sections are created. Signed-off-by: Guennadi Liakhovetski --- src/include/sof/lib/fast-get.h | 10 ++++++++++ zephyr/CMakeLists.txt | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/include/sof/lib/fast-get.h b/src/include/sof/lib/fast-get.h index fa34ecea128d..71bd81bd58a7 100644 --- a/src/include/sof/lib/fast-get.h +++ b/src/include/sof/lib/fast-get.h @@ -12,7 +12,17 @@ struct k_heap; +#if (CONFIG_COLD_STORE_EXECUTE_DRAM && \ + (CONFIG_LLEXT_TYPE_ELF_RELOCATABLE || !defined(LL_EXTENSION_BUILD))) || \ + !CONFIG_SOF_FULL_ZEPHYR_APPLICATION const void *fast_get(struct k_heap *heap, const void * const dram_ptr, size_t size); void fast_put(struct k_heap *heap, const void *sram_ptr); +#else +static inline const void *fast_get(struct k_heap *heap, const void * const dram_ptr, size_t size) +{ + return dram_ptr; +} +static inline void fast_put(struct k_heap *heap, const void *sram_ptr) {} +#endif #endif /* __SOF_LIB_FAST_GET_H__ */ diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 61ed49a3d15f..9f95170c8bdc 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -518,7 +518,9 @@ zephyr_library_sources( # SOF module interface functions add_subdirectory(../src/module module_unused_install/) +if(CONFIG_COLD_STORE_EXECUTE_DRAM) zephyr_library_sources_ifdef(CONFIG_FAST_GET lib/fast-get.c) +endif() # Optional SOF sources - depends on Kconfig - WIP