From a221affc00faaafbcb06249389221c3dfd3b2220 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Wed, 19 Apr 2023 08:15:58 +0000 Subject: [PATCH] zephyr: use system cache API Use zephyr cache APIs instead of xtensa specific ones. Signed-off-by: Anas Nashif --- src/idc/zephyr_idc.c | 7 ++++--- zephyr/lib/alloc.c | 8 +++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/idc/zephyr_idc.c b/src/idc/zephyr_idc.c index 769e1a32d4ca..36b373e1aad8 100644 --- a/src/idc/zephyr_idc.c +++ b/src/idc/zephyr_idc.c @@ -20,6 +20,7 @@ */ #include +#include #include #include @@ -62,7 +63,7 @@ static void idc_handler(struct k_p4wq_work *work) int payload = -1; k_spinlock_key_t key; - SOC_DCACHE_INVALIDATE(msg, sizeof(*msg)); + sys_cache_data_flush_range(msg, sizeof(*msg)); if (msg->size == sizeof(int)) { const int idc_handler_memcpy_err __unused = @@ -122,13 +123,13 @@ int idc_send_msg(struct idc_msg *msg, uint32_t mode) msg->payload, msg->size); assert(!idc_send_memcpy_err); - SOC_DCACHE_FLUSH(payload->data, MIN(sizeof(payload->data), msg->size)); + sys_cache_data_flush_range(payload->data, MIN(sizeof(payload->data), msg->size)); } /* Temporarily store sender core ID */ msg_cp->core = cpu_get_id(); - SOC_DCACHE_FLUSH(msg_cp, sizeof(*msg_cp)); + sys_cache_data_flush_range(msg_cp, sizeof(*msg_cp)); k_p4wq_submit(q_zephyr_idc + target_cpu, work); switch (mode) { diff --git a/zephyr/lib/alloc.c b/zephyr/lib/alloc.c index 3c41db278509..a9dad84077e3 100644 --- a/zephyr/lib/alloc.c +++ b/zephyr/lib/alloc.c @@ -25,12 +25,9 @@ #include #include #include +#include #include -#if defined(CONFIG_ARCH_XTENSA) && !defined(CONFIG_KERNEL_COHERENCE) -#include -#endif - #if CONFIG_SYS_HEAP_RUNTIME_STATS && CONFIG_IPC_MAJOR_4 #include #endif @@ -216,7 +213,8 @@ static void heap_free(struct k_heap *h, void *mem) if (is_cached(mem)) { mem_uncached = z_soc_uncached_ptr((__sparse_force void __sparse_cache *)mem); - z_xtensa_cache_flush_inv(mem, sys_heap_usable_size(&h->heap, mem_uncached)); + sys_cache_data_flush_and_invd_range(mem, + sys_heap_usable_size(&h->heap, mem_uncached)); mem = mem_uncached; }