Skip to content
Merged
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
24 changes: 24 additions & 0 deletions src/lib/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ static void *rmalloc_sys(size_t bytes)
alloc_memset_region(ptr, bytes, DEBUG_BLOCK_ALLOC_VALUE);
#endif

dcache_writeback_invalidate_region(&memmap.system,
sizeof(memmap.system));

return ptr;
}

Expand All @@ -135,6 +138,7 @@ static void *alloc_block(struct mm_heap *heap, int level,
hdr->used = 1;
heap->info.used += map->block_size;
heap->info.free -= map->block_size;
dcache_writeback_invalidate_region(hdr, sizeof(*hdr));

/* find next free */
for (i = map->first_free; i < map->count; ++i) {
Expand All @@ -151,6 +155,9 @@ static void *alloc_block(struct mm_heap *heap, int level,
alloc_memset_region(ptr, map->block_size, DEBUG_BLOCK_ALLOC_VALUE);
#endif

dcache_writeback_invalidate_region(map, sizeof(*map));
dcache_writeback_invalidate_region(heap, sizeof(*heap));

return ptr;
}

Expand Down Expand Up @@ -201,11 +208,13 @@ static void *alloc_cont_blocks(struct mm_heap *heap, int level,
hdr->size = count;
heap->info.used += count * map->block_size;
heap->info.free -= count * map->block_size;
dcache_writeback_invalidate_region(hdr, sizeof(*hdr));

/* allocate each block */
for (current = start; current < end; current++) {
hdr = &map->block[current];
hdr->used = 1;
dcache_writeback_invalidate_region(hdr, sizeof(*hdr));
}

/* do we need to find a new first free block ? */
Expand All @@ -227,6 +236,9 @@ static void *alloc_cont_blocks(struct mm_heap *heap, int level,
alloc_memset_region(ptr, bytes, DEBUG_BLOCK_ALLOC_VALUE);
#endif

dcache_writeback_invalidate_region(map, sizeof(*map));
dcache_writeback_invalidate_region(heap, sizeof(*heap));

return ptr;
}

Expand Down Expand Up @@ -334,6 +346,7 @@ static void free_block(void *ptr)
block_map->free_count++;
heap->info.used -= block_map->block_size;
heap->info.free += block_map->block_size;
dcache_writeback_invalidate_region(hdr, sizeof(*hdr));
}

/* set first free block */
Expand All @@ -343,6 +356,9 @@ static void free_block(void *ptr)
#if DEBUG_BLOCK_FREE
alloc_memset_region(ptr, block_map->block_size * (i - 1), DEBUG_BLOCK_FREE_VALUE);
#endif

dcache_writeback_invalidate_region(block_map, sizeof(*block_map));
dcache_writeback_invalidate_region(heap, sizeof(*heap));
}

/* allocate single block for runtime */
Expand Down Expand Up @@ -612,13 +628,17 @@ void init_heap(struct sof *sof)

current_map = &heap->map[j];
current_map->base = heap->heap;
dcache_writeback_region(current_map,
sizeof(*current_map));

for (k = 1; k < heap->blocks; k++) {
next_map = &heap->map[k];
next_map->base = current_map->base +
current_map->block_size *
current_map->count;
current_map = &heap->map[k];
dcache_writeback_region(current_map,
sizeof(*current_map));
}
}
}
Expand All @@ -631,13 +651,17 @@ void init_heap(struct sof *sof)

current_map = &heap->map[j];
current_map->base = heap->heap;
dcache_writeback_region(current_map,
sizeof(*current_map));

for (k = 1; k < heap->blocks; k++) {
next_map = &heap->map[k];
next_map->base = current_map->base +
current_map->block_size *
current_map->count;
current_map = &heap->map[k];
dcache_writeback_region(current_map,
sizeof(*current_map));
}
}
}
Expand Down