From de177f3b40180630327e527ca7288dfc060e8832 Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Wed, 20 Mar 2019 16:03:41 +0800 Subject: [PATCH 1/2] memory: unify alloc API Rmalloc and rzalloc would waste much memory for allocation of big chunk of memory. Now refine the algorithm: First remove the rballoc function and user should call rmalloc and rzalloc to allocate memory. Second, if the allocation size > HEAP_BUFFER_SIZE, it would be allocated from buffer heap, or it would be done as usual. And if it is not supported by system heap, rt heap, it would be allocated from buffer heap. Signed-off-by: Rander Wang --- src/audio/buffer.c | 2 +- src/audio/detect_test.c | 2 +- src/audio/eq_fir.c | 6 ++-- src/audio/kpb.c | 2 +- src/audio/src.c | 2 +- src/host/alloc.c | 5 --- src/include/sof/alloc.h | 18 ----------- src/lib/alloc.c | 39 ++++++++++++++++++++--- src/lib/dma-trace.c | 2 +- test/cmocka/src/audio/buffer/mock.c | 2 +- test/cmocka/src/audio/kpb/kpb_mock.c | 2 +- test/cmocka/src/audio/mixer/mock.c | 2 +- test/cmocka/src/lib/alloc/alloc.c | 47 +--------------------------- 13 files changed, 46 insertions(+), 85 deletions(-) diff --git a/src/audio/buffer.c b/src/audio/buffer.c index 648353efb9a1..4980f48223c9 100644 --- a/src/audio/buffer.c +++ b/src/audio/buffer.c @@ -68,7 +68,7 @@ struct comp_buffer *buffer_new(struct sof_ipc_buffer *desc) return NULL; } - buffer->addr = rballoc(RZONE_BUFFER, desc->caps, desc->size); + buffer->addr = rmalloc(RZONE_BUFFER, desc->caps, desc->size); if (!buffer->addr) { rfree(buffer); trace_buffer_error("buffer_new() error: " diff --git a/src/audio/detect_test.c b/src/audio/detect_test.c index ad37bf1ba3ed..cf05afb530c1 100644 --- a/src/audio/detect_test.c +++ b/src/audio/detect_test.c @@ -176,7 +176,7 @@ static int alloc_mem_load(struct comp_data *cd, uint32_t size) if (!size) return 0; - cd->load_memory = rballoc(RZONE_BUFFER, SOF_MEM_CAPS_RAM, size); + cd->load_memory = rmalloc(RZONE_BUFFER, SOF_MEM_CAPS_RAM, size); if (!cd->load_memory) { trace_keyword_error("alloc_mem_load() alloc failed"); diff --git a/src/audio/eq_fir.c b/src/audio/eq_fir.c index 4c32babd0501..67c370a4c466 100644 --- a/src/audio/eq_fir.c +++ b/src/audio/eq_fir.c @@ -345,7 +345,7 @@ static int eq_fir_setup(struct comp_data *cd, int nch) return 0; /* Allocate all FIR channels data in a big chunk and clear it */ - cd->fir_delay = rballoc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, size_sum); + cd->fir_delay = rmalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, size_sum); if (!cd->fir_delay) { trace_eq_error("eq_fir_setup() error: alloc failed, size = %u", size_sum); @@ -434,7 +434,7 @@ static struct comp_dev *eq_fir_new(struct sof_ipc_comp *comp) * the EQ is configured later in run-time the size is zero. */ if (bs) { - cd->config = rballoc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, bs); + cd->config = rmalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, bs); if (!cd->config) { rfree(dev); rfree(cd); @@ -598,7 +598,7 @@ static int fir_cmd_set_data(struct comp_dev *dev, eq_fir_free_parameters(&cd->config); /* Allocate buffer for copy of the blob. */ - cd->config = rballoc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, + cd->config = rmalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, cdata->num_elems + cdata->elems_remaining); diff --git a/src/audio/kpb.c b/src/audio/kpb.c index eabd410306d1..2f5a3ee8312c 100644 --- a/src/audio/kpb.c +++ b/src/audio/kpb.c @@ -201,7 +201,7 @@ static size_t kpb_allocate_history_buffer(struct comp_data *kpb) /* Try to allocate ca_size (current allocation size). At first * attempt it will be equal to hb_size (history buffer size). */ - new_mem_block = rballoc(RZONE_RUNTIME, hb_mcp[i], ca_size); + new_mem_block = rmalloc(RZONE_RUNTIME, hb_mcp[i], ca_size); if (new_mem_block) { /* We managed to allocate a block of ca_size. diff --git a/src/audio/src.c b/src/audio/src.c index 4b4f7995ad4b..8700a5f5c7a0 100644 --- a/src/audio/src.c +++ b/src/audio/src.c @@ -642,7 +642,7 @@ static int src_params(struct comp_dev *dev) if (cd->delay_lines) rfree(cd->delay_lines); - cd->delay_lines = rballoc(RZONE_BUFFER, SOF_MEM_CAPS_RAM, + cd->delay_lines = rmalloc(RZONE_BUFFER, SOF_MEM_CAPS_RAM, delay_lines_size); if (!cd->delay_lines) { trace_src_error("src_params() error: " diff --git a/src/host/alloc.c b/src/host/alloc.c index 23fd40484229..59cb8a5dc640 100644 --- a/src/host/alloc.c +++ b/src/host/alloc.c @@ -55,11 +55,6 @@ void rfree(void *ptr) free(ptr); } -void *rballoc(int zone, uint32_t caps, size_t bytes) -{ - return malloc(bytes); -} - void heap_trace(struct mm_heap *heap, int size) { malloc_info(0, stdout); diff --git a/src/include/sof/alloc.h b/src/include/sof/alloc.h index aa8df02e957d..1e6f4af31f80 100644 --- a/src/include/sof/alloc.h +++ b/src/include/sof/alloc.h @@ -130,7 +130,6 @@ void *_balloc(int zone, uint32_t caps, size_t bytes); void rfree(void *ptr); #if CONFIG_DEBUG_HEAP - #define rmalloc(zone, caps, bytes) \ ({void *_ptr; \ do { \ @@ -157,28 +156,11 @@ void rfree(void *ptr); } while (0); \ _ptr; }) -#define rballoc(zone, caps, bytes) \ - ({void *_ptr; \ - do { \ - _ptr = _balloc(zone, caps, bytes); \ - if (!_ptr) { \ - trace_error(TRACE_CLASS_MEM, \ - "failed to alloc 0x%x bytes caps 0x%x", \ - bytes, caps); \ - alloc_trace_buffer_heap(zone, caps, bytes); \ - } \ - } while (0); \ - _ptr; }) - void alloc_trace_runtime_heap(int zone, uint32_t caps, size_t bytes); void alloc_trace_buffer_heap(int zone, uint32_t caps, size_t bytes); - #else - #define rmalloc(zone, caps, bytes) _malloc(zone, caps, bytes) #define rzalloc(zone, caps, bytes) _zalloc(zone, caps, bytes) -#define rballoc(zone, caps, bytes) _balloc(zone, caps, bytes) - #endif /* system heap allocation for specific core */ diff --git a/src/lib/alloc.c b/src/lib/alloc.c index e7a1c5e7c155..6eba6bf08d82 100644 --- a/src/lib/alloc.c +++ b/src/lib/alloc.c @@ -555,12 +555,34 @@ static void *rmalloc_runtime(int zone, uint32_t caps, size_t bytes) return get_ptr_from_heap(heap, zone, caps, bytes); } +static void *rballoc(int zone, uint32_t caps, size_t bytes) +{ + void *ptr; + + ptr = _balloc(zone, caps, bytes); + +#if CONFIG_DEBUG_HEAP + if (!ptr) { + trace_error(TRACE_CLASS_MEM, + "failed to alloc 0x%x bytes caps 0x%x", + bytes, caps); + + alloc_trace_buffer_heap(zone, caps, bytes); + } +#endif + + return ptr; +} + /* allocates memory - not for direct use, clients use rmalloc() */ void *_malloc(int zone, uint32_t caps, size_t bytes) { uint32_t flags; void *ptr = NULL; + if (bytes >= HEAP_BUFFER_BLOCK_SIZE) + return rballoc(zone, caps, bytes); + spin_lock_irq(&memmap.lock, flags); switch (zone & RZONE_TYPE_MASK) { @@ -568,23 +590,30 @@ void *_malloc(int zone, uint32_t caps, size_t bytes) ptr = rmalloc_sys(zone, caps, cpu_get_id(), bytes); break; case RZONE_SYS_RUNTIME: - ptr = rmalloc_sys_runtime(zone, caps, cpu_get_id(), bytes); + ptr = rmalloc_sys_runtime(zone, caps, cpu_get_id(), + bytes); break; case RZONE_RUNTIME: ptr = rmalloc_runtime(zone, caps, bytes); break; default: trace_mem_error("rmalloc() error: invalid zone"); - panic(SOF_IPC_PANIC_MEM); /* logic non recoverable problem */ + + /* logic non recoverable problem */ + panic(SOF_IPC_PANIC_MEM); break; } + spin_unlock_irq(&memmap.lock, flags); + + if (!ptr) + ptr = _balloc(zone, caps, bytes); + #if DEBUG_BLOCK_FREE if (ptr) bzero(ptr, bytes); #endif - spin_unlock_irq(&memmap.lock, flags); memmap.heap_trace_updated = 1; return ptr; } @@ -618,7 +647,7 @@ void *rzalloc_core_sys(int core, size_t bytes) return ptr; } -/* allocates continuous buffers - not for direct use, clients use rballoc() */ +/* allocates continuous buffers - not for direct use, clients use rmalloc() */ static void *alloc_heap_buffer(struct mm_heap *heap, int zone, uint32_t caps, size_t bytes) { @@ -667,7 +696,7 @@ static void *alloc_heap_buffer(struct mm_heap *heap, int zone, uint32_t caps, return ptr; } -/* allocates continuous buffers - not for direct use, clients use rballoc() */ +/* allocates continuous buffers - not for direct use, clients use rmalloc() */ void *_balloc(int zone, uint32_t caps, size_t bytes) { struct mm_heap *heap; diff --git a/src/lib/dma-trace.c b/src/lib/dma-trace.c index c33b029bde87..80282b6991ff 100644 --- a/src/lib/dma-trace.c +++ b/src/lib/dma-trace.c @@ -170,7 +170,7 @@ static int dma_trace_buffer_init(struct dma_trace_data *d) struct dma_trace_buf *buffer = &d->dmatb; /* allocate new buffer */ - buffer->addr = rballoc(RZONE_BUFFER, + buffer->addr = rmalloc(RZONE_BUFFER, SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_DMA, DMA_TRACE_LOCAL_SIZE); if (!buffer->addr) { diff --git a/test/cmocka/src/audio/buffer/mock.c b/test/cmocka/src/audio/buffer/mock.c index cb08de8ad2cd..ea25e0163488 100644 --- a/test/cmocka/src/audio/buffer/mock.c +++ b/test/cmocka/src/audio/buffer/mock.c @@ -49,7 +49,7 @@ void *rzalloc(int zone, uint32_t caps, size_t bytes) return malloc(bytes); } -void *rballoc(int zone, uint32_t caps, size_t bytes) +void *rmalloc(int zone, uint32_t caps, size_t bytes) { (void)zone; (void)caps; diff --git a/test/cmocka/src/audio/kpb/kpb_mock.c b/test/cmocka/src/audio/kpb/kpb_mock.c index fcc768a20178..6b0790b2504d 100644 --- a/test/cmocka/src/audio/kpb/kpb_mock.c +++ b/test/cmocka/src/audio/kpb/kpb_mock.c @@ -11,7 +11,7 @@ TRACE_IMPL() -void *rballoc(int zone, uint32_t caps, size_t bytes) +void *rmalloc(int zone, uint32_t caps, size_t bytes) { (void)zone; (void)caps; diff --git a/test/cmocka/src/audio/mixer/mock.c b/test/cmocka/src/audio/mixer/mock.c index 6b7714f6f9bc..d10d52899009 100644 --- a/test/cmocka/src/audio/mixer/mock.c +++ b/test/cmocka/src/audio/mixer/mock.c @@ -43,7 +43,7 @@ TRACE_IMPL() -void *rballoc(int zone, uint32_t caps, size_t bytes) +void *rmalloc(int zone, uint32_t caps, size_t bytes) { (void)zone; (void)caps; diff --git a/test/cmocka/src/lib/alloc/alloc.c b/test/cmocka/src/lib/alloc/alloc.c index 410a7bf4b6ea..dfb25829715c 100644 --- a/test/cmocka/src/lib/alloc/alloc.c +++ b/test/cmocka/src/lib/alloc/alloc.c @@ -173,48 +173,6 @@ static struct test_case test_cases[] = { TEST_ZERO, "rzalloc_dma"), TEST_CASE(256, RZONE_RUNTIME, SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_DMA, 2, TEST_ZERO, "rzalloc_dma"), - - /* - * rballoc tests - */ - - TEST_CASE(4, RZONE_BUFFER, SOF_MEM_CAPS_RAM, 1024, - TEST_IMMEDIATE_FREE, "rballoc"), - - TEST_CASE(1, RZONE_BUFFER, SOF_MEM_CAPS_RAM, 2, TEST_BULK, - "rballoc"), - TEST_CASE(4, RZONE_BUFFER, SOF_MEM_CAPS_RAM, 2, TEST_BULK, - "rballoc"), - TEST_CASE(256, RZONE_BUFFER, SOF_MEM_CAPS_RAM, 2, TEST_BULK, - "rballoc"), - - TEST_CASE(1, RZONE_BUFFER, SOF_MEM_CAPS_RAM, 4, TEST_BULK, - "rballoc"), - TEST_CASE(4, RZONE_BUFFER, SOF_MEM_CAPS_RAM, 4, TEST_BULK, - "rballoc"), - TEST_CASE(256, RZONE_BUFFER, SOF_MEM_CAPS_RAM, 4, TEST_BULK, - "rballoc"), - - TEST_CASE(1, RZONE_BUFFER, SOF_MEM_CAPS_RAM, 8, TEST_BULK, - "rballoc"), - TEST_CASE(4, RZONE_BUFFER, SOF_MEM_CAPS_RAM, 8, TEST_BULK, - "rballoc"), - TEST_CASE(256, RZONE_BUFFER, SOF_MEM_CAPS_RAM, 8, TEST_BULK, - "rballoc"), - - TEST_CASE(16, RZONE_BUFFER, SOF_MEM_CAPS_RAM, 64, TEST_BULK, - "rballoc"), - TEST_CASE(4, RZONE_BUFFER, SOF_MEM_CAPS_RAM, 64, TEST_BULK, - "rballoc"), - - TEST_CASE(1, RZONE_BUFFER, SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_DMA, 2, - TEST_BULK, "rballoc_dma"), - TEST_CASE(4, RZONE_BUFFER, SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_DMA, 2, - TEST_BULK, "rballoc_dma"), - TEST_CASE(256, RZONE_BUFFER, SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_DMA, 2, - TEST_BULK, "rballoc_dma"), - TEST_CASE(2048, RZONE_BUFFER, SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_DMA, 100, - TEST_IMMEDIATE_FREE, "rballoc_dma") }; static int setup(void **state) @@ -251,10 +209,7 @@ static void *alloc(struct test_case *tc) { void *mem; - if (tc->alloc_zone == RZONE_BUFFER) - mem = rballoc(tc->alloc_zone, tc->alloc_caps, tc->alloc_size); - else - mem = rmalloc(tc->alloc_zone, tc->alloc_caps, tc->alloc_size); + mem = rmalloc(tc->alloc_zone, tc->alloc_caps, tc->alloc_size); return mem; } From d3d00688517c8bb73a1b132024b1ad1d21163b6a Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Wed, 20 Mar 2019 16:17:03 +0800 Subject: [PATCH 2/2] memory: refine memory usage Change block size of 512 and 1024 to 192 and 320 to save memory. For APL and later chips, cache line size is 64byte in xtensa core. For BYT and HSW, cpu cache is not supported. This PR refines the block size to be aligned to cache line size on supported chips. Now sys_runtime and runtime heap don't support allcation size bigger than 320. Buffer heap would support it. Signed-off-by: Rander Wang --- src/lib/alloc.c | 2 +- .../apollolake/include/platform/memory.h | 52 +++++++++-------- .../baytrail/include/platform/memory.h | 27 +++++---- src/platform/baytrail/memory.c | 22 +++++--- .../cannonlake/include/platform/memory.h | 56 ++++++++++--------- .../haswell/include/platform/memory.h | 27 +++++---- src/platform/haswell/memory.c | 22 +++++--- .../icelake/include/platform/memory.h | 54 +++++++++--------- src/platform/intel/cavs/memory.c | 32 +++++++---- .../suecreek/include/platform/memory.h | 36 +++++++----- 10 files changed, 190 insertions(+), 140 deletions(-) diff --git a/src/lib/alloc.c b/src/lib/alloc.c index 6eba6bf08d82..1b555fc85372 100644 --- a/src/lib/alloc.c +++ b/src/lib/alloc.c @@ -580,7 +580,7 @@ void *_malloc(int zone, uint32_t caps, size_t bytes) uint32_t flags; void *ptr = NULL; - if (bytes >= HEAP_BUFFER_BLOCK_SIZE) + if (bytes >= PLATFORM_BUFFER_BLOCK_SIZE) return rballoc(zone, caps, bytes); spin_lock_irq(&memmap.lock, flags); diff --git a/src/platform/apollolake/include/platform/memory.h b/src/platform/apollolake/include/platform/memory.h index 053915790947..eb3d9b52e234 100644 --- a/src/platform/apollolake/include/platform/memory.h +++ b/src/platform/apollolake/include/platform/memory.h @@ -135,20 +135,24 @@ /* Heap section sizes for system runtime heap for master core */ #define HEAP_SYS_RT_0_COUNT64 64 -#define HEAP_SYS_RT_0_COUNT512 16 -#define HEAP_SYS_RT_0_COUNT1024 4 +#define HEAP_SYS_RT_0_COUNT128 16 +#define HEAP_SYS_RT_0_COUNT192 8 +#define HEAP_SYS_RT_0_COUNT256 4 +#define HEAP_SYS_RT_0_COUNT320 4 /* Heap section sizes for system runtime heap for slave core */ #define HEAP_SYS_RT_X_COUNT64 32 -#define HEAP_SYS_RT_X_COUNT512 8 -#define HEAP_SYS_RT_X_COUNT1024 4 +#define HEAP_SYS_RT_X_COUNT128 8 +#define HEAP_SYS_RT_X_COUNT192 4 +#define HEAP_SYS_RT_X_COUNT256 4 +#define HEAP_SYS_RT_X_COUNT320 4 /* Heap section sizes for module pool */ #define HEAP_RT_COUNT64 128 #define HEAP_RT_COUNT128 64 -#define HEAP_RT_COUNT256 128 -#define HEAP_RT_COUNT512 8 -#define HEAP_RT_COUNT1024 4 +#define HEAP_RT_COUNT192 32 +#define HEAP_RT_COUNT256 16 +#define HEAP_RT_COUNT320 8 #define L2_VECTOR_SIZE 0x1000 @@ -165,12 +169,14 @@ ((PLATFORM_CORE_COUNT - 1) * HEAP_SYSTEM_S_SIZE)) #define HEAP_SYS_RUNTIME_M_SIZE \ - (HEAP_SYS_RT_0_COUNT64 * 64 + HEAP_SYS_RT_0_COUNT512 * 512 + \ - HEAP_SYS_RT_0_COUNT1024 * 1024) + (HEAP_SYS_RT_0_COUNT64 * 64 + HEAP_SYS_RT_0_COUNT128 * 128 + \ + HEAP_SYS_RT_0_COUNT192 * 192 + HEAP_SYS_RT_0_COUNT256 * 256 + \ + HEAP_SYS_RT_0_COUNT320 * 320) #define HEAP_SYS_RUNTIME_S_SIZE \ - (HEAP_SYS_RT_X_COUNT64 * 64 + HEAP_SYS_RT_X_COUNT512 * 512 + \ - HEAP_SYS_RT_X_COUNT1024 * 1024) + (HEAP_SYS_RT_X_COUNT64 * 64 + HEAP_SYS_RT_X_COUNT128 * 128 + \ + HEAP_SYS_RT_X_COUNT192 * 192 + HEAP_SYS_RT_X_COUNT256 * 256 + \ + HEAP_SYS_RT_X_COUNT320 * 320) #define HEAP_SYS_RUNTIME_T_SIZE \ (HEAP_SYS_RUNTIME_M_SIZE + ((PLATFORM_CORE_COUNT - 1) * \ @@ -182,14 +188,16 @@ #define HEAP_RUNTIME_SIZE \ (HEAP_RT_COUNT64 * 64 + HEAP_RT_COUNT128 * 128 + \ - HEAP_RT_COUNT256 * 256 + HEAP_RT_COUNT512 * 512 + \ - HEAP_RT_COUNT1024 * 1024) + HEAP_RT_COUNT192 * 192 + HEAP_RT_COUNT256 * 256 + \ + HEAP_RT_COUNT320 * 320) #define HEAP_BUFFER_BASE (HEAP_RUNTIME_BASE + HEAP_RUNTIME_SIZE) #define HEAP_BUFFER_SIZE (SOF_STACK_END - HEAP_BUFFER_BASE) #define HEAP_BUFFER_BLOCK_SIZE 0x180 #define HEAP_BUFFER_COUNT (HEAP_BUFFER_SIZE / HEAP_BUFFER_BLOCK_SIZE) +#define PLATFORM_BUFFER_BLOCK_SIZE (HEAP_BUFFER_BLOCK_SIZE - 64) + #define LOG_ENTRY_ELF_BASE 0x20000000 #define LOG_ENTRY_ELF_SIZE 0x2000000 @@ -352,14 +360,11 @@ #define LP_SRAM_BASE 0xBE800000 /* Heap section sizes for module pool */ -#define HEAP_RT_LP_COUNT8 0 -#define HEAP_RT_LP_COUNT16 256 -#define HEAP_RT_LP_COUNT32 128 -#define HEAP_RT_LP_COUNT64 64 +#define HEAP_RT_LP_COUNT64 128 #define HEAP_RT_LP_COUNT128 64 -#define HEAP_RT_LP_COUNT256 96 -#define HEAP_RT_LP_COUNT512 8 -#define HEAP_RT_LP_COUNT1024 4 +#define HEAP_RT_LP_COUNT192 32 +#define HEAP_RT_LP_COUNT256 16 +#define HEAP_RT_LP_COUNT320 8 /* Heap configuration */ #define SOF_LP_DATA_SIZE 0x4000 @@ -370,10 +375,9 @@ #define HEAP_LP_RUNTIME_BASE \ (HEAP_LP_SYSTEM_BASE + HEAP_LP_SYSTEM_SIZE) #define HEAP_LP_RUNTIME_SIZE \ - (HEAP_RT_LP_COUNT8 * 8 + HEAP_RT_LP_COUNT16 * 16 + \ - HEAP_RT_LP_COUNT32 * 32 + HEAP_RT_LP_COUNT64 * 64 + \ - HEAP_RT_LP_COUNT128 * 128 + HEAP_RT_LP_COUNT256 * 256 + \ - HEAP_RT_LP_COUNT512 * 512 + HEAP_RT_LP_COUNT1024 * 1024) + (HEAP_RT_LP_COUNT64 * 64 + HEAP_RT_LP_COUNT128 * 128 + \ + HEAP_RT_LP_COUNT192 * 192 + HEAP_RT_LP_COUNT256 * 256 + \ + HEAP_RT_LP_COUNT320 * 320) #define HEAP_LP_BUFFER_BASE LP_SRAM_BASE #define HEAP_LP_BUFFER_SIZE LP_SRAM_SIZE diff --git a/src/platform/baytrail/include/platform/memory.h b/src/platform/baytrail/include/platform/memory.h index b27822a64c26..c8d3805f2b15 100644 --- a/src/platform/baytrail/include/platform/memory.h +++ b/src/platform/baytrail/include/platform/memory.h @@ -105,21 +105,23 @@ void platform_init_memmap(void); * +---------------------+----------------+-----------------------------------+ */ - /* Heap section sizes for module pool */ #define HEAP_RT_COUNT8 0 #define HEAP_RT_COUNT16 48 #define HEAP_RT_COUNT32 48 #define HEAP_RT_COUNT64 32 -#define HEAP_RT_COUNT128 32 -#define HEAP_RT_COUNT256 32 -#define HEAP_RT_COUNT512 4 -#define HEAP_RT_COUNT1024 4 +#define HEAP_RT_COUNT128 16 +#define HEAP_RT_COUNT192 16 +#define HEAP_RT_COUNT256 24 +#define HEAP_RT_COUNT320 2 /* Heap section sizes for system runtime heap */ +#define HEAP_SYS_RT_COUNT32 64 #define HEAP_SYS_RT_COUNT64 64 -#define HEAP_SYS_RT_COUNT512 8 -#define HEAP_SYS_RT_COUNT1024 4 +#define HEAP_SYS_RT_COUNT128 8 +#define HEAP_SYS_RT_COUNT192 4 +#define HEAP_SYS_RT_COUNT256 4 +#define HEAP_SYS_RT_COUNT320 2 /* Heap configuration */ #define SOF_DATA_SIZE 0x6800 @@ -131,15 +133,16 @@ void platform_init_memmap(void); #define HEAP_SYS_RUNTIME_BASE (HEAP_SYSTEM_BASE + HEAP_SYSTEM_SIZE) #define HEAP_SYS_RUNTIME_SIZE \ - (HEAP_SYS_RT_COUNT64 * 64 + HEAP_SYS_RT_COUNT512 * 512 + \ - HEAP_SYS_RT_COUNT1024 * 1024) + (HEAP_SYS_RT_COUNT32 * 32 + HEAP_SYS_RT_COUNT64 * 64 + \ + HEAP_SYS_RT_COUNT128 * 128 + HEAP_SYS_RT_COUNT192 * 192 + \ + HEAP_SYS_RT_COUNT256 * 256 + HEAP_SYS_RT_COUNT320 * 320) #define HEAP_RUNTIME_BASE (HEAP_SYS_RUNTIME_BASE + HEAP_SYS_RUNTIME_SIZE) #define HEAP_RUNTIME_SIZE \ (HEAP_RT_COUNT8 * 8 + HEAP_RT_COUNT16 * 16 + \ HEAP_RT_COUNT32 * 32 + HEAP_RT_COUNT64 * 64 + \ - HEAP_RT_COUNT128 * 128 + HEAP_RT_COUNT256 * 256 + \ - HEAP_RT_COUNT512 * 512 + HEAP_RT_COUNT1024 * 1024) + HEAP_RT_COUNT128 * 128 + HEAP_RT_COUNT192 * 192 + \ + HEAP_RT_COUNT256 * 256 + HEAP_RT_COUNT320 * 320) #define HEAP_BUFFER_BASE (HEAP_RUNTIME_BASE + HEAP_RUNTIME_SIZE) #define HEAP_BUFFER_SIZE \ @@ -149,6 +152,8 @@ void platform_init_memmap(void); #define HEAP_BUFFER_BLOCK_SIZE 0x180 #define HEAP_BUFFER_COUNT (HEAP_BUFFER_SIZE / HEAP_BUFFER_BLOCK_SIZE) +#define PLATFORM_BUFFER_BLOCK_SIZE (HEAP_BUFFER_BLOCK_SIZE - 64) + #define PLATFORM_HEAP_SYSTEM 1 /* one per core */ #define PLATFORM_HEAP_SYSTEM_RUNTIME 1 /* one per core */ #define PLATFORM_HEAP_RUNTIME 1 diff --git a/src/platform/baytrail/memory.c b/src/platform/baytrail/memory.c index 0ba4472540ac..e87a79b56ca3 100644 --- a/src/platform/baytrail/memory.c +++ b/src/platform/baytrail/memory.c @@ -33,15 +33,21 @@ #include /* Heap blocks for system runtime */ +static struct block_hdr sys_rt_block32[HEAP_SYS_RT_COUNT32]; static struct block_hdr sys_rt_block64[HEAP_SYS_RT_COUNT64]; -static struct block_hdr sys_rt_block512[HEAP_SYS_RT_COUNT512]; -static struct block_hdr sys_rt_block1024[HEAP_SYS_RT_COUNT1024]; +static struct block_hdr sys_rt_block128[HEAP_SYS_RT_COUNT128]; +static struct block_hdr sys_rt_block192[HEAP_SYS_RT_COUNT192]; +static struct block_hdr sys_rt_block256[HEAP_SYS_RT_COUNT256]; +static struct block_hdr sys_rt_block320[HEAP_SYS_RT_COUNT320]; /* Heap memory for system runtime */ static struct block_map sys_rt_heap_map[] = { + BLOCK_DEF(32, HEAP_SYS_RT_COUNT32, sys_rt_block32), BLOCK_DEF(64, HEAP_SYS_RT_COUNT64, sys_rt_block64), - BLOCK_DEF(512, HEAP_SYS_RT_COUNT512, sys_rt_block512), - BLOCK_DEF(1024, HEAP_SYS_RT_COUNT1024, sys_rt_block1024), + BLOCK_DEF(128, HEAP_SYS_RT_COUNT128, sys_rt_block128), + BLOCK_DEF(192, HEAP_SYS_RT_COUNT192, sys_rt_block192), + BLOCK_DEF(256, HEAP_SYS_RT_COUNT256, sys_rt_block256), + BLOCK_DEF(320, HEAP_SYS_RT_COUNT320, sys_rt_block320), }; /* Heap blocks for modules */ @@ -49,9 +55,9 @@ static struct block_hdr mod_block16[HEAP_RT_COUNT16]; static struct block_hdr mod_block32[HEAP_RT_COUNT32]; static struct block_hdr mod_block64[HEAP_RT_COUNT64]; static struct block_hdr mod_block128[HEAP_RT_COUNT128]; +static struct block_hdr mod_block192[HEAP_RT_COUNT192]; static struct block_hdr mod_block256[HEAP_RT_COUNT256]; -static struct block_hdr mod_block512[HEAP_RT_COUNT512]; -static struct block_hdr mod_block1024[HEAP_RT_COUNT1024]; +static struct block_hdr mod_block320[HEAP_RT_COUNT320]; /* Heap memory map for modules */ static struct block_map rt_heap_map[] = { @@ -59,9 +65,9 @@ static struct block_map rt_heap_map[] = { BLOCK_DEF(32, HEAP_RT_COUNT32, mod_block32), BLOCK_DEF(64, HEAP_RT_COUNT64, mod_block64), BLOCK_DEF(128, HEAP_RT_COUNT128, mod_block128), + BLOCK_DEF(192, HEAP_RT_COUNT192, mod_block192), BLOCK_DEF(256, HEAP_RT_COUNT256, mod_block256), - BLOCK_DEF(512, HEAP_RT_COUNT512, mod_block512), - BLOCK_DEF(1024, HEAP_RT_COUNT1024, mod_block1024), + BLOCK_DEF(320, HEAP_RT_COUNT320, mod_block320), }; /* Heap blocks for buffers */ diff --git a/src/platform/cannonlake/include/platform/memory.h b/src/platform/cannonlake/include/platform/memory.h index 30011de73ae3..f3924e855e42 100644 --- a/src/platform/cannonlake/include/platform/memory.h +++ b/src/platform/cannonlake/include/platform/memory.h @@ -180,20 +180,24 @@ /* Heap section sizes for system runtime heap for master core */ #define HEAP_SYS_RT_0_COUNT64 64 -#define HEAP_SYS_RT_0_COUNT512 16 -#define HEAP_SYS_RT_0_COUNT1024 4 +#define HEAP_SYS_RT_0_COUNT128 16 +#define HEAP_SYS_RT_0_COUNT192 8 +#define HEAP_SYS_RT_0_COUNT256 4 +#define HEAP_SYS_RT_0_COUNT320 4 /* Heap section sizes for system runtime heap for slave core */ #define HEAP_SYS_RT_X_COUNT64 32 -#define HEAP_SYS_RT_X_COUNT512 8 -#define HEAP_SYS_RT_X_COUNT1024 4 +#define HEAP_SYS_RT_X_COUNT128 8 +#define HEAP_SYS_RT_X_COUNT192 4 +#define HEAP_SYS_RT_X_COUNT256 4 +#define HEAP_SYS_RT_X_COUNT320 4 /* Heap section sizes for module pool */ #define HEAP_RT_COUNT64 128 -#define HEAP_RT_COUNT128 64 -#define HEAP_RT_COUNT256 128 -#define HEAP_RT_COUNT512 8 -#define HEAP_RT_COUNT1024 4 +#define HEAP_RT_COUNT128 64 +#define HEAP_RT_COUNT192 32 +#define HEAP_RT_COUNT256 16 +#define HEAP_RT_COUNT320 8 #define L2_VECTOR_SIZE 0x1000 @@ -273,12 +277,14 @@ ((PLATFORM_CORE_COUNT - 1) * HEAP_SYSTEM_S_SIZE)) #define HEAP_SYS_RUNTIME_M_SIZE \ - (HEAP_SYS_RT_0_COUNT64 * 64 + HEAP_SYS_RT_0_COUNT512 * 512 + \ - HEAP_SYS_RT_0_COUNT1024 * 1024) + (HEAP_SYS_RT_0_COUNT64 * 64 + HEAP_SYS_RT_0_COUNT128 * 128 + \ + HEAP_SYS_RT_0_COUNT192 * 192 + HEAP_SYS_RT_0_COUNT256 * 256 + \ + HEAP_SYS_RT_0_COUNT320 * 320) #define HEAP_SYS_RUNTIME_S_SIZE \ - (HEAP_SYS_RT_X_COUNT64 * 64 + HEAP_SYS_RT_X_COUNT512 * 512 + \ - HEAP_SYS_RT_X_COUNT1024 * 1024) + (HEAP_SYS_RT_X_COUNT64 * 64 + HEAP_SYS_RT_X_COUNT128 * 128 + \ + HEAP_SYS_RT_X_COUNT192 * 192 + HEAP_SYS_RT_X_COUNT256 * 256 + \ + HEAP_SYS_RT_X_COUNT320 * 320) #define HEAP_SYS_RUNTIME_T_SIZE \ (HEAP_SYS_RUNTIME_M_SIZE + ((PLATFORM_CORE_COUNT - 1) * \ @@ -290,8 +296,8 @@ #define HEAP_RUNTIME_SIZE \ (HEAP_RT_COUNT64 * 64 + HEAP_RT_COUNT128 * 128 + \ - HEAP_RT_COUNT256 * 256 + HEAP_RT_COUNT512 * 512 + \ - HEAP_RT_COUNT1024 * 1024) + HEAP_RT_COUNT192 * 192 + HEAP_RT_COUNT256 * 256 + \ + HEAP_RT_COUNT320 * 320) /* Stack configuration */ #define SOF_STACK_SIZE ARCH_STACK_SIZE @@ -306,6 +312,8 @@ #define HEAP_BUFFER_BLOCK_SIZE 0x180 #define HEAP_BUFFER_COUNT (HEAP_BUFFER_SIZE / HEAP_BUFFER_BLOCK_SIZE) +#define PLATFORM_BUFFER_BLOCK_SIZE (HEAP_BUFFER_BLOCK_SIZE - 64) + #define SOF_MEMORY_SIZE (SOF_STACK_BASE - HP_SRAM_BASE) /* * The LP SRAM Heap and Stack on Cannonlake are organised like this :- @@ -333,14 +341,11 @@ #define LP_SRAM_BASE 0xBE800000 /* Heap section sizes for module pool */ -#define HEAP_RT_LP_COUNT8 0 -#define HEAP_RT_LP_COUNT16 256 -#define HEAP_RT_LP_COUNT32 128 -#define HEAP_RT_LP_COUNT64 64 -#define HEAP_RT_LP_COUNT128 64 -#define HEAP_RT_LP_COUNT256 96 -#define HEAP_RT_LP_COUNT512 8 -#define HEAP_RT_LP_COUNT1024 4 +#define HEAP_RT_LP_COUNT64 128 +#define HEAP_RT_LP_COUNT128 64 +#define HEAP_RT_LP_COUNT192 32 +#define HEAP_RT_LP_COUNT256 16 +#define HEAP_RT_LP_COUNT320 8 /* Heap configuration */ #define SOF_LP_DATA_SIZE 0x4000 @@ -350,10 +355,9 @@ #define HEAP_LP_RUNTIME_BASE (HEAP_LP_SYSTEM_BASE + HEAP_LP_SYSTEM_SIZE) #define HEAP_LP_RUNTIME_SIZE \ - (HEAP_RT_LP_COUNT8 * 8 + HEAP_RT_LP_COUNT16 * 16 + \ - HEAP_RT_LP_COUNT32 * 32 + HEAP_RT_LP_COUNT64 * 64 + \ - HEAP_RT_LP_COUNT128 * 128 + HEAP_RT_LP_COUNT256 * 256 + \ - HEAP_RT_LP_COUNT512 * 512 + HEAP_RT_LP_COUNT1024 * 1024) + (HEAP_RT_LP_COUNT64 * 64 + HEAP_RT_LP_COUNT128 * 128 + \ + HEAP_RT_LP_COUNT192 * 192 + HEAP_RT_LP_COUNT256 * 256 + \ + HEAP_RT_LP_COUNT320 * 320) #define HEAP_LP_BUFFER_BASE (HEAP_LP_RUNTIME_BASE + HEAP_LP_RUNTIME_SIZE) #define HEAP_LP_BUFFER_SIZE \ diff --git a/src/platform/haswell/include/platform/memory.h b/src/platform/haswell/include/platform/memory.h index 08c4d9e8a3ea..3c554b7083ed 100644 --- a/src/platform/haswell/include/platform/memory.h +++ b/src/platform/haswell/include/platform/memory.h @@ -100,21 +100,23 @@ void platform_init_memmap(void); * +---------------------+----------------+-----------------------------------+ */ - /* Heap section sizes for module pool */ #define HEAP_RT_COUNT8 0 #define HEAP_RT_COUNT16 192 #define HEAP_RT_COUNT32 128 #define HEAP_RT_COUNT64 64 -#define HEAP_RT_COUNT128 64 -#define HEAP_RT_COUNT256 64 -#define HEAP_RT_COUNT512 8 -#define HEAP_RT_COUNT1024 4 +#define HEAP_RT_COUNT128 32 +#define HEAP_RT_COUNT192 16 +#define HEAP_RT_COUNT256 24 +#define HEAP_RT_COUNT320 4 /* Heap section sizes for system runtime heap */ +#define HEAP_SYS_RT_COUNT32 64 #define HEAP_SYS_RT_COUNT64 64 -#define HEAP_SYS_RT_COUNT512 8 -#define HEAP_SYS_RT_COUNT1024 4 +#define HEAP_SYS_RT_COUNT128 8 +#define HEAP_SYS_RT_COUNT192 4 +#define HEAP_SYS_RT_COUNT256 4 +#define HEAP_SYS_RT_COUNT320 2 /* Heap configuration */ #define SOF_DATA_SIZE 0xa000 @@ -126,15 +128,16 @@ void platform_init_memmap(void); #define HEAP_SYS_RUNTIME_BASE (HEAP_SYSTEM_BASE + HEAP_SYSTEM_SIZE) #define HEAP_SYS_RUNTIME_SIZE \ - (HEAP_SYS_RT_COUNT64 * 64 + HEAP_SYS_RT_COUNT512 * 512 + \ - HEAP_SYS_RT_COUNT1024 * 1024) + (HEAP_SYS_RT_COUNT32 * 32 + HEAP_SYS_RT_COUNT64 * 64 + \ + HEAP_SYS_RT_COUNT128 * 128 + HEAP_SYS_RT_COUNT192 * 192 + \ + HEAP_SYS_RT_COUNT256 * 256 + HEAP_SYS_RT_COUNT320 * 320) #define HEAP_RUNTIME_BASE (HEAP_SYS_RUNTIME_BASE + HEAP_SYS_RUNTIME_SIZE) #define HEAP_RUNTIME_SIZE \ (HEAP_RT_COUNT8 * 8 + HEAP_RT_COUNT16 * 16 + \ HEAP_RT_COUNT32 * 32 + HEAP_RT_COUNT64 * 64 + \ - HEAP_RT_COUNT128 * 128 + HEAP_RT_COUNT256 * 256 + \ - HEAP_RT_COUNT512 * 512 + HEAP_RT_COUNT1024 * 1024) + HEAP_RT_COUNT128 * 128 + HEAP_RT_COUNT192 * 192 + \ + HEAP_RT_COUNT256 * 256 + HEAP_RT_COUNT320 * 320) #define HEAP_BUFFER_BASE (HEAP_RUNTIME_BASE + HEAP_RUNTIME_SIZE) #define HEAP_BUFFER_SIZE \ @@ -145,6 +148,8 @@ void platform_init_memmap(void); #define HEAP_BUFFER_BLOCK_SIZE 0x180 #define HEAP_BUFFER_COUNT (HEAP_BUFFER_SIZE / HEAP_BUFFER_BLOCK_SIZE) +#define PLATFORM_BUFFER_BLOCK_SIZE (HEAP_BUFFER_BLOCK_SIZE - 64) + #define PLATFORM_HEAP_SYSTEM 1 /* one per core */ #define PLATFORM_HEAP_SYSTEM_RUNTIME 1 /* one per core */ #define PLATFORM_HEAP_RUNTIME 1 diff --git a/src/platform/haswell/memory.c b/src/platform/haswell/memory.c index 0ba4472540ac..e87a79b56ca3 100644 --- a/src/platform/haswell/memory.c +++ b/src/platform/haswell/memory.c @@ -33,15 +33,21 @@ #include /* Heap blocks for system runtime */ +static struct block_hdr sys_rt_block32[HEAP_SYS_RT_COUNT32]; static struct block_hdr sys_rt_block64[HEAP_SYS_RT_COUNT64]; -static struct block_hdr sys_rt_block512[HEAP_SYS_RT_COUNT512]; -static struct block_hdr sys_rt_block1024[HEAP_SYS_RT_COUNT1024]; +static struct block_hdr sys_rt_block128[HEAP_SYS_RT_COUNT128]; +static struct block_hdr sys_rt_block192[HEAP_SYS_RT_COUNT192]; +static struct block_hdr sys_rt_block256[HEAP_SYS_RT_COUNT256]; +static struct block_hdr sys_rt_block320[HEAP_SYS_RT_COUNT320]; /* Heap memory for system runtime */ static struct block_map sys_rt_heap_map[] = { + BLOCK_DEF(32, HEAP_SYS_RT_COUNT32, sys_rt_block32), BLOCK_DEF(64, HEAP_SYS_RT_COUNT64, sys_rt_block64), - BLOCK_DEF(512, HEAP_SYS_RT_COUNT512, sys_rt_block512), - BLOCK_DEF(1024, HEAP_SYS_RT_COUNT1024, sys_rt_block1024), + BLOCK_DEF(128, HEAP_SYS_RT_COUNT128, sys_rt_block128), + BLOCK_DEF(192, HEAP_SYS_RT_COUNT192, sys_rt_block192), + BLOCK_DEF(256, HEAP_SYS_RT_COUNT256, sys_rt_block256), + BLOCK_DEF(320, HEAP_SYS_RT_COUNT320, sys_rt_block320), }; /* Heap blocks for modules */ @@ -49,9 +55,9 @@ static struct block_hdr mod_block16[HEAP_RT_COUNT16]; static struct block_hdr mod_block32[HEAP_RT_COUNT32]; static struct block_hdr mod_block64[HEAP_RT_COUNT64]; static struct block_hdr mod_block128[HEAP_RT_COUNT128]; +static struct block_hdr mod_block192[HEAP_RT_COUNT192]; static struct block_hdr mod_block256[HEAP_RT_COUNT256]; -static struct block_hdr mod_block512[HEAP_RT_COUNT512]; -static struct block_hdr mod_block1024[HEAP_RT_COUNT1024]; +static struct block_hdr mod_block320[HEAP_RT_COUNT320]; /* Heap memory map for modules */ static struct block_map rt_heap_map[] = { @@ -59,9 +65,9 @@ static struct block_map rt_heap_map[] = { BLOCK_DEF(32, HEAP_RT_COUNT32, mod_block32), BLOCK_DEF(64, HEAP_RT_COUNT64, mod_block64), BLOCK_DEF(128, HEAP_RT_COUNT128, mod_block128), + BLOCK_DEF(192, HEAP_RT_COUNT192, mod_block192), BLOCK_DEF(256, HEAP_RT_COUNT256, mod_block256), - BLOCK_DEF(512, HEAP_RT_COUNT512, mod_block512), - BLOCK_DEF(1024, HEAP_RT_COUNT1024, mod_block1024), + BLOCK_DEF(320, HEAP_RT_COUNT320, mod_block320), }; /* Heap blocks for buffers */ diff --git a/src/platform/icelake/include/platform/memory.h b/src/platform/icelake/include/platform/memory.h index 4ab15f68db6f..6954c14e84fb 100644 --- a/src/platform/icelake/include/platform/memory.h +++ b/src/platform/icelake/include/platform/memory.h @@ -183,20 +183,24 @@ /* Heap section sizes for system runtime heap for master core */ #define HEAP_SYS_RT_0_COUNT64 64 -#define HEAP_SYS_RT_0_COUNT512 16 -#define HEAP_SYS_RT_0_COUNT1024 4 +#define HEAP_SYS_RT_0_COUNT128 16 +#define HEAP_SYS_RT_0_COUNT192 8 +#define HEAP_SYS_RT_0_COUNT256 4 +#define HEAP_SYS_RT_0_COUNT320 4 /* Heap section sizes for system runtime heap for slave core */ #define HEAP_SYS_RT_X_COUNT64 32 -#define HEAP_SYS_RT_X_COUNT512 8 -#define HEAP_SYS_RT_X_COUNT1024 4 +#define HEAP_SYS_RT_X_COUNT128 8 +#define HEAP_SYS_RT_X_COUNT192 4 +#define HEAP_SYS_RT_X_COUNT256 4 +#define HEAP_SYS_RT_X_COUNT320 4 /* Heap section sizes for module pool */ #define HEAP_RT_COUNT64 128 #define HEAP_RT_COUNT128 64 -#define HEAP_RT_COUNT256 128 -#define HEAP_RT_COUNT512 8 -#define HEAP_RT_COUNT1024 4 +#define HEAP_RT_COUNT192 32 +#define HEAP_RT_COUNT256 16 +#define HEAP_RT_COUNT320 8 #define L2_VECTOR_SIZE 0x1000 @@ -274,12 +278,14 @@ ((PLATFORM_CORE_COUNT - 1) * HEAP_SYSTEM_S_SIZE)) #define HEAP_SYS_RUNTIME_M_SIZE \ - (HEAP_SYS_RT_0_COUNT64 * 64 + HEAP_SYS_RT_0_COUNT512 * 512 + \ - HEAP_SYS_RT_0_COUNT1024 * 1024) + (HEAP_SYS_RT_0_COUNT64 * 64 + HEAP_SYS_RT_0_COUNT128 * 128 + \ + HEAP_SYS_RT_0_COUNT192 * 192 + HEAP_SYS_RT_0_COUNT256 * 256 + \ + HEAP_SYS_RT_0_COUNT320 * 320) #define HEAP_SYS_RUNTIME_S_SIZE \ - (HEAP_SYS_RT_X_COUNT64 * 64 + HEAP_SYS_RT_X_COUNT512 * 512 + \ - HEAP_SYS_RT_X_COUNT1024 * 1024) + (HEAP_SYS_RT_X_COUNT64 * 64 + HEAP_SYS_RT_X_COUNT128 * 128 + \ + HEAP_SYS_RT_X_COUNT192 * 192 + HEAP_SYS_RT_X_COUNT256 * 256 + \ + HEAP_SYS_RT_X_COUNT320 * 320) #define HEAP_SYS_RUNTIME_T_SIZE \ (HEAP_SYS_RUNTIME_M_SIZE + ((PLATFORM_CORE_COUNT - 1) * \ @@ -291,8 +297,8 @@ #define HEAP_RUNTIME_SIZE \ (HEAP_RT_COUNT64 * 64 + HEAP_RT_COUNT128 * 128 + \ - HEAP_RT_COUNT256 * 256 + HEAP_RT_COUNT512 * 512 + \ - HEAP_RT_COUNT1024 * 1024) + HEAP_RT_COUNT192 * 192 + HEAP_RT_COUNT256 * 256 + \ + HEAP_RT_COUNT320 * 320) /* Stack configuration */ #define SOF_STACK_SIZE ARCH_STACK_SIZE @@ -306,6 +312,8 @@ #define HEAP_BUFFER_BLOCK_SIZE 0x180 #define HEAP_BUFFER_COUNT (HEAP_BUFFER_SIZE / HEAP_BUFFER_BLOCK_SIZE) +#define PLATFORM_BUFFER_BLOCK_SIZE (HEAP_BUFFER_BLOCK_SIZE - 64) + #define SOF_MEMORY_SIZE (SOF_STACK_BASE - HP_SRAM_BASE) /* @@ -334,14 +342,11 @@ #define LP_SRAM_BASE 0xBE800000 /* Heap section sizes for module pool */ -#define HEAP_RT_LP_COUNT8 0 -#define HEAP_RT_LP_COUNT16 256 -#define HEAP_RT_LP_COUNT32 128 -#define HEAP_RT_LP_COUNT64 64 -#define HEAP_RT_LP_COUNT128 64 -#define HEAP_RT_LP_COUNT256 96 -#define HEAP_RT_LP_COUNT512 8 -#define HEAP_RT_LP_COUNT1024 4 +#define HEAP_RT_LP_COUNT64 128 +#define HEAP_RT_LP_COUNT128 64 +#define HEAP_RT_LP_COUNT192 32 +#define HEAP_RT_LP_COUNT256 16 +#define HEAP_RT_LP_COUNT320 8 /* Heap configuration */ #define SOF_LP_DATA_SIZE 0x4000 @@ -351,10 +356,9 @@ #define HEAP_LP_RUNTIME_BASE (HEAP_LP_SYSTEM_BASE + HEAP_LP_SYSTEM_SIZE) #define HEAP_LP_RUNTIME_SIZE \ - (HEAP_RT_LP_COUNT8 * 8 + HEAP_RT_LP_COUNT16 * 16 + \ - HEAP_RT_LP_COUNT32 * 32 + HEAP_RT_LP_COUNT64 * 64 + \ - HEAP_RT_LP_COUNT128 * 128 + HEAP_RT_LP_COUNT256 * 256 + \ - HEAP_RT_LP_COUNT512 * 512 + HEAP_RT_LP_COUNT1024 * 1024) + (HEAP_RT_LP_COUNT64 * 64 + HEAP_RT_LP_COUNT128 * 128 + \ + HEAP_RT_LP_COUNT192 * 192 + HEAP_RT_LP_COUNT256 * 256 + \ + HEAP_RT_LP_COUNT320 * 320) #define HEAP_LP_BUFFER_BASE (HEAP_LP_RUNTIME_BASE + HEAP_LP_RUNTIME_SIZE) #define HEAP_LP_BUFFER_SIZE \ diff --git a/src/platform/intel/cavs/memory.c b/src/platform/intel/cavs/memory.c index da676284f862..7b0542b06fb8 100644 --- a/src/platform/intel/cavs/memory.c +++ b/src/platform/intel/cavs/memory.c @@ -35,42 +35,50 @@ /* Heap blocks for system runtime for master core */ static struct block_hdr sys_rt_0_block64[HEAP_SYS_RT_0_COUNT64]; -static struct block_hdr sys_rt_0_block512[HEAP_SYS_RT_0_COUNT512]; -static struct block_hdr sys_rt_0_block1024[HEAP_SYS_RT_0_COUNT1024]; +static struct block_hdr sys_rt_0_block128[HEAP_SYS_RT_0_COUNT128]; +static struct block_hdr sys_rt_0_block192[HEAP_SYS_RT_0_COUNT192]; +static struct block_hdr sys_rt_0_block256[HEAP_SYS_RT_0_COUNT256]; +static struct block_hdr sys_rt_0_block320[HEAP_SYS_RT_0_COUNT320]; /* Heap memory for system runtime for master core */ static struct block_map sys_rt_0_heap_map[] = { BLOCK_DEF(64, HEAP_SYS_RT_0_COUNT64, sys_rt_0_block64), - BLOCK_DEF(512, HEAP_SYS_RT_0_COUNT512, sys_rt_0_block512), - BLOCK_DEF(1024, HEAP_SYS_RT_0_COUNT1024, sys_rt_0_block1024), + BLOCK_DEF(128, HEAP_SYS_RT_0_COUNT128, sys_rt_0_block128), + BLOCK_DEF(192, HEAP_SYS_RT_0_COUNT192, sys_rt_0_block192), + BLOCK_DEF(256, HEAP_SYS_RT_0_COUNT256, sys_rt_0_block256), + BLOCK_DEF(320, HEAP_SYS_RT_0_COUNT320, sys_rt_0_block320), }; /* Heap blocks for system runtime for slave core */ static struct block_hdr sys_rt_x_block64[HEAP_SYS_RT_X_COUNT64]; -static struct block_hdr sys_rt_x_block512[HEAP_SYS_RT_X_COUNT512]; -static struct block_hdr sys_rt_x_block1024[HEAP_SYS_RT_X_COUNT1024]; +static struct block_hdr sys_rt_x_block128[HEAP_SYS_RT_X_COUNT128]; +static struct block_hdr sys_rt_x_block192[HEAP_SYS_RT_X_COUNT192]; +static struct block_hdr sys_rt_x_block256[HEAP_SYS_RT_X_COUNT256]; +static struct block_hdr sys_rt_x_block320[HEAP_SYS_RT_X_COUNT320]; /* Heap memory for system runtime for slave core */ static struct block_map sys_rt_x_heap_map[] = { BLOCK_DEF(64, HEAP_SYS_RT_X_COUNT64, sys_rt_x_block64), - BLOCK_DEF(512, HEAP_SYS_RT_X_COUNT512, sys_rt_x_block512), - BLOCK_DEF(1024, HEAP_SYS_RT_X_COUNT1024, sys_rt_x_block1024), + BLOCK_DEF(128, HEAP_SYS_RT_X_COUNT128, sys_rt_x_block128), + BLOCK_DEF(192, HEAP_SYS_RT_X_COUNT192, sys_rt_x_block192), + BLOCK_DEF(256, HEAP_SYS_RT_X_COUNT256, sys_rt_x_block256), + BLOCK_DEF(320, HEAP_SYS_RT_X_COUNT320, sys_rt_x_block320), }; /* Heap blocks for modules */ static struct block_hdr mod_block64[HEAP_RT_COUNT64]; static struct block_hdr mod_block128[HEAP_RT_COUNT128]; +static struct block_hdr mod_block192[HEAP_RT_COUNT192]; static struct block_hdr mod_block256[HEAP_RT_COUNT256]; -static struct block_hdr mod_block512[HEAP_RT_COUNT512]; -static struct block_hdr mod_block1024[HEAP_RT_COUNT1024]; +static struct block_hdr mod_block320[HEAP_RT_COUNT320]; /* Heap memory map for modules */ static struct block_map rt_heap_map[] = { BLOCK_DEF(64, HEAP_RT_COUNT64, mod_block64), BLOCK_DEF(128, HEAP_RT_COUNT128, mod_block128), + BLOCK_DEF(192, HEAP_RT_COUNT192, mod_block192), BLOCK_DEF(256, HEAP_RT_COUNT256, mod_block256), - BLOCK_DEF(512, HEAP_RT_COUNT512, mod_block512), - BLOCK_DEF(1024, HEAP_RT_COUNT1024, mod_block1024), + BLOCK_DEF(320, HEAP_RT_COUNT320, mod_block320), }; /* Heap blocks for buffers */ diff --git a/src/platform/suecreek/include/platform/memory.h b/src/platform/suecreek/include/platform/memory.h index ed1a2709a484..a1017a6f6c87 100644 --- a/src/platform/suecreek/include/platform/memory.h +++ b/src/platform/suecreek/include/platform/memory.h @@ -201,20 +201,24 @@ /* Heap section sizes for system runtime heap for master core */ #define HEAP_SYS_RT_0_COUNT64 64 -#define HEAP_SYS_RT_0_COUNT512 16 -#define HEAP_SYS_RT_0_COUNT1024 4 +#define HEAP_SYS_RT_0_COUNT128 16 +#define HEAP_SYS_RT_0_COUNT192 8 +#define HEAP_SYS_RT_0_COUNT256 4 +#define HEAP_SYS_RT_0_COUNT320 4 /* Heap section sizes for system runtime heap for slave core */ #define HEAP_SYS_RT_X_COUNT64 32 -#define HEAP_SYS_RT_X_COUNT512 8 -#define HEAP_SYS_RT_X_COUNT1024 4 +#define HEAP_SYS_RT_X_COUNT128 8 +#define HEAP_SYS_RT_X_COUNT192 4 +#define HEAP_SYS_RT_X_COUNT256 4 +#define HEAP_SYS_RT_X_COUNT320 4 /* Heap section sizes for module pool */ #define HEAP_RT_COUNT64 192 -#define HEAP_RT_COUNT128 32 -#define HEAP_RT_COUNT256 80 -#define HEAP_RT_COUNT512 8 -#define HEAP_RT_COUNT1024 4 +#define HEAP_RT_COUNT128 64 +#define HEAP_RT_COUNT192 32 +#define HEAP_RT_COUNT256 16 +#define HEAP_RT_COUNT320 8 #define L2_VECTOR_SIZE 0x2000 @@ -279,12 +283,14 @@ ((PLATFORM_CORE_COUNT - 1) * HEAP_SYSTEM_S_SIZE)) #define HEAP_SYS_RUNTIME_M_SIZE \ - (HEAP_SYS_RT_0_COUNT64 * 64 + HEAP_SYS_RT_0_COUNT512 * 512 + \ - HEAP_SYS_RT_0_COUNT1024 * 1024) + (HEAP_SYS_RT_0_COUNT64 * 64 + HEAP_SYS_RT_0_COUNT128 * 128 + \ + HEAP_SYS_RT_0_COUNT192 * 192 + HEAP_SYS_RT_0_COUNT256 * 256 + \ + HEAP_SYS_RT_0_COUNT320 * 320) #define HEAP_SYS_RUNTIME_S_SIZE \ - (HEAP_SYS_RT_X_COUNT64 * 64 + HEAP_SYS_RT_X_COUNT512 * 512 + \ - HEAP_SYS_RT_X_COUNT1024 * 1024) + (HEAP_SYS_RT_X_COUNT64 * 64 + HEAP_SYS_RT_X_COUNT128 * 128 + \ + HEAP_SYS_RT_X_COUNT192 * 192 + HEAP_SYS_RT_X_COUNT256 * 256 + \ + HEAP_SYS_RT_X_COUNT320 * 320) #define HEAP_SYS_RUNTIME_T_SIZE \ (HEAP_SYS_RUNTIME_M_SIZE + ((PLATFORM_CORE_COUNT - 1) * \ @@ -296,8 +302,8 @@ #define HEAP_RUNTIME_SIZE \ (HEAP_RT_COUNT64 * 64 + HEAP_RT_COUNT128 * 128 + \ - HEAP_RT_COUNT256 * 256 + HEAP_RT_COUNT512 * 512 + \ - HEAP_RT_COUNT1024 * 1024) + HEAP_RT_COUNT192 * 192 + HEAP_RT_COUNT256 * 256 + \ + HEAP_RT_COUNT320 * 320) /* Stack configuration */ #define SOF_STACK_SIZE ARCH_STACK_SIZE @@ -310,6 +316,8 @@ #define HEAP_BUFFER_BLOCK_SIZE 0x180 #define HEAP_BUFFER_COUNT (HEAP_BUFFER_SIZE / HEAP_BUFFER_BLOCK_SIZE) +#define PLATFORM_BUFFER_BLOCK_SIZE (HEAP_BUFFER_BLOCK_SIZE - 64) + #define HEAP_HP_BUFFER_COUNT 0 #define HEAP_HP_BUFFER_BLOCK_SIZE 0 #define HEAP_HP_BUFFER_BASE 0