mirror of https://github.com/thesofproject/sof.git
alloc: change way of allocation core context for slave cores
Now master core can allocate core context from the system heap of slave core. Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
This commit is contained in:
parent
57744b8742
commit
b561eb8692
|
@ -107,13 +107,11 @@ void cpu_power_down_core(void)
|
|||
|
||||
free_system_workq();
|
||||
|
||||
free_core_context(arch_cpu_get_id());
|
||||
|
||||
dcache_writeback_invalidate_all();
|
||||
|
||||
/* free entire sys heap, an instance dedicated for this core */
|
||||
free_heap(RZONE_SYS);
|
||||
|
||||
dcache_writeback_invalidate_all();
|
||||
|
||||
/* arch_wait_for_interrupt() not used, because it will cause panic.
|
||||
* This code is executed on irq lvl > 0, which is expected.
|
||||
* Core will be put into reset by host anyway.
|
||||
|
|
|
@ -51,17 +51,11 @@ static inline void alloc_core_context(int core)
|
|||
{
|
||||
struct core_context *core_ctx;
|
||||
|
||||
core_ctx = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*core_ctx));
|
||||
core_ctx = rzalloc_core_sys(core, sizeof(*core_ctx));
|
||||
dcache_writeback_invalidate_region(core_ctx, sizeof(*core_ctx));
|
||||
|
||||
/* xtos_core_data is a big struct, so allocate it from system heap
|
||||
* and never free again. Allocating from runtime heap would be
|
||||
* a waste of a very big memory block.
|
||||
*/
|
||||
if (!core_data_ptr[core])
|
||||
core_data_ptr[core] = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM,
|
||||
sizeof(*core_data_ptr[core]));
|
||||
|
||||
core_data_ptr[core] = rzalloc_core_sys(core,
|
||||
sizeof(*core_data_ptr[core]));
|
||||
core_data_ptr[core]->thread_data_ptr = &core_ctx->td;
|
||||
dcache_writeback_invalidate_region(core_data_ptr[core],
|
||||
sizeof(*core_data_ptr[core]));
|
||||
|
@ -77,14 +71,4 @@ static inline void alloc_core_context(int core)
|
|||
dcache_writeback_region((void *)SOF_BSS_DATA_START, SOF_BSS_DATA_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Frees memory allocated for core specific data.
|
||||
* \param[in] core Slave core for which data needs to be freed.
|
||||
*/
|
||||
static inline void free_core_context(int core)
|
||||
{
|
||||
dcache_writeback_invalidate_region(core_ctx_ptr[core],
|
||||
sizeof(*core_ctx_ptr[core]));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -122,6 +122,9 @@ void rfree(void *ptr);
|
|||
/* heap allocation and free for buffers on 1k boundary */
|
||||
void *rballoc(int zone, uint32_t flags, size_t bytes);
|
||||
|
||||
/* system heap allocation for specific core */
|
||||
void *rzalloc_core_sys(int core, size_t bytes);
|
||||
|
||||
/* utility */
|
||||
void bzero(void *s, size_t n);
|
||||
void *memset(void *s, int c, size_t n);
|
||||
|
|
|
@ -111,14 +111,14 @@ static void alloc_memset_region(void *ptr, uint32_t bytes, uint32_t val)
|
|||
#endif
|
||||
|
||||
/* allocate from system memory pool */
|
||||
static void *rmalloc_sys(int zone, size_t bytes)
|
||||
static void *rmalloc_sys(int zone, int core, size_t bytes)
|
||||
{
|
||||
void *ptr;
|
||||
struct mm_heap *cpu_heap;
|
||||
size_t alignment = 0;
|
||||
|
||||
/* use the heap dedicated for the current core */
|
||||
cpu_heap = memmap.system + cpu_get_id();
|
||||
/* use the heap dedicated for the selected core */
|
||||
cpu_heap = cache_to_uncache(memmap.system + core);
|
||||
|
||||
/* align address to dcache line size */
|
||||
if (cpu_heap->info.used % PLATFORM_DCACHE_ALIGN)
|
||||
|
@ -434,7 +434,7 @@ void *rmalloc(int zone, uint32_t caps, size_t bytes)
|
|||
|
||||
switch (zone & RZONE_TYPE_MASK) {
|
||||
case RZONE_SYS:
|
||||
ptr = rmalloc_sys(zone, bytes);
|
||||
ptr = rmalloc_sys(zone, cpu_get_id(), bytes);
|
||||
break;
|
||||
case RZONE_RUNTIME:
|
||||
ptr = rmalloc_runtime(zone, caps, bytes);
|
||||
|
@ -460,6 +460,22 @@ void *rzalloc(int zone, uint32_t caps, size_t bytes)
|
|||
return ptr;
|
||||
}
|
||||
|
||||
void *rzalloc_core_sys(int core, size_t bytes)
|
||||
{
|
||||
uint32_t flags;
|
||||
void *ptr = NULL;
|
||||
|
||||
spin_lock_irq(&memmap.lock, flags);
|
||||
|
||||
ptr = rmalloc_sys(RZONE_SYS, core, bytes);
|
||||
if (ptr)
|
||||
bzero(ptr, bytes);
|
||||
|
||||
spin_unlock_irq(&memmap.lock, flags);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/* allocates continuous buffers */
|
||||
void *rballoc(int zone, uint32_t caps, size_t bytes)
|
||||
{
|
||||
|
@ -567,7 +583,7 @@ void free_heap(int zone)
|
|||
panic(SOF_IPC_PANIC_MEM);
|
||||
}
|
||||
|
||||
cpu_heap = memmap.system + cpu_get_id();
|
||||
cpu_heap = cache_to_uncache(memmap.system + cpu_get_id());
|
||||
cpu_heap->info.used = 0;
|
||||
cpu_heap->info.free = cpu_heap->size;
|
||||
}
|
||||
|
|
|
@ -143,10 +143,10 @@
|
|||
#define HEAP_SYSTEM_0_BASE \
|
||||
(SOF_TEXT_BASE + SOF_TEXT_SIZE +\
|
||||
SOF_DATA_SIZE + SOF_BSS_DATA_SIZE)
|
||||
#define HEAP_SYSTEM_0_SIZE 0xe000
|
||||
#define HEAP_SYSTEM_0_SIZE 0x8000
|
||||
|
||||
#define HEAP_SYSTEM_1_BASE (HEAP_SYSTEM_0_BASE + HEAP_SYSTEM_0_SIZE)
|
||||
#define HEAP_SYSTEM_1_SIZE 0x1000
|
||||
#define HEAP_SYSTEM_1_SIZE 0x5000
|
||||
|
||||
#define HEAP_SYSTEM_T_SIZE (HEAP_SYSTEM_0_SIZE + HEAP_SYSTEM_1_SIZE)
|
||||
|
||||
|
|
|
@ -248,16 +248,16 @@
|
|||
#define HEAP_SYSTEM_0_BASE (SOF_TEXT_BASE + SOF_TEXT_SIZE + \
|
||||
SOF_DATA_SIZE + SOF_BSS_DATA_SIZE)
|
||||
|
||||
#define HEAP_SYSTEM_0_SIZE 0xe000
|
||||
#define HEAP_SYSTEM_0_SIZE 0x8000
|
||||
|
||||
#define HEAP_SYSTEM_1_BASE (HEAP_SYSTEM_0_BASE + HEAP_SYSTEM_0_SIZE)
|
||||
#define HEAP_SYSTEM_1_SIZE 0x1000
|
||||
#define HEAP_SYSTEM_1_SIZE 0x5000
|
||||
|
||||
#define HEAP_SYSTEM_2_BASE (HEAP_SYSTEM_1_BASE + HEAP_SYSTEM_1_SIZE)
|
||||
#define HEAP_SYSTEM_2_SIZE 0x1000
|
||||
#define HEAP_SYSTEM_2_SIZE 0x5000
|
||||
|
||||
#define HEAP_SYSTEM_3_BASE (HEAP_SYSTEM_2_BASE + HEAP_SYSTEM_2_SIZE)
|
||||
#define HEAP_SYSTEM_3_SIZE 0x1000
|
||||
#define HEAP_SYSTEM_3_SIZE 0x5000
|
||||
|
||||
#define HEAP_SYSTEM_T_SIZE (HEAP_SYSTEM_0_SIZE + HEAP_SYSTEM_1_SIZE + \
|
||||
HEAP_SYSTEM_2_SIZE + HEAP_SYSTEM_3_SIZE)
|
||||
|
|
|
@ -248,16 +248,16 @@
|
|||
#define HEAP_SYSTEM_0_BASE (SOF_TEXT_BASE + SOF_TEXT_SIZE + \
|
||||
SOF_DATA_SIZE + SOF_BSS_DATA_SIZE)
|
||||
|
||||
#define HEAP_SYSTEM_0_SIZE 0xe000
|
||||
#define HEAP_SYSTEM_0_SIZE 0x8000
|
||||
|
||||
#define HEAP_SYSTEM_1_BASE (HEAP_SYSTEM_0_BASE + HEAP_SYSTEM_0_SIZE)
|
||||
#define HEAP_SYSTEM_1_SIZE 0x1000
|
||||
#define HEAP_SYSTEM_1_SIZE 0x5000
|
||||
|
||||
#define HEAP_SYSTEM_2_BASE (HEAP_SYSTEM_1_BASE + HEAP_SYSTEM_1_SIZE)
|
||||
#define HEAP_SYSTEM_2_SIZE 0x1000
|
||||
#define HEAP_SYSTEM_2_SIZE 0x5000
|
||||
|
||||
#define HEAP_SYSTEM_3_BASE (HEAP_SYSTEM_2_BASE + HEAP_SYSTEM_2_SIZE)
|
||||
#define HEAP_SYSTEM_3_SIZE 0x1000
|
||||
#define HEAP_SYSTEM_3_SIZE 0x5000
|
||||
|
||||
#define HEAP_SYSTEM_T_SIZE (HEAP_SYSTEM_0_SIZE + HEAP_SYSTEM_1_SIZE + \
|
||||
HEAP_SYSTEM_2_SIZE + HEAP_SYSTEM_3_SIZE)
|
||||
|
|
|
@ -213,7 +213,7 @@
|
|||
#define HEAP_SYSTEM_0_SIZE 0x8000
|
||||
|
||||
#define HEAP_SYSTEM_1_BASE (HEAP_SYSTEM_0_BASE + HEAP_SYSTEM_0_SIZE)
|
||||
#define HEAP_SYSTEM_1_SIZE 0x1000
|
||||
#define HEAP_SYSTEM_1_SIZE 0x5000
|
||||
|
||||
#define HEAP_SYSTEM_T_SIZE (HEAP_SYSTEM_0_SIZE + HEAP_SYSTEM_1_SIZE)
|
||||
|
||||
|
|
Loading…
Reference in New Issue