From 6e1e33e2a72276bfc12d2aed055cd6626f890c2d Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sat, 5 Dec 2026 15:08:10 +0000 Subject: [PATCH] kernel: use the Zephyr cache pointer API Kernel code uses the native Zephyr API. cache_to_uncache() and is_cached() are SOF helpers for the cached and uncached aliases of the Intel ADSP memory. On ACE, cache_to_uncache() is already an alias of sys_cache_uncached_ptr_get(). On cAVS, SOF clears address bit 29 itself, and Zephyr now does the same: the cAVS cached and uncached regions are 5 and 4 (CONFIG_INTEL_ADSP_CACHED_REGION, _UNCACHED_REGION), which only differ in that bit. Call sys_cache_uncached_ptr_get() in the telemetry and IPC code, and sys_cache_is_ptr_cached() in the IDC message asserts. is_cached() tested address bit 29; Zephyr tests that the address is in the cached region, which is the same for the SRAM addresses of the IDC messages. Remove is_cached(), which has no other users. The user code, including the platform mailbox helpers, keeps the SOF helpers. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/kernel/debug/telemetry/telemetry.c | 2 +- src/kernel/idc/zephyr_idc.c | 4 ++-- src/kernel/ipc/ipc-zephyr.c | 2 +- zephyr/include/rtos/cache.h | 1 - 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/kernel/debug/telemetry/telemetry.c b/src/kernel/debug/telemetry/telemetry.c index 0942fdba4705..de8d27ed10e9 100644 --- a/src/kernel/debug/telemetry/telemetry.c +++ b/src/kernel/debug/telemetry/telemetry.c @@ -97,7 +97,7 @@ static struct telemetry_shared_state tel_state_storage __aligned(64); static inline struct telemetry_shared_state *tel_state(void) { - return (struct telemetry_shared_state *)cache_to_uncache( + return (struct telemetry_shared_state *)sys_cache_uncached_ptr_get( (__sparse_force void __sparse_cache *)&tel_state_storage); } diff --git a/src/kernel/idc/zephyr_idc.c b/src/kernel/idc/zephyr_idc.c index e5023cba649f..1192278bcd1e 100644 --- a/src/kernel/idc/zephyr_idc.c +++ b/src/kernel/idc/zephyr_idc.c @@ -81,7 +81,7 @@ static void idc_handler(struct k_p4wq_work *work) int payload = -1; k_spinlock_key_t key; - __ASSERT_NO_MSG(!is_cached(msg)); + __ASSERT_NO_MSG(!sys_cache_is_ptr_cached(msg)); if (msg->size == sizeof(int)) { const int idc_handler_memcpy_err __unused = @@ -173,7 +173,7 @@ static int idc_send_msg_kernel(struct idc_msg *msg, uint32_t mode) /* Temporarily store sender core ID */ msg_cp->core = cpu_get_id(); - __ASSERT_NO_MSG(!is_cached(msg_cp)); + __ASSERT_NO_MSG(!sys_cache_is_ptr_cached(msg_cp)); k_p4wq_submit(q_zephyr_idc + target_cpu, work); diff --git a/src/kernel/ipc/ipc-zephyr.c b/src/kernel/ipc/ipc-zephyr.c index 0748a0c084bb..32416a2ee749 100644 --- a/src/kernel/ipc/ipc-zephyr.c +++ b/src/kernel/ipc/ipc-zephyr.c @@ -196,7 +196,7 @@ static inline void increment_ipc_received_counter(void) static inline void increment_ipc_processed_counter(void) { static uint32_t ipc_processed_counter; - uint32_t *uncache_counter = cache_to_uncache(&ipc_processed_counter); + uint32_t *uncache_counter = sys_cache_uncached_ptr_get(&ipc_processed_counter); mailbox_sw_reg_write(SRAM_REG_FW_IPC_PROCESSED_COUNT, (*uncache_counter)++); diff --git a/zephyr/include/rtos/cache.h b/zephyr/include/rtos/cache.h index c67279655cbb..cc707f323338 100644 --- a/zephyr/include/rtos/cache.h +++ b/zephyr/include/rtos/cache.h @@ -26,7 +26,6 @@ * TODO: if possible, move these to Zephyr. */ #define SRAM_UNCACHED_ALIAS 0x20000000 -#define is_cached(address) (!!((uintptr_t)(address) & SRAM_UNCACHED_ALIAS)) #endif /* defined(CONFIG_XTENSA) && defined(CONFIG_INTEL) */