From 8704c506ab8283424e695535848ba6184831edbd Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 1 Dec 2026 22:30:53 +0000 Subject: [PATCH 1/3] posix: provide from rtos/cache.h On Zephyr, rtos/cache.h includes , so code that includes it for the SOF cache wrappers can also call the Zephyr cache API. Include the stub from the host rtos/cache.h too, so that shared code can switch to the Zephyr calls without new includes. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- posix/include/rtos/cache.h | 1 + 1 file changed, 1 insertion(+) diff --git a/posix/include/rtos/cache.h b/posix/include/rtos/cache.h index 9ec4091bb5a1..a5a499c5e557 100644 --- a/posix/include/rtos/cache.h +++ b/posix/include/rtos/cache.h @@ -15,6 +15,7 @@ #define __SOF_LIB_CACHE_H__ #include +#include /* writeback and invalidate data */ #define CACHE_WRITEBACK_INV 0 From 8751a89b8a3ccd60a118180bc5d616cdaa973f39 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 1 Dec 2026 22:30:53 +0000 Subject: [PATCH 2/3] audio, coherent: call the Zephyr cache API directly dcache_writeback_region(), dcache_invalidate_region() and dcache_writeback_invalidate_region() are inline wrappers of sys_cache_data_flush_range(), sys_cache_data_invd_range() and sys_cache_data_flush_and_invd_range(). The host builds have a stub now, so call the Zephyr functions directly in the coherent API and the audio buffers. The coherent API and the ring buffer pass real __sparse_cache pointers, which get a __sparse_force cast. The other callers cast their pointers to __sparse_cache only to match the wrapper prototypes; that cast becomes a plain (void *). The ring buffer wrap-around calls no longer fit on two lines, so they compute the length of the first part once. That also fixes a comment that said "writeback" in the invalidate function. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/audio/buffers/comp_buffer.c | 6 +++--- src/audio/buffers/ring_buffer.c | 20 +++++++++++--------- src/include/sof/audio/audio_stream.h | 12 ++++++------ src/include/sof/coherent.h | 22 +++++++++++----------- 4 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/audio/buffers/comp_buffer.c b/src/audio/buffers/comp_buffer.c index 7c08d1f32f25..066e6037e75f 100644 --- a/src/audio/buffers/comp_buffer.c +++ b/src/audio/buffers/comp_buffer.c @@ -382,9 +382,9 @@ void buffer_zero(struct comp_buffer *buffer) bzero(audio_stream_get_addr(&buffer->stream), audio_stream_get_size(&buffer->stream)); if (buffer->flags & SOF_MEM_FLAG_DMA) - dcache_writeback_region((__sparse_force void __sparse_cache *) - audio_stream_get_addr(&buffer->stream), - audio_stream_get_size(&buffer->stream)); + sys_cache_data_flush_range((void *) + audio_stream_get_addr(&buffer->stream), + audio_stream_get_size(&buffer->stream)); } int buffer_set_size(struct comp_buffer *buffer, uint32_t size, uint32_t alignment) diff --git a/src/audio/buffers/ring_buffer.c b/src/audio/buffers/ring_buffer.c index fde594d32424..9d9c77d55ff2 100644 --- a/src/audio/buffers/ring_buffer.c +++ b/src/audio/buffers/ring_buffer.c @@ -59,14 +59,15 @@ static inline void ring_buffer_invalidate_shared(struct ring_buffer *ring_buffer /* wrap-around? */ if ((uintptr_t)ptr + size > (uintptr_t)ring_buffer_buffer_end(ring_buffer)) { - /* writeback till the end of circular buffer */ - dcache_invalidate_region - (ptr, (uintptr_t)ring_buffer_buffer_end(ring_buffer) - (uintptr_t)ptr); - size -= (uintptr_t)ring_buffer_buffer_end(ring_buffer) - (uintptr_t)ptr; + size_t head = (uintptr_t)ring_buffer_buffer_end(ring_buffer) - (uintptr_t)ptr; + + /* invalidate till the end of circular buffer */ + sys_cache_data_invd_range((__sparse_force void *)ptr, head); + size -= head; ptr = ring_buffer->_data_buffer; } /* invalidate rest of data */ - dcache_invalidate_region(ptr, size); + sys_cache_data_invd_range((__sparse_force void *)ptr, size); } static inline void ring_buffer_writeback_shared(struct ring_buffer *ring_buffer, @@ -78,14 +79,15 @@ static inline void ring_buffer_writeback_shared(struct ring_buffer *ring_buffer, /* wrap-around? */ if ((uintptr_t)ptr + size > (uintptr_t)ring_buffer_buffer_end(ring_buffer)) { + size_t head = (uintptr_t)ring_buffer_buffer_end(ring_buffer) - (uintptr_t)ptr; + /* writeback till the end of circular buffer */ - dcache_writeback_region - (ptr, (uintptr_t)ring_buffer_buffer_end(ring_buffer) - (uintptr_t)ptr); - size -= (uintptr_t)ring_buffer_buffer_end(ring_buffer) - (uintptr_t)ptr; + sys_cache_data_flush_range((__sparse_force void *)ptr, head); + size -= head; ptr = ring_buffer->_data_buffer; } /* writeback rest of data */ - dcache_writeback_region(ptr, size); + sys_cache_data_flush_range((__sparse_force void *)ptr, size); } diff --git a/src/include/sof/audio/audio_stream.h b/src/include/sof/audio/audio_stream.h index 4f2d3a03c97c..82d4875dfea1 100644 --- a/src/include/sof/audio/audio_stream.h +++ b/src/include/sof/audio/audio_stream.h @@ -736,10 +736,10 @@ static inline void audio_stream_invalidate(struct audio_stream *buffer, uint32_t tail_size = bytes - head_size; } - dcache_invalidate_region((__sparse_force void __sparse_cache *)buffer->r_ptr, head_size); + sys_cache_data_invd_range((void *)buffer->r_ptr, head_size); if (tail_size) - dcache_invalidate_region((__sparse_force void __sparse_cache *)buffer->addr, - tail_size); + sys_cache_data_invd_range((void *)buffer->addr, + tail_size); } /** @@ -759,10 +759,10 @@ static inline void audio_stream_writeback(struct audio_stream *buffer, uint32_t tail_size = bytes - head_size; } - dcache_writeback_region((__sparse_force void __sparse_cache *)buffer->w_ptr, head_size); + sys_cache_data_flush_range((void *)buffer->w_ptr, head_size); if (tail_size) - dcache_writeback_region((__sparse_force void __sparse_cache *)buffer->addr, - tail_size); + sys_cache_data_flush_range((void *)buffer->addr, + tail_size); } /** diff --git a/src/include/sof/coherent.h b/src/include/sof/coherent.h index d7e86bbf09b8..5f57344e7c64 100644 --- a/src/include/sof/coherent.h +++ b/src/include/sof/coherent.h @@ -164,7 +164,7 @@ __must_check static inline struct coherent __sparse_cache *coherent_acquire(stru c->key = k_spin_lock(&c->lock); /* - * FIXME: This is wrong. dcache_invalidate_region() only makes + * FIXME: This is wrong. Invalidating the cache here only makes * sense if we assume, that dirty cache lines might exist for * this object. But in that case those lines could be written * back here thus overwriting either user data, or the coherent @@ -175,7 +175,7 @@ __must_check static inline struct coherent __sparse_cache *coherent_acquire(stru */ /* invalidate local copy */ - dcache_invalidate_region(cc, size); + sys_cache_data_invd_range((__sparse_force void *)cc, size); } /* client can now use cached object safely */ @@ -204,7 +204,7 @@ static inline void coherent_release(struct coherent __sparse_cache *c, CHECK_COHERENT_CORE(c); /* wtb and inv local data to coherent object */ - dcache_writeback_invalidate_region(c, size); + sys_cache_data_flush_and_invd_range((__sparse_force void *)c, size); /* unlock on uncache alias */ k_spin_unlock(&uc->lock, uc->key); @@ -243,7 +243,7 @@ static inline void *__coherent_init(size_t offset, const size_t size) c->core = cpu_get_id(); list_init(&c->list); /* inv local data to coherent object */ - dcache_invalidate_region(uncache_to_cache(object), size); + sys_cache_data_invd_range((__sparse_force void *)uncache_to_cache(object), size); return object; } @@ -276,7 +276,7 @@ static inline void __coherent_shared(struct coherent *c, const size_t size) c->key = k_spin_lock(&c->lock); c->shared = true; - dcache_invalidate_region(uncache_to_cache(c), size); + sys_cache_data_invd_range((__sparse_force void *)uncache_to_cache(c), size); k_spin_unlock(&c->lock, c->key); } @@ -320,7 +320,7 @@ __must_check static inline struct coherent __sparse_cache *coherent_acquire_thre k_mutex_lock(&c->mutex, K_FOREVER); /* invalidate local copy */ - dcache_invalidate_region(cc, size); + sys_cache_data_invd_range((__sparse_force void *)cc, size); } /* client can now use cached object safely */ @@ -350,7 +350,7 @@ static inline void coherent_release_thread(struct coherent __sparse_cache *c, CHECK_COHERENT_CORE(c); /* wtb and inv local data to coherent object */ - dcache_writeback_invalidate_region(c, size); + sys_cache_data_flush_and_invd_range((__sparse_force void *)c, size); /* unlock on uncache alias */ k_mutex_unlock(&uc->mutex); @@ -386,7 +386,7 @@ static inline void *__coherent_init_thread(size_t offset, const size_t size) c->core = cpu_get_id(); list_init(&c->list); /* inv local data to coherent object */ - dcache_invalidate_region(uncache_to_cache(object), size); + sys_cache_data_invd_range((__sparse_force void *)uncache_to_cache(object), size); return object; } @@ -420,7 +420,7 @@ static inline void __coherent_shared_thread(struct coherent *c, const size_t siz k_mutex_lock(&c->mutex, K_FOREVER); c->shared = true; - dcache_invalidate_region(uncache_to_cache(c), size); + sys_cache_data_invd_range((__sparse_force void *)uncache_to_cache(c), size); k_mutex_unlock(&c->mutex); } @@ -450,8 +450,8 @@ static inline void __coherent_shared_thread(struct coherent *c, const size_t siz /* assert if someone passes a cache address in here. */ \ ADDR_IS_COHERENT(object); \ /* wtb and inv local data to coherent object */ \ - dcache_writeback_invalidate_region(uncache_to_cache(object), \ - sizeof(*object)); \ + sys_cache_data_flush_and_invd_range( \ + (__sparse_force void *)uncache_to_cache(object), sizeof(*object)); \ rfree(object); \ } while (0) From a0c466e6bddd64dba654c66333afca82fe34c747 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 1 Dec 2026 22:30:53 +0000 Subject: [PATCH 3/3] treewide: call the Zephyr cache API directly in shared code Call sys_cache_data_flush_range() and sys_cache_data_invd_range() directly instead of the SOF dcache_writeback_region() and dcache_invalidate_region() wrappers in the remaining shared code: the mailbox, the IPC handlers and logging, the IPC gateway copier, the module adapter, the notifier, the dummy DMA driver and the host library memory map. The callers cast their pointers to __sparse_cache only to match the wrapper prototypes; that cast becomes a plain (void *). No lines are added or removed. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- posix/include/sof/lib/mailbox.h | 20 ++++++++++---------- src/audio/copier/copier_ipcgtw.c | 14 +++++++------- src/audio/module_adapter/module/generic.c | 2 +- src/include/sof/lib/mailbox.h | 20 ++++++++++---------- src/ipc/ipc4/handler-user.c | 20 ++++++++++---------- src/kernel/drivers/generic/dummy-dma.c | 4 ++-- src/kernel/ipc/ipc-common-kernel.c | 4 ++-- src/kernel/ipc/ipc4/handler-kernel.c | 4 ++-- src/kernel/ipc/ipc4/handler-user-kernel.c | 8 ++++---- src/kernel/ipc/ipc4/logging.c | 4 ++-- src/kernel/platform/library/lib/memory.c | 4 ++-- src/lib/notifier.c | 8 ++++---- 12 files changed, 56 insertions(+), 56 deletions(-) diff --git a/posix/include/sof/lib/mailbox.h b/posix/include/sof/lib/mailbox.h index 06e2659a5847..30f08d43a3dc 100644 --- a/posix/include/sof/lib/mailbox.h +++ b/posix/include/sof/lib/mailbox.h @@ -50,8 +50,8 @@ void mailbox_dspbox_write(size_t offset, const void *src, size_t bytes) MAILBOX_DSPBOX_SIZE - offset, src, bytes); assert(!dsp_write_err); - dcache_writeback_region((__sparse_force void __sparse_cache *)(MAILBOX_DSPBOX_BASE + - offset), bytes); + sys_cache_data_flush_range((void *)(MAILBOX_DSPBOX_BASE + + offset), bytes); } static inline @@ -60,8 +60,8 @@ void mailbox_dspbox_read(void *dest, size_t dest_size, { int dsp_read_err __unused; - dcache_invalidate_region((__sparse_force void __sparse_cache *)(MAILBOX_DSPBOX_BASE + - offset), bytes); + sys_cache_data_invd_range((void *)(MAILBOX_DSPBOX_BASE + + offset), bytes); dsp_read_err = memcpy_s(dest, dest_size, (void *)(MAILBOX_DSPBOX_BASE + offset), bytes); assert(!dsp_read_err); @@ -81,8 +81,8 @@ void mailbox_hostbox_write(size_t offset, const void *src, size_t bytes) MAILBOX_HOSTBOX_SIZE - offset, src, bytes); assert(!host_write_err); - dcache_writeback_region((__sparse_force void __sparse_cache *)(MAILBOX_HOSTBOX_BASE + - offset), bytes); + sys_cache_data_flush_range((void *)(MAILBOX_HOSTBOX_BASE + + offset), bytes); } #endif @@ -93,8 +93,8 @@ void mailbox_hostbox_read(void *dest, size_t dest_size, { int host_read_err __unused; - dcache_invalidate_region((__sparse_force void __sparse_cache *)(MAILBOX_HOSTBOX_BASE + - offset), bytes); + sys_cache_data_invd_range((void *)(MAILBOX_HOSTBOX_BASE + + offset), bytes); host_read_err = memcpy_s(dest, dest_size, (void *)(MAILBOX_HOSTBOX_BASE + offset), bytes); assert(!host_read_err); @@ -107,8 +107,8 @@ void mailbox_stream_write(size_t offset, const void *src, size_t bytes) MAILBOX_STREAM_SIZE - offset, src, bytes); assert(!stream_write_err); - dcache_writeback_region((__sparse_force void __sparse_cache *)(MAILBOX_STREAM_BASE + - offset), bytes); + sys_cache_data_flush_range((void *)(MAILBOX_STREAM_BASE + + offset), bytes); } #endif /* __SOF_LIB_MAILBOX_H__ */ diff --git a/src/audio/copier/copier_ipcgtw.c b/src/audio/copier/copier_ipcgtw.c index 699518563fa3..1bee44eba33f 100644 --- a/src/audio/copier/copier_ipcgtw.c +++ b/src/audio/copier/copier_ipcgtw.c @@ -127,8 +127,8 @@ __cold int copier_ipcgtw_process(const struct ipc4_ipcgtw_cmd *cmd, assert_can_be_cold(); - dcache_invalidate_region((__sparse_force void __sparse_cache *)MAILBOX_HOSTBOX_BASE, - sizeof(struct ipc4_ipc_gateway_cmd_data)); + sys_cache_data_invd_range((void *)MAILBOX_HOSTBOX_BASE, + sizeof(struct ipc4_ipc_gateway_cmd_data)); in = (const struct ipc4_ipc_gateway_cmd_data *)MAILBOX_HOSTBOX_BASE; dev = find_ipcgtw_by_node_id(in->node_id); @@ -174,11 +174,11 @@ __cold int copier_ipcgtw_process(const struct ipc4_ipcgtw_cmd *cmd, if (sink) { data_size = MIN(cmd->extension.r.data_size, SOF_IPC_MSG_MAX_SIZE - 4); data_size = MIN(data_size, sink_get_free_size(sink)); - dcache_invalidate_region((__sparse_force void __sparse_cache *) - MAILBOX_HOSTBOX_BASE, - data_size + - offsetof(struct ipc4_ipc_gateway_cmd_data, - payload)); + sys_cache_data_invd_range((void *) + MAILBOX_HOSTBOX_BASE, + data_size + + offsetof(struct ipc4_ipc_gateway_cmd_data, + payload)); ret = sink_copy_bytes_from_linear(in->payload, sink, data_size); if (ret) return ret; diff --git a/src/audio/module_adapter/module/generic.c b/src/audio/module_adapter/module/generic.c index 5a82f1dbb56f..446823137872 100644 --- a/src/audio/module_adapter/module/generic.c +++ b/src/audio/module_adapter/module/generic.c @@ -788,7 +788,7 @@ static const void *mod_fast_get_copy(struct processing_module *mod, return NULL; memcpy_s(ptr, size, dram_ptr, size); - dcache_writeback_region((__sparse_force void __sparse_cache *)ptr, size); + sys_cache_data_flush_range((void *)ptr, size); return ptr; } diff --git a/src/include/sof/lib/mailbox.h b/src/include/sof/lib/mailbox.h index 5dbf0160332c..9851f248f07b 100644 --- a/src/include/sof/lib/mailbox.h +++ b/src/include/sof/lib/mailbox.h @@ -49,8 +49,8 @@ void mailbox_dspbox_write(size_t offset, const void *src, size_t bytes) MAILBOX_DSPBOX_SIZE - offset, src, bytes); assert(!dsp_write_err); - dcache_writeback_region((__sparse_force void __sparse_cache *)(MAILBOX_DSPBOX_BASE + - offset), bytes); + sys_cache_data_flush_range((void *)(MAILBOX_DSPBOX_BASE + + offset), bytes); } static inline @@ -59,8 +59,8 @@ void mailbox_dspbox_read(void *dest, size_t dest_size, { int dsp_read_err __unused; - dcache_invalidate_region((__sparse_force void __sparse_cache *)(MAILBOX_DSPBOX_BASE + - offset), bytes); + sys_cache_data_invd_range((void *)(MAILBOX_DSPBOX_BASE + + offset), bytes); dsp_read_err = memcpy_s(dest, dest_size, (void *)(MAILBOX_DSPBOX_BASE + offset), bytes); assert(!dsp_read_err); @@ -80,8 +80,8 @@ void mailbox_hostbox_write(size_t offset, const void *src, size_t bytes) MAILBOX_HOSTBOX_SIZE - offset, src, bytes); assert(!host_write_err); - dcache_writeback_region((__sparse_force void __sparse_cache *)(MAILBOX_HOSTBOX_BASE + - offset), bytes); + sys_cache_data_flush_range((void *)(MAILBOX_HOSTBOX_BASE + + offset), bytes); } #endif @@ -92,8 +92,8 @@ void mailbox_hostbox_read(void *dest, size_t dest_size, { int host_read_err __unused; - dcache_invalidate_region((__sparse_force void __sparse_cache *)(MAILBOX_HOSTBOX_BASE + - offset), bytes); + sys_cache_data_invd_range((void *)(MAILBOX_HOSTBOX_BASE + + offset), bytes); host_read_err = memcpy_s(dest, dest_size, (void *)(MAILBOX_HOSTBOX_BASE + offset), bytes); assert(!host_read_err); @@ -114,8 +114,8 @@ void mailbox_stream_write(size_t offset, const void *src, size_t bytes) MAILBOX_STREAM_SIZE - offset, src, bytes); assert(!stream_write_err); - dcache_writeback_region((__sparse_force void __sparse_cache *)(MAILBOX_STREAM_BASE + - offset), bytes); + sys_cache_data_flush_range((void *)(MAILBOX_STREAM_BASE + + offset), bytes); } #endif diff --git a/src/ipc/ipc4/handler-user.c b/src/ipc/ipc4/handler-user.c index e18bac8c2889..94f613b9e4c0 100644 --- a/src/ipc/ipc4/handler-user.c +++ b/src/ipc/ipc4/handler-user.c @@ -75,8 +75,8 @@ static inline const struct ipc4_pipeline_set_state_data *ipc4_get_pipeline_data( const struct ipc4_pipeline_set_state_data *ppl_data; ppl_data = (const struct ipc4_pipeline_set_state_data *)MAILBOX_HOSTBOX_BASE; - dcache_invalidate_region((__sparse_force void __sparse_cache *)ppl_data, - sizeof(*ppl_data)); + sys_cache_data_invd_range((void *)ppl_data, + sizeof(*ppl_data)); return ppl_data; } @@ -424,8 +424,8 @@ int ipc4_pipeline_id_get(struct ipc4_message_request *ipc4, cnt); return -EINVAL; } - dcache_invalidate_region((__sparse_force void __sparse_cache *)ppl_data->ppl_id, - sizeof(int) * cnt); + sys_cache_data_invd_range((void *)ppl_data->ppl_id, + sizeof(int) * cnt); if (ppl_count) *ppl_count = cnt; if (ppl_id) @@ -745,8 +745,8 @@ __cold void ipc4_prepare_for_kcontrol_get(struct comp_dev *dev, uint8_t param_id case SOF_IPC4_ENUM_CONTROL_PARAM_ID: case SOF_IPC4_BYTES_CONTROL_PARAM_ID: /* We have payload in hostbox */ - dcache_invalidate_region((__sparse_force void __sparse_cache *)MAILBOX_HOSTBOX_BASE, - data_size); + sys_cache_data_invd_range((void *)MAILBOX_HOSTBOX_BASE, + data_size); /* Copy the control payload header from inbox to outbox */ memcpy_s(data_out, data_size, hostbox, @@ -910,8 +910,8 @@ __cold static int ipc4_process_large_config_get(struct ipc4_message_request *ipc /* check for vendor param first */ if (config->extension.r.large_param_id == VENDOR_CONFIG_PARAM) { /* For now only vendor_config case uses payload from hostbox */ - dcache_invalidate_region((__sparse_force void __sparse_cache *)MAILBOX_HOSTBOX_BASE, - config->extension.r.data_off_size); + sys_cache_data_invd_range((void *)MAILBOX_HOSTBOX_BASE, + config->extension.r.data_off_size); ret = ipc4_get_vendor_config_module_instance(dev, drv, config->extension.r.init_block, config->extension.r.final_block, @@ -1062,8 +1062,8 @@ __cold int ipc4_process_large_config_set(struct ipc4_message_request *ipc4) assert_can_be_cold(); - dcache_invalidate_region((__sparse_force void __sparse_cache *)MAILBOX_HOSTBOX_BASE, - config->extension.r.data_off_size); + sys_cache_data_invd_range((void *)MAILBOX_HOSTBOX_BASE, + config->extension.r.data_off_size); tr_dbg(&ipc_tr, "%x : %x", (uint32_t)config->primary.r.module_id, (uint32_t)config->primary.r.instance_id); diff --git a/src/kernel/drivers/generic/dummy-dma.c b/src/kernel/drivers/generic/dummy-dma.c index af5bfad70595..feec983471c9 100644 --- a/src/kernel/drivers/generic/dummy-dma.c +++ b/src/kernel/drivers/generic/dummy-dma.c @@ -104,7 +104,7 @@ static ssize_t dummy_dma_copy_crt_elem(struct dma_chan_pdata *pdata, * On capture this should be safe as host.c does a writeback before * triggering the DMA. */ - dcache_invalidate_region((void *)rptr, copy_size); + sys_cache_data_invd_range((void *)rptr, copy_size); /* Perform the copy, being careful if we overflow the elem */ ret = memcpy_s((void *)wptr, remaining_size, (void *)rptr, copy_size); @@ -114,7 +114,7 @@ static ssize_t dummy_dma_copy_crt_elem(struct dma_chan_pdata *pdata, * On playback, also writeback because host.c does an invalidate to * be able to use the data transferred by the DMA. */ - dcache_writeback_region((void *)wptr, copy_size); + sys_cache_data_flush_range((void *)wptr, copy_size); pdata->elem_progress += copy_size; diff --git a/src/kernel/ipc/ipc-common-kernel.c b/src/kernel/ipc/ipc-common-kernel.c index 3263c63c1255..31ceb7d1d96e 100644 --- a/src/kernel/ipc/ipc-common-kernel.c +++ b/src/kernel/ipc/ipc-common-kernel.c @@ -96,8 +96,8 @@ int ipc_process_on_core(uint32_t core, bool blocking) #if CONFIG_IPC_MAJOR_3 /* The other core will write there its response */ - dcache_invalidate_region((__sparse_force void __sparse_cache *)MAILBOX_HOSTBOX_BASE, - ((struct sof_ipc_cmd_hdr *)ipc->comp_data)->size); + sys_cache_data_invd_range((void *)MAILBOX_HOSTBOX_BASE, + ((struct sof_ipc_cmd_hdr *)ipc->comp_data)->size); #endif /* diff --git a/src/kernel/ipc/ipc4/handler-kernel.c b/src/kernel/ipc/ipc4/handler-kernel.c index cf9188850ed6..0914a7190785 100644 --- a/src/kernel/ipc/ipc4/handler-kernel.c +++ b/src/kernel/ipc/ipc4/handler-kernel.c @@ -369,8 +369,8 @@ __cold static int ipc4_module_process_dx(struct ipc4_message_request *ipc4) return IPC4_INVALID_RESOURCE_ID; } - dcache_invalidate_region((__sparse_force void __sparse_cache *)MAILBOX_HOSTBOX_BASE, - sizeof(dx_info)); + sys_cache_data_invd_range((void *)MAILBOX_HOSTBOX_BASE, + sizeof(dx_info)); ret = memcpy_s(&dx_info, sizeof(dx_info), (const void *)MAILBOX_HOSTBOX_BASE, sizeof(dx_info)); if (ret < 0) diff --git a/src/kernel/ipc/ipc4/handler-user-kernel.c b/src/kernel/ipc/ipc4/handler-user-kernel.c index d50896bf4ae4..3aca22a0f83d 100644 --- a/src/kernel/ipc/ipc4/handler-user-kernel.c +++ b/src/kernel/ipc/ipc4/handler-user-kernel.c @@ -308,8 +308,8 @@ __cold int ipc4_get_large_config_module_instance(struct ipc4_message_request *ip return IPC4_INVALID_CONFIG_DATA_STRUCT; } /* For now only vendor_config case uses payload from hostbox */ - dcache_invalidate_region((__sparse_force void __sparse_cache *)MAILBOX_HOSTBOX_BASE, - config->extension.r.data_off_size); + sys_cache_data_invd_range((void *)MAILBOX_HOSTBOX_BASE, + config->extension.r.data_off_size); ret = ipc4_get_vendor_config_module_instance(dev, drv, config->extension.r.init_block, config->extension.r.final_block, @@ -371,8 +371,8 @@ __cold int ipc4_set_large_config_module_instance(struct ipc4_message_request *ip assert_can_be_cold(); - dcache_invalidate_region((__sparse_force void __sparse_cache *)MAILBOX_HOSTBOX_BASE, - config->extension.r.data_off_size); + sys_cache_data_invd_range((void *)MAILBOX_HOSTBOX_BASE, + config->extension.r.data_off_size); tr_dbg(&ipc_tr, "%x : %x", (uint32_t)config->primary.r.module_id, (uint32_t)config->primary.r.instance_id); diff --git a/src/kernel/ipc/ipc4/logging.c b/src/kernel/ipc/ipc4/logging.c index 60a2fdd5dbb6..0084920704a4 100644 --- a/src/kernel/ipc/ipc4/logging.c +++ b/src/kernel/ipc/ipc4/logging.c @@ -142,7 +142,7 @@ __cold int ipc4_logging_enable_logs(bool first_block, return -EINVAL; } - dcache_invalidate_region((__sparse_force void __sparse_cache *)data, data_offset_or_size); + sys_cache_data_invd_range((void *)data, data_offset_or_size); /* * TODO: support is missing for extended log state info that @@ -246,7 +246,7 @@ __cold int ipc4_logging_enable_logs(bool first_block, * data may be taken from different core to the one we are working * on right now. */ - dcache_invalidate_region((__sparse_force void __sparse_cache *)data, data_offset_or_size); + sys_cache_data_invd_range((void *)data, data_offset_or_size); log_state = (const struct ipc4_log_state_info *)data; diff --git a/src/kernel/platform/library/lib/memory.c b/src/kernel/platform/library/lib/memory.c index 0d32fcda6390..dd243befee40 100644 --- a/src/kernel/platform/library/lib/memory.c +++ b/src/kernel/platform/library/lib/memory.c @@ -144,8 +144,8 @@ void platform_init_memmap(struct sof *sof) buf_heap_map[i].count = buffer_count; buf_heap_map[i].free_count = buffer_count; } - dcache_writeback_region(buf_heap_map, - sizeof(struct block_map) * ARRAY_SIZE(buf_heap_map)); + sys_cache_data_flush_range(buf_heap_map, + sizeof(struct block_map) * ARRAY_SIZE(buf_heap_map)); /* access memory map through uncached region */ sof->memory_map = cache_to_uncache(&memmap); diff --git a/src/lib/notifier.c b/src/lib/notifier.c index 673cc39c98bf..3775d6010244 100644 --- a/src/lib/notifier.c +++ b/src/lib/notifier.c @@ -137,8 +137,8 @@ void notifier_notify_remote(void) struct notify_data *notify_data = notify_data_get() + cpu_get_id(); if (!list_is_empty(¬ify->list[notify_data->type])) { - dcache_invalidate_region((__sparse_force void __sparse_cache *)notify_data->data, - notify_data->data_size); + sys_cache_data_invd_range((void *)notify_data->data, + notify_data->data_size); notifier_notify(notify_data->caller, notify_data->type, notify_data->data); } @@ -169,8 +169,8 @@ void notifier_event(const void *caller, enum notify_id type, uint32_t core_mask, notify_data->data = data; notify_data->data_size = data_size; - dcache_writeback_region((__sparse_force void __sparse_cache *) - notify_data->data, data_size); + sys_cache_data_flush_range((void *) + notify_data->data, data_size); idc_send_msg(¬ify_msg, IDC_NON_BLOCKING); }