From 16775c0d674cb93f659f8ac9d9b101787bb7f128 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Fri, 23 Jan 2026 11:07:43 +0100 Subject: [PATCH 1/3] audio: fast-get: fast_get() and fast_put() should not be syscalls Userspace modules should only call mod_fast_get() and mod_fast_put(), which already can cross into the kernel space on their own, so fast_get() and fast_put() themselves don't need to be syscalls. Remove their syscall implementations. Signed-off-by: Guennadi Liakhovetski --- src/include/sof/lib/fast-get.h | 14 ++------------ zephyr/lib/fast-get.c | 33 ++++----------------------------- 2 files changed, 6 insertions(+), 41 deletions(-) diff --git a/src/include/sof/lib/fast-get.h b/src/include/sof/lib/fast-get.h index 36232cfbb3d6..fa34ecea128d 100644 --- a/src/include/sof/lib/fast-get.h +++ b/src/include/sof/lib/fast-get.h @@ -12,17 +12,7 @@ struct k_heap; -#if defined(__ZEPHYR__) && defined(CONFIG_SOF_FULL_ZEPHYR_APPLICATION) -#include - -__syscall const void *fast_get(struct k_heap *heap, const void * const dram_ptr, size_t size); -__syscall void fast_put(struct k_heap *heap, const void *sram_ptr); -#include -#else -const void *z_impl_fast_get(struct k_heap *heap, const void * const dram_ptr, size_t size); -void z_impl_fast_put(struct k_heap *heap, const void *sram_ptr); -#define fast_get z_impl_fast_get -#define fast_put z_impl_fast_put -#endif /* __ZEPHYR__ */ +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); #endif /* __SOF_LIB_FAST_GET_H__ */ diff --git a/zephyr/lib/fast-get.c b/zephyr/lib/fast-get.c index 4f08d111e8b9..a5ec260822b5 100644 --- a/zephyr/lib/fast-get.c +++ b/zephyr/lib/fast-get.c @@ -81,7 +81,7 @@ static struct sof_fast_get_entry *fast_get_find_entry(struct sof_fast_get_data * return NULL; } -const void *z_impl_fast_get(struct k_heap *heap, const void *dram_ptr, size_t size) +const void *fast_get(struct k_heap *heap, const void *dram_ptr, size_t size) { struct sof_fast_get_data *data = &fast_get_data; struct sof_fast_get_entry *entry; @@ -133,7 +133,7 @@ const void *z_impl_fast_get(struct k_heap *heap, const void *dram_ptr, size_t si return ret; } -EXPORT_SYMBOL(z_impl_fast_get); +EXPORT_SYMBOL(fast_get); static struct sof_fast_get_entry *fast_put_find_entry(struct sof_fast_get_data *data, const void *sram_ptr) @@ -148,7 +148,7 @@ static struct sof_fast_get_entry *fast_put_find_entry(struct sof_fast_get_data * return NULL; } -void z_impl_fast_put(struct k_heap *heap, const void *sram_ptr) +void fast_put(struct k_heap *heap, const void *sram_ptr) { struct sof_fast_get_data *data = &fast_get_data; struct sof_fast_get_entry *entry; @@ -170,29 +170,4 @@ void z_impl_fast_put(struct k_heap *heap, const void *sram_ptr) entry ? entry->size : 0, entry ? entry->refcount : 0); k_spin_unlock(&data->lock, key); } -EXPORT_SYMBOL(z_impl_fast_put); - -#ifdef CONFIG_USERSPACE -#include -void z_vrfy_fast_put(struct k_heap *heap, const void *sram_ptr) -{ - K_OOPS(K_SYSCALL_MEMORY_WRITE(heap, sizeof(*heap))); - /* - * FIXME: we don't know how much SRAM has been allocated, so cannot - * check. Should fast_put() be changed to pass a size argument? - */ - - z_impl_fast_put(heap, sram_ptr); -} -#include - -const void *z_vrfy_fast_get(struct k_heap *heap, const void *dram_ptr, size_t size) -{ - K_OOPS(K_SYSCALL_MEMORY_WRITE(heap, sizeof(*heap))); - /* We cannot (easily) verify the actual heapp memory */ - K_OOPS(K_SYSCALL_MEMORY_READ(dram_ptr, size)); - - return z_impl_fast_get(heap, dram_ptr, size); -} -#include -#endif +EXPORT_SYMBOL(fast_put); From 987c80bf40c8e036fc14b8af677ba6bb29c1dcda Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Fri, 23 Jan 2026 11:58:02 +0100 Subject: [PATCH 2/3] fast_get: replace tr_dbg() and tr_err() with LOG_*() fast_get.c doesn't have a "trace context" - it doesn't have a DECLARE_TR_CTX() call. Hencs all calls to tr_err() and friends are wrong. Replace them with respective LOG_*() analogs. Signed-off-by: Guennadi Liakhovetski --- zephyr/lib/fast-get.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/zephyr/lib/fast-get.c b/zephyr/lib/fast-get.c index a5ec260822b5..9a31265fed5c 100644 --- a/zephyr/lib/fast-get.c +++ b/zephyr/lib/fast-get.c @@ -16,6 +16,15 @@ #include #include +#ifdef __ZEPHYR__ +#include +#else +#define LOG_DBG(...) do {} while (0) +#define LOG_INF(...) do {} while (0) +#define LOG_WRN(...) do {} while (0) +#define LOG_ERR(...) do {} while (0) +#endif + struct sof_fast_get_entry { const void *dram_ptr; void *sram_ptr; @@ -101,7 +110,7 @@ const void *fast_get(struct k_heap *heap, const void *dram_ptr, size_t size) if (entry->sram_ptr) { if (entry->size != size || entry->dram_ptr != dram_ptr) { - tr_err(fast_get, "size %u != %u or ptr %p != %p mismatch", + LOG_ERR("size %u != %u or ptr %p != %p mismatch", entry->size, size, entry->dram_ptr, dram_ptr); ret = NULL; goto out; @@ -128,8 +137,7 @@ const void *fast_get(struct k_heap *heap, const void *dram_ptr, size_t size) entry->refcount = 1; out: k_spin_unlock(&data->lock, key); - tr_dbg(fast_get, "get %p, %p, size %u, refcnt %u", dram_ptr, ret, size, - entry ? entry->refcount : 0); + LOG_DBG("get %p, %p, size %u, refcnt %u", dram_ptr, ret, size, entry ? entry->refcount : 0); return ret; } @@ -157,7 +165,7 @@ void fast_put(struct k_heap *heap, const void *sram_ptr) key = k_spin_lock(&fast_get_data.lock); entry = fast_put_find_entry(data, sram_ptr); if (!entry) { - tr_err(fast_get, "Put called to unknown address %p", sram_ptr); + LOG_ERR("Put called to unknown address %p", sram_ptr); goto out; } entry->refcount--; @@ -166,8 +174,8 @@ void fast_put(struct k_heap *heap, const void *sram_ptr) memset(entry, 0, sizeof(*entry)); } out: - tr_dbg(fast_get, "put %p, DRAM %p size %u refcnt %u", sram_ptr, entry ? entry->dram_ptr : 0, - entry ? entry->size : 0, entry ? entry->refcount : 0); + LOG_DBG("put %p, DRAM %p size %u refcnt %u", sram_ptr, entry ? entry->dram_ptr : 0, + entry ? entry->size : 0, entry ? entry->refcount : 0); k_spin_unlock(&data->lock, key); } EXPORT_SYMBOL(fast_put); From e521410453fb12b6e1434c2e29f6132af76fc5f0 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 29 Jan 2026 10:33:11 +0100 Subject: [PATCH 3/3] intel_adsp: ace: fix compiler warnings Fix "unused function" Zephyr compilation warnings. Signed-off-by: Guennadi Liakhovetski --- app/boards/intel_adsp_ace15_mtpm.conf | 1 + app/boards/intel_adsp_ace20_lnl.conf | 1 + app/boards/intel_adsp_ace30_ptl.conf | 1 + app/boards/intel_adsp_ace30_wcl.conf | 1 + app/boards/intel_adsp_ace40_nvl.conf | 1 + app/boards/intel_adsp_ace40_nvls.conf | 1 + 6 files changed, 6 insertions(+) diff --git a/app/boards/intel_adsp_ace15_mtpm.conf b/app/boards/intel_adsp_ace15_mtpm.conf index e95b18d97169..d2721cdbdbb1 100644 --- a/app/boards/intel_adsp_ace15_mtpm.conf +++ b/app/boards/intel_adsp_ace15_mtpm.conf @@ -74,6 +74,7 @@ CONFIG_MM_DRV_INTEL_ADSP_TLB_REMAP_UNUSED_RAM=y CONFIG_MM_DRV_INTEL_VIRTUAL_REGION_COUNT=2 CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=38400000 CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000 +CONFIG_ACE_V1X_RTC_COUNTER=n # Zephyr / power settings CONFIG_ADSP_IDLE_CLOCK_GATING=y diff --git a/app/boards/intel_adsp_ace20_lnl.conf b/app/boards/intel_adsp_ace20_lnl.conf index beb441d6e6c6..f97530527c37 100644 --- a/app/boards/intel_adsp_ace20_lnl.conf +++ b/app/boards/intel_adsp_ace20_lnl.conf @@ -52,6 +52,7 @@ CONFIG_MM_DRV_INTEL_ADSP_TLB_REMAP_UNUSED_RAM=y CONFIG_MM_DRV_INTEL_VIRTUAL_REGION_COUNT=2 CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=38400000 CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000 +CONFIG_ACE_V1X_RTC_COUNTER=n # Zephyr / power settings CONFIG_ADSP_IDLE_CLOCK_GATING=y diff --git a/app/boards/intel_adsp_ace30_ptl.conf b/app/boards/intel_adsp_ace30_ptl.conf index 12aa78162c06..065a2cd00136 100644 --- a/app/boards/intel_adsp_ace30_ptl.conf +++ b/app/boards/intel_adsp_ace30_ptl.conf @@ -56,6 +56,7 @@ CONFIG_MM_DRV_INTEL_ADSP_TLB_REMAP_UNUSED_RAM=y CONFIG_MM_DRV_INTEL_VIRTUAL_REGION_COUNT=2 CONFIG_XTENSA_MMU_NUM_L2_TABLES=128 CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000 +CONFIG_ACE_V1X_RTC_COUNTER=n # Zephyr / power settings CONFIG_ADSP_IMR_CONTEXT_SAVE=y diff --git a/app/boards/intel_adsp_ace30_wcl.conf b/app/boards/intel_adsp_ace30_wcl.conf index 621eb719de9f..0704d60a4800 100644 --- a/app/boards/intel_adsp_ace30_wcl.conf +++ b/app/boards/intel_adsp_ace30_wcl.conf @@ -52,6 +52,7 @@ CONFIG_MEMORY_WIN_2_SIZE=12288 CONFIG_MM_DRV_INTEL_ADSP_TLB_REMAP_UNUSED_RAM=y CONFIG_MM_DRV_INTEL_VIRTUAL_REGION_COUNT=2 CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000 +CONFIG_ACE_V1X_RTC_COUNTER=n # Zephyr / power settings CONFIG_ADSP_IMR_CONTEXT_SAVE=y diff --git a/app/boards/intel_adsp_ace40_nvl.conf b/app/boards/intel_adsp_ace40_nvl.conf index 75652f508d53..a145b4e6d6c6 100644 --- a/app/boards/intel_adsp_ace40_nvl.conf +++ b/app/boards/intel_adsp_ace40_nvl.conf @@ -44,6 +44,7 @@ CONFIG_DMA_INTEL_ADSP_GPDMA=n CONFIG_MM_DRV_INTEL_ADSP_TLB_REMAP_UNUSED_RAM=y CONFIG_MM_DRV_INTEL_VIRTUAL_REGION_COUNT=2 CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000 +CONFIG_ACE_V1X_RTC_COUNTER=n # Zephyr / power settings CONFIG_ADSP_IMR_CONTEXT_SAVE=y diff --git a/app/boards/intel_adsp_ace40_nvls.conf b/app/boards/intel_adsp_ace40_nvls.conf index 75652f508d53..a145b4e6d6c6 100644 --- a/app/boards/intel_adsp_ace40_nvls.conf +++ b/app/boards/intel_adsp_ace40_nvls.conf @@ -44,6 +44,7 @@ CONFIG_DMA_INTEL_ADSP_GPDMA=n CONFIG_MM_DRV_INTEL_ADSP_TLB_REMAP_UNUSED_RAM=y CONFIG_MM_DRV_INTEL_VIRTUAL_REGION_COUNT=2 CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000 +CONFIG_ACE_V1X_RTC_COUNTER=n # Zephyr / power settings CONFIG_ADSP_IMR_CONTEXT_SAVE=y