Skip to content

Commit

Permalink
regions_mm: Invalidate cache when freeing memory
Browse files Browse the repository at this point in the history
Platforms based on xtensa have a non-coherent cache between cores. Before
releasing a memory block, it is necessary to invalidate the cache. This
memory block can be allocated by another core and performing cache
writeback by the previous owner will destroy current content of the main
memory.

Signed-off-by: Adrian Warecki <[email protected]>
  • Loading branch information
softwarecki committed Jul 8, 2024
1 parent 9f9ad33 commit 1b45a41
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions zephyr/lib/regions_mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,12 @@ int vmh_free(struct vmh_heap *heap, void *ptr)
if (retval)
return retval;

/* Platforms based on xtensa have a non-coherent cache between cores. Before releasing
* a memory block, it is necessary to invalidate the cache. This memory block can be
* allocated by another core and performing cache writeback by the previous owner will
* destroy current content of the main memory.
*/
sys_cache_data_invd_range(ptr, size_to_free);
return vmh_unmap_region(heap->physical_blocks_allocators[mem_block_iter], ptr,
size_to_free);
}
Expand Down

0 comments on commit 1b45a41

Please sign in to comment.