Skip to content

Commit f72fa27

Browse files
fast-get: Fix shared data usage by multiple callers
fast_get() for the same data can be called by multiple clients from the same or other cores. Since sram_ptr points to cached memory, writeback is needed after memcpy() to also copy data to uncached memory. When fast_get() is called a second time for the same data, invalidate() is used to bring shared data into another core's cache. This fixes tests which use two SRC modules. Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
1 parent e19293c commit f72fa27

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

zephyr/lib/fast-get.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,13 @@ const void *z_impl_fast_get(struct k_heap *heap, const void *dram_ptr, size_t si
117117
goto out;
118118
}
119119

120-
ret = sof_heap_alloc(heap, SOF_MEM_FLAG_USER, size, 0);
120+
ret = sof_heap_alloc(heap, SOF_MEM_FLAG_USER, size, PLATFORM_DCACHE_ALIGN);
121121
if (!ret)
122122
goto out;
123123
entry->size = size;
124124
entry->sram_ptr = ret;
125125
memcpy_s(entry->sram_ptr, entry->size, dram_ptr, size);
126+
dcache_writeback_region((__sparse_force void __sparse_cache *)entry->sram_ptr, size);
126127
entry->dram_ptr = dram_ptr;
127128
entry->refcount = 1;
128129
out:

0 commit comments

Comments
 (0)