Skip to content
Open
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
12 changes: 10 additions & 2 deletions zephyr/lib/vregion.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,11 @@ struct vregion *vregion_create(size_t memsize)
*/
total_size = ALIGN_UP(memsize, CONFIG_MM_DRV_PAGE_SIZE);

/* allocate vregion metadata separately to keep it inaccessible to the user */
vr = rmalloc(0, sizeof(*vr));
/* allocate vregion metadata separately to keep it inaccessible to the user.
* Use coherent memory so interim heap state written on one core is
* visible to other cores during cross-core buffer allocation.
*/
vr = rmalloc(SOF_MEM_FLAG_COHERENT, sizeof(*vr));
if (!vr)
return NULL;

Expand Down Expand Up @@ -254,6 +257,11 @@ static void interim_heap_init(struct vregion *vr)
k_heap_init(&vr->interim.heap, interim_base, interim_size);
vr->type = VREGION_MEM_TYPE_INTERIM;

/* Flush the heap metadata written by k_heap_init to main memory
* so other cores can access the interim heap without stale cache.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, but should heap be initialited with coherent address and cached addresses given out when/if needed? It seems all heap actions are now unsafe with multicore unless you have explicit cache flushes whenever the heap is used via k_heap. Am I missing something?

*/
sys_cache_data_flush_range(interim_base, interim_size);
Comment on lines +260 to +263

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address this


/* Update lifetime heap with the interim heap usage. */
vr->lifetime.ptr = (void *)(interim_base + interim_size);
vr->lifetime.used = (uint8_t *)vr->lifetime.ptr - (uint8_t *)vr->lifetime.base;
Expand Down
Loading