Skip to content

Commit c3b6e0a

Browse files
committed
lib_manager: Add cache writeback after library loading to IMR
Add dcache_writeback_region() calls after copying library data to IMR (Isolated Memory Region) to ensure cache coherency in multicore scenarios. Without these cache operations, when Core 0 loads a library into IMR via memcpy_s(), the data remains in Core 0's data cache and is not written back to main memory. When Core 1 later tries to create a module from this library, it reads uninitialized or stale data from IMR, causing either: - "Unsupported module API version" errors (reading garbage build info) - Fatal PIF data errors and crashes (accessing corrupted module data) The fix adds cache writeback operations at two critical points: 1. After copying the manifest (MAN_MAX_SIZE_V1_8 bytes) 2. After copying the entire library (preload_size bytes) This ensures library data written by Core 0 is flushed from cache to IMR memory before Core 1 attempts to read it, following the standard cache coherency protocol for non-coherent Harvard architecture (Xtensa). Fixes multicore topology crashes on Intel MTL, LNL, PTL, NVL platforms when loading external libraries with modules instantiated on secondary cores. Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
1 parent 2e1dcfc commit c3b6e0a

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/library_manager/lib_manager.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,9 @@ static int lib_manager_store_library(struct lib_manager_dma_ext *dma_ext,
929929
memcpy_s((__sparse_force void *)library_base_address, MAN_MAX_SIZE_V1_8,
930930
(__sparse_force const void *)man_buffer, MAN_MAX_SIZE_V1_8);
931931

932+
/* Writeback manifest to ensure it's visible to other cores */
933+
dcache_writeback_region((__sparse_force void *)library_base_address, MAN_MAX_SIZE_V1_8);
934+
932935
/* Copy remaining library part into storage buffer */
933936
ret = lib_manager_store_data(dma_ext, (uint8_t __sparse_cache *)library_base_address +
934937
MAN_MAX_SIZE_V1_8, preload_size - MAN_MAX_SIZE_V1_8);
@@ -937,6 +940,9 @@ static int lib_manager_store_library(struct lib_manager_dma_ext *dma_ext,
937940
return ret;
938941
}
939942

943+
/* Writeback entire library to ensure it's visible to other cores */
944+
dcache_writeback_region((__sparse_force void *)library_base_address, preload_size);
945+
940946
#if CONFIG_LIBRARY_AUTH_SUPPORT
941947
/* AUTH_PHASE_LAST - do final library authentication checks */
942948
ret = lib_manager_auth_proc((__sparse_force void *)library_base_address,

0 commit comments

Comments
 (0)