Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/kernel/init/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include <zephyr/version.h>
#endif
#include <sof/lib/ams.h>
#include <zephyr/cache.h>

LOG_MODULE_REGISTER(init, CONFIG_SOF_LOG_LEVEL);

Expand Down Expand Up @@ -85,7 +86,7 @@ static inline void lp_sram_unpack(void)
size = *ptr++;

memcpy_s(dst, size, src, size);
dcache_writeback_region((__sparse_force void __sparse_cache *)dst, size);
sys_cache_data_flush_range(dst, size);
}
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/kernel/library_manager/lib_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static int lib_manager_load_data_from_storage(void __sparse_cache *vma, void *s_
if (ret < 0)
return ret;

dcache_writeback_region(vma, size);
sys_cache_data_flush_range((__sparse_force void *)vma, size);

return sys_mm_drv_update_region_flags((__sparse_force void *)vma, size, flags);
}
Expand Down Expand Up @@ -1211,7 +1211,7 @@ __cold static int lib_manager_store_library(struct lib_manager_dma_ext *dma_ext,
}

/* Writeback entire library to ensure it's visible to other cores */
dcache_writeback_region((__sparse_force void *)library_base_address, preload_size);
sys_cache_data_flush_range((__sparse_force void *)library_base_address, preload_size);

#if CONFIG_LIBRARY_AUTH_SUPPORT
/* AUTH_PHASE_LAST - do final library authentication checks */
Expand Down
7 changes: 4 additions & 3 deletions src/kernel/library_manager/llext_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ llext_manager_load_data_from_storage(const struct sys_mm_drv_region *virtual_reg

llext_manager_detached_update_flags(sect_addr, shdr->sh_size, flags);
if (flags & SYS_MM_MEM_PERM_EXEC)
icache_invalidate_region(sect_addr, shdr->sh_size);
sys_cache_instr_invd_range((__sparse_force void *)sect_addr,
shdr->sh_size);
continue;
}

Expand All @@ -183,11 +184,11 @@ llext_manager_load_data_from_storage(const struct sys_mm_drv_region *virtual_reg
* We don't know what flags we're changing to, maybe the buffer will be
* executable or read-only. Need to write back caches now
*/
dcache_writeback_region(vma, size);
sys_cache_data_flush_range((__sparse_force void *)vma, size);

ret = llext_manager_update_flags(vma, size, flags);
if (!ret && (flags & SYS_MM_MEM_PERM_EXEC))
icache_invalidate_region(vma, size);
sys_cache_instr_invd_range((__sparse_force void *)vma, size);

return ret;
}
Expand Down
10 changes: 4 additions & 6 deletions src/kernel/library_manager/llext_manager_dram.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <zephyr/llext/llext.h>
#include <zephyr/llext/llext_internal.h>
#include <zephyr/logging/log_ctrl.h>
#include <zephyr/cache.h>

LOG_MODULE_DECLARE(lib_manager, CONFIG_SOF_LOG_LEVEL);

Expand Down Expand Up @@ -153,10 +154,8 @@ int llext_manager_store_to_dram(void)
lib_manager_dram.n_mod = n_mod;

/* Make sure, that the data is actually in the DRAM, not just in data cache */
dcache_writeback_region((__sparse_force void __sparse_cache *)&lib_manager_dram,
sizeof(lib_manager_dram));
dcache_writeback_region((__sparse_force void __sparse_cache *)lib_manager_dram.ctx,
buf_size);
sys_cache_data_flush_range(&lib_manager_dram, sizeof(lib_manager_dram));
sys_cache_data_flush_range(lib_manager_dram.ctx, buf_size);

return 0;
}
Expand All @@ -172,8 +171,7 @@ int llext_manager_restore_from_dram(void)

if (!lib_manager_dram.n_mod || !lib_manager_dram.ctx) {
tr_dbg(&lib_manager_tr, "No modules saved");
dcache_writeback_region((__sparse_force void __sparse_cache *)&lib_manager_dram,
sizeof(lib_manager_dram));
sys_cache_data_flush_range(&lib_manager_dram, sizeof(lib_manager_dram));
return 0;
}

Expand Down
8 changes: 3 additions & 5 deletions src/kernel/platform/intel/cavs/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <rtos/timer.h>
#include <sof/fw-ready-metadata.h>
#include <sof/lib/agent.h>
#include <rtos/cache.h>
#include <zephyr/cache.h>
#include <rtos/clk.h>
#include <sof/lib/cpu.h>
#include <sof/lib/dai.h>
Expand Down Expand Up @@ -209,12 +209,10 @@ static void imr_layout_update(void *vector)
* configuration, no symmetric task need to done in any
* platform_resume() to clear the configuration.
*/
dcache_invalidate_region((__sparse_force void __sparse_cache *)imr_layout,
sizeof(*imr_layout));
sys_cache_data_invd_range(imr_layout, sizeof(*imr_layout));
imr_layout->imr_state.header.adsp_imr_magic = ADSP_IMR_MAGIC_VALUE;
imr_layout->imr_state.header.imr_restore_vector = vector;
dcache_writeback_region((__sparse_force void __sparse_cache *)imr_layout,
sizeof(*imr_layout));
sys_cache_data_flush_range(imr_layout, sizeof(*imr_layout));
}
#endif

Expand Down
16 changes: 8 additions & 8 deletions src/kernel/probe/probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ __cold static int probe_dma_buffer_init(struct probe_dma_buf *buffer, uint32_t s
}

bzero((void *)buffer->addr, size);
dcache_writeback_region((__sparse_force void __sparse_cache *)buffer->addr, size);
sys_cache_data_flush_range((void *)buffer->addr, size);

/* initialise the DMA buffer */
buffer->size = size;
Expand Down Expand Up @@ -383,8 +383,7 @@ static void probe_host_publish(struct probe_dma_ext *dma, uint32_t bytes)
/* host_wr wraps at 2^32; kernel side casts its counter to u32 before subtracting */
dma->host_wr += bytes;
*(volatile uint32_t *)dma->host_base = dma->host_wr;
dcache_writeback_region((__sparse_force void __sparse_cache *)dma->host_base,
sizeof(uint32_t));
sys_cache_data_flush_range((void *)dma->host_base, sizeof(uint32_t));
}
#endif

Expand Down Expand Up @@ -782,7 +781,7 @@ static int copy_to_pbuffer(struct probe_dma_buf *pbuf, void *data,
tr_err(&pr_tr, "memcpy_s() failed");
return -EINVAL;
}
dcache_writeback_region((__sparse_force void __sparse_cache *)pbuf->w_ptr, head);
sys_cache_data_flush_range((void *)pbuf->w_ptr, head);

/* buffer ended so needs to do a second copy */
if (tail) {
Expand All @@ -792,7 +791,7 @@ static int copy_to_pbuffer(struct probe_dma_buf *pbuf, void *data,
tr_err(&pr_tr, "memcpy_s() failed");
return -EINVAL;
}
dcache_writeback_region((__sparse_force void __sparse_cache *)pbuf->w_ptr, tail);
sys_cache_data_flush_range((void *)pbuf->w_ptr, tail);
pbuf->w_ptr = pbuf->w_ptr + tail;
} else {
pbuf->w_ptr = pbuf->w_ptr + head;
Expand Down Expand Up @@ -834,7 +833,7 @@ static int copy_from_pbuffer(struct probe_dma_buf *pbuf, void *data,
}

/* data from DMA so invalidate it */
dcache_invalidate_region((__sparse_force void __sparse_cache *)pbuf->r_ptr, head);
sys_cache_data_invd_range((void *)pbuf->r_ptr, head);
if (memcpy_s(data, bytes, (void *)pbuf->r_ptr, head)) {
tr_err(&pr_tr, "memcpy_s() failed");
return -EINVAL;
Expand All @@ -844,7 +843,7 @@ static int copy_from_pbuffer(struct probe_dma_buf *pbuf, void *data,
if (tail) {
/* starting from the beginning of the buffer */
pbuf->r_ptr = pbuf->addr;
dcache_invalidate_region((__sparse_force void __sparse_cache *)pbuf->r_ptr, tail);
sys_cache_data_invd_range((void *)pbuf->r_ptr, tail);
if (memcpy_s((char *)data + head, tail, (void *)pbuf->r_ptr, tail)) {
tr_err(&pr_tr, "memcpy_s() failed");
return -EINVAL;
Expand Down Expand Up @@ -894,7 +893,7 @@ static int probe_gen_header(uint32_t buffer_id, uint32_t size,
header->timestamp_low +
header->data_size_bytes;

dcache_writeback_region((__sparse_force void __sparse_cache *)header, sizeof(*header));
sys_cache_data_flush_range(header, sizeof(*header));

return copy_to_pbuffer(&_probe->ext_dma.dmapb, header,
sizeof(struct probe_data_packet));
Expand Down Expand Up @@ -1832,6 +1831,7 @@ static const struct module_interface probe_interface = {
#include <module/module/api_ver.h>
#include <module/module/llext.h>
#include <rimage/sof/user/manifest.h>
#include <zephyr/cache.h>

static const struct sof_man_module_manifest mod_manifest __section(".module") __used =
SOF_LLEXT_MODULE_MANIFEST("PROBE", &probe_interface, 1, SOF_REG_UUID(probe4), 40);
Expand Down
6 changes: 2 additions & 4 deletions zephyr/lib/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,8 @@ void l3_heap_save(void)
{
l3_heap_copy = l3_heap;
LOG_DBG("L3 heap copy: %p", (void *)l3_heap_copy.heap.heap);
dcache_writeback_region((__sparse_force void __sparse_cache *)&l3_heap_copy,
sizeof(l3_heap_copy));
dcache_writeback_region((__sparse_force void __sparse_cache *)l3_heap.heap.init_mem,
l3_heap.heap.init_bytes);
sys_cache_data_flush_range(&l3_heap_copy, sizeof(l3_heap_copy));
sys_cache_data_flush_range(l3_heap.heap.init_mem, l3_heap.heap.init_bytes);
}

static void *l3_heap_alloc_aligned(struct k_heap *h, size_t min_align, size_t bytes)
Expand Down
6 changes: 3 additions & 3 deletions zephyr/lib/fast-get.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,7 @@ const void *fast_get(struct mod_alloc_ctx *alloc, const void *dram_ptr, size_t s
* The data is constant, so it's safe to use cached access to
* it, but initially we have to invalidate caches
*/
dcache_invalidate_region((__sparse_force void __sparse_cache *)ret,
size);
sys_cache_data_invd_range(ret, size);
} else if (fast_get_partition_exists(mdom, ret,
ALIGN_UP(size, CONFIG_MM_DRV_PAGE_SIZE))) {
LOG_WRN("Repeated access request by thread");
Expand All @@ -330,7 +329,7 @@ const void *fast_get(struct mod_alloc_ctx *alloc, const void *dram_ptr, size_t s
goto out;

memcpy_s(ret, alloc_size, dram_ptr, size);
dcache_writeback_region((__sparse_force void __sparse_cache *)ret, size);
sys_cache_data_flush_range(ret, size);

#if CONFIG_USERSPACE
struct k_mem_domain *mdom = k_current_get()->mem_domain_info.mem_domain;
Expand Down Expand Up @@ -618,5 +617,6 @@ void z_vrfy_fast_put_ll(const void *sram_ptr)
z_impl_fast_put_ll(sram_ptr);
}
#include <zephyr/syscalls/fast_put_ll_mrsh.c>
#include <zephyr/cache.h>
#endif /* CONFIG_USERSPACE */
#endif /* CONFIG_SOF_USERSPACE_LL */
Loading