Skip to content

Commit 4e726e6

Browse files
authored
Merge pull request #226 from tlauda/topic/system_mem_master_core
alloc: system memory reserved for master core
2 parents 2530814 + 7d38ed1 commit 4e726e6

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

src/lib/alloc.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <sof/panic.h>
3636
#include <sof/trace.h>
3737
#include <sof/lock.h>
38+
#include <sof/cpu.h>
3839
#include <platform/memory.h>
3940
#include <stdint.h>
4041

@@ -104,22 +105,27 @@ static void alloc_memset_region(void *ptr, uint32_t bytes, uint32_t val)
104105
/* allocate from system memory pool */
105106
static void *rmalloc_sys(size_t bytes)
106107
{
107-
void *ptr = (void *)memmap.system.heap;
108+
void *ptr;
109+
110+
/* system memory reserved only for master core */
111+
if (cpu_get_id() != PLATFORM_MASTER_CORE_ID) {
112+
trace_mem_error("eM0");
113+
return NULL;
114+
}
115+
116+
ptr = (void *)memmap.system.heap;
108117

109118
/* always succeeds or panics */
110119
memmap.system.heap += bytes;
111120
if (memmap.system.heap >= HEAP_SYSTEM_BASE + HEAP_SYSTEM_SIZE) {
112-
trace_mem_error("eMd");
121+
trace_mem_error("eM1");
113122
panic(SOF_IPC_PANIC_MEM);
114123
}
115124

116125
#if DEBUG_BLOCK_ALLOC
117126
alloc_memset_region(ptr, bytes, DEBUG_BLOCK_ALLOC_VALUE);
118127
#endif
119128

120-
dcache_writeback_invalidate_region(&memmap.system,
121-
sizeof(memmap.system));
122-
123129
return ptr;
124130
}
125131

0 commit comments

Comments
 (0)