From dc72159511db2d3ed26c313cacdadb924b7f3729 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Fri, 23 Jul 2021 19:41:13 +0800 Subject: [PATCH 01/13] pipeline-params: add heap debug support. Show heap status update with every pipeline going to be run, when CONFIG_DEBUG_HEAP is enabled. This will help to monitor the heap memory usage status. Signed-off-by: Keyon Jie --- src/audio/pipeline/pipeline-params.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/audio/pipeline/pipeline-params.c b/src/audio/pipeline/pipeline-params.c index 63dbbdc36669..86ed235a8c01 100644 --- a/src/audio/pipeline/pipeline-params.c +++ b/src/audio/pipeline/pipeline-params.c @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include #include #include @@ -235,6 +237,10 @@ int pipeline_params(struct pipeline *p, struct comp_dev *host, ret, dev_comp_id(host)); } +#if CONFIG_DEBUG_HEAP + /* show heap status update with this pipeline run */ + heap_trace_all(0); +#endif return ret; } From 01d79d1a1e848fc947de81b7694cc84f420a1e8b Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Fri, 23 Jul 2021 19:50:50 +0800 Subject: [PATCH 02/13] alloc: fix heap_trace() block start index Fix and log the information of block 0 also. Signed-off-by: Keyon Jie --- src/lib/alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/alloc.c b/src/lib/alloc.c index d7b2a1ca47ad..6e24db2d4f1e 100644 --- a/src/lib/alloc.c +++ b/src/lib/alloc.c @@ -1073,7 +1073,7 @@ void heap_trace(struct mm_heap *heap, int size) heap->info.free); /* map[j]'s base is calculated based on map[j-1] */ - for (j = 1; j < heap->blocks; j++) { + for (j = 0; j < heap->blocks; j++) { current_map = &heap->map[j]; tr_info(&mem_tr, " block %d base 0x%x size %d", From 62c68427618a0e4d717890b1b34954245d4629ef Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Mon, 26 Jul 2021 19:07:39 +0800 Subject: [PATCH 03/13] alloc: trace error when allocation failed with no condition No matter if CONFIG_DEBUG_HEAP selected or not, we need to print out error message when allocation failed. Signed-off-by: Keyon Jie --- src/lib/alloc.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/lib/alloc.c b/src/lib/alloc.c index 6e24db2d4f1e..b90569f70a79 100644 --- a/src/lib/alloc.c +++ b/src/lib/alloc.c @@ -620,14 +620,22 @@ static void alloc_trace_heap(enum mem_zone zone, uint32_t caps, size_t bytes) #define DEBUG_TRACE_PTR(ptr, bytes, zone, caps, flags) \ do { \ - if (!ptr) { \ - tr_err(&mem_tr, "failed to alloc 0x%x bytes zone 0x%x caps 0x%x flags 0x%x", \ + if (!(ptr)) { \ + tr_err(&mem_tr, \ + "failed to alloc 0x%x bytes zone 0x%x caps 0x%x flags 0x%x", \ bytes, zone, caps, flags); \ alloc_trace_heap(zone, caps, bytes); \ } \ } while (0) #else -#define DEBUG_TRACE_PTR(ptr, bytes, zone, caps, flags) +#define DEBUG_TRACE_PTR(ptr, bytes, zone, caps, flags) \ + do { \ + if (!(ptr)) { \ + tr_err(&mem_tr, \ + "failed to alloc 0x%x bytes zone 0x%x caps 0x%x flags 0x%x", \ + bytes, zone, caps, flags); \ + } \ + } while (0) #endif /* allocate single block for system runtime */ From 7a8891fb6909183badc50a5d82db8a8fa2eb8314 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Mon, 26 Jul 2021 19:04:26 +0800 Subject: [PATCH 04/13] trace: Kconfig: disable filtering by default The trace filtering will suppress useful logs and make debugging difficult, disable it by default. Signed-off-by: Keyon Jie --- src/trace/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/trace/Kconfig b/src/trace/Kconfig index 2e7cdfc2f1e6..f26aabf5cc73 100644 --- a/src/trace/Kconfig +++ b/src/trace/Kconfig @@ -35,14 +35,14 @@ config TRACEM config TRACE_FILTERING bool "Trace filtering" depends on TRACE - default y + default n help Filtering of trace messages based on their verbosity level and frequency. config TRACE_FILTERING_VERBOSITY bool "Filter by verbosity" depends on TRACE_FILTERING - default y + default n help Filtering by log verbosity level, where maximum verbosity allowed is specified for each context and may be adjusted in runtime. @@ -50,7 +50,7 @@ config TRACE_FILTERING_VERBOSITY config TRACE_FILTERING_ADAPTIVE bool "Adaptive rate limiting" depends on TRACE_FILTERING - default y + default n help Adaptive filtering of trace messages, tracking up to CONFIG_TRACE_RECENT_ENTRIES_COUNT, suppressing all repeated messages for up to CONFIG_TRACE_RECENT_TIME_THRESHOLD cycles. From 980a183758df2f9ee352dcb5ebe26239c64fd9d6 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Fri, 2 Jul 2021 14:37:35 +0800 Subject: [PATCH 05/13] alloc: add more coverage to log all details of the allocation Add coverage to log out details during memory allocation, including successful allocation, and all zone types heap. Signed-off-by: Keyon Jie --- src/lib/alloc.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/lib/alloc.c b/src/lib/alloc.c index b90569f70a79..b8de66ee65ba 100644 --- a/src/lib/alloc.c +++ b/src/lib/alloc.c @@ -584,6 +584,14 @@ static void alloc_trace_heap(enum mem_zone zone, uint32_t caps, size_t bytes) int count = 0; switch (zone) { + case SOF_MEM_ZONE_SYS: + heap_base = memmap->system; + heap_count = PLATFORM_HEAP_SYSTEM; + break; + case SOF_MEM_ZONE_SYS_RUNTIME: + heap_base = memmap->system_runtime; + heap_count = PLATFORM_HEAP_SYSTEM_RUNTIME; + break; case SOF_MEM_ZONE_RUNTIME: heap_base = memmap->runtime; heap_count = PLATFORM_HEAP_RUNTIME; @@ -592,6 +600,25 @@ static void alloc_trace_heap(enum mem_zone zone, uint32_t caps, size_t bytes) heap_base = memmap->buffer; heap_count = PLATFORM_HEAP_BUFFER; break; +#if CONFIG_CORE_COUNT > 1 + case SOF_MEM_ZONE_RUNTIME_SHARED: + heap_base = memmap->runtime_shared; + heap_count = PLATFORM_HEAP_RUNTIME_SHARED; + break; + case SOF_MEM_ZONE_SYS_SHARED: + heap_base = memmap->system_shared; + heap_count = PLATFORM_HEAP_SYSTEM_SHARED; + break; +#else + case SOF_MEM_ZONE_RUNTIME_SHARED: + heap_base = memmap->runtime; + heap_count = PLATFORM_HEAP_RUNTIME; + break; + case SOF_MEM_ZONE_SYS_SHARED: + heap_base = memmap->system; + heap_count = PLATFORM_HEAP_SYSTEM; + break; +#endif default: tr_err(&mem_tr, "alloc trace: unsupported mem zone"); goto out; @@ -773,7 +800,6 @@ void *rzalloc(enum mem_zone zone, uint32_t flags, uint32_t caps, size_t bytes) if (ptr) bzero(ptr, bytes); - DEBUG_TRACE_PTR(ptr, bytes, zone, caps, flags); return ptr; } @@ -1102,6 +1128,10 @@ void heap_trace_all(int force) /* has heap changed since last shown */ if (memmap->heap_trace_updated || force) { + tr_info(&mem_tr, "heap: system status"); + heap_trace(memmap->system, PLATFORM_HEAP_SYSTEM); + tr_info(&mem_tr, "heap: system runtime status"); + heap_trace(memmap->system_runtime, PLATFORM_HEAP_SYSTEM_RUNTIME); tr_info(&mem_tr, "heap: buffer status"); heap_trace(memmap->buffer, PLATFORM_HEAP_BUFFER); tr_info(&mem_tr, "heap: runtime status"); @@ -1109,6 +1139,8 @@ void heap_trace_all(int force) #if CONFIG_CORE_COUNT > 1 tr_info(&mem_tr, "heap: runtime shared status"); heap_trace(memmap->runtime_shared, PLATFORM_HEAP_RUNTIME_SHARED); + tr_info(&mem_tr, "heap: system shared status"); + heap_trace(memmap->system_shared, PLATFORM_HEAP_SYSTEM_SHARED); #endif } From c85713bfc78dc186855e8ba7ff31a655048c3a40 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Thu, 1 Jul 2021 14:44:26 +0800 Subject: [PATCH 06/13] memory: tigerlake: correct comments about HP SRAM organization Some minor corrections to the tigerlake HP SRAM organization. Signed-off-by: Keyon Jie --- .../tigerlake/include/platform/lib/memory.h | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/src/platform/tigerlake/include/platform/lib/memory.h b/src/platform/tigerlake/include/platform/lib/memory.h index ecf152ed5fa0..abdb18df8114 100644 --- a/src/platform/tigerlake/include/platform/lib/memory.h +++ b/src/platform/tigerlake/include/platform/lib/memory.h @@ -135,47 +135,47 @@ /* * The HP SRAM Region on Tigerlake is organised like this :- - * +--------------------------------------------------------------------------+ - * | Offset | Region | Size | - * +------------------+-------------------------+-----------------------------+ - * | SRAM_SW_REG_BASE | SW Registers W0 | SRAM_SW_REG_SIZE | - * +------------------+-------------------------+-----------------------------+ - * | SRAM_OUTBOX_BASE | Outbox W0 | SRAM_MAILBOX_SIZE | - * +------------------+-------------------------+-----------------------------+ - * | SRAM_INBOX_BASE | Inbox W1 | SRAM_INBOX_SIZE | - * +------------------+-------------------------+-----------------------------+ - * | SRAM_DEBUG_BASE | Debug data W2 | SRAM_DEBUG_SIZE | - * +------------------+-------------------------+-----------------------------+ - * | SRAM_EXCEPT_BASE | Debug data W2 | SRAM_EXCEPT_SIZE | - * +------------------+-------------------------+-----------------------------+ - * | SRAM_STREAM_BASE | Stream data W2 | SRAM_STREAM_SIZE | - * +------------------+-------------------------+-----------------------------+ - * | SRAM_TRACE_BASE | Trace Buffer W3 | SRAM_TRACE_SIZE | - * +------------------+-------------------------+-----------------------------+ - * | HP_SRAM_BASE | DMA | HEAP_HP_BUFFER_SIZE | - * +------------------+-------------------------+-----------------------------+ - * | SOF_FW_START | text | | - * | | data | | - * | | BSS | | - * +------------------+-------------------------+-----------------------------+ - * | | Runtime Heap | HEAP_RUNTIME_SIZE | - * +------------------+-------------------------+-----------------------------+ - * | | Runtime shared Heap | HEAP_RUNTIME_SHARED_SIZE | - * | |-------------------------+-----------------------------+ - * | | System shared Heap | HEAP_SYSTEM_SHARED_SIZE | - * | |-------------------------+-----------------------------+ - * | | Module Buffers | HEAP_BUFFER_SIZE | - * +------------------+-------------------------+-----------------------------+ - * | | Primary core Sys Heap | HEAP_SYSTEM_M_SIZE | - * +------------------+-------------------------+-----------------------------+ - * | | Pri. Sys Runtime Heap | HEAP_SYS_RUNTIME_M_SIZE | - * +------------------+-------------------------+-----------------------------+ - * | | Primary core Stack | SOF_STACK_SIZE | - * +------------------+-------------------------+-----------------------------+ - * | | Sec. core Sys Heap | SOF_CORE_S_T_SIZE | - * | | Sec. Sys Runtime Heap | | - * | | Secondary core Stack | | - * +------------------+-------------------------+-----------------------------+ + * +----------------------------------------------------------------------------+ + * | Offset | Region | Size | + * +--------------------+-------------------------+-----------------------------+ + * | SRAM_SW_REG_BASE | SW Registers W0 | SRAM_SW_REG_SIZE | + * +--------------------+-------------------------+-----------------------------+ + * | SRAM_OUTBOX_BASE | Outbox W0 | SRAM_OUTBOX_SIZE | + * +--------------------+-------------------------+-----------------------------+ + * | SRAM_INBOX_BASE | Inbox W1 | SRAM_INBOX_SIZE | + * +--------------------+-------------------------+-----------------------------+ + * | SRAM_DEBUG_BASE | Debug data W2 | SRAM_DEBUG_SIZE | + * +--------------------+-------------------------+-----------------------------+ + * | SRAM_EXCEPT_BASE | Debug data W2 | SRAM_EXCEPT_SIZE | + * +--------------------+-------------------------+-----------------------------+ + * | SRAM_STREAM_BASE | Stream data W2 | SRAM_STREAM_SIZE | + * +--------------------+-------------------------+-----------------------------+ + * | SRAM_TRACE_BASE | Trace Buffer W3 | SRAM_TRACE_SIZE | + * +--------------------+-------------------------+-----------------------------+ + * | HEAP_HP_BUFFER_BASE| DMA | HEAP_HP_BUFFER_SIZE | + * +--------------------+-------------------------+-----------------------------+ + * | SOF_FW_START | text | | + * | | data | | + * | | BSS | | + * +--------------------+-------------------------+-----------------------------+ + * | | Runtime Heap | HEAP_RUNTIME_SIZE | + * +--------------------+-------------------------+-----------------------------+ + * | | Runtime shared Heap | HEAP_RUNTIME_SHARED_SIZE | + * | |-------------------------+-----------------------------+ + * | | System shared Heap | HEAP_SYSTEM_SHARED_SIZE | + * | |-------------------------+-----------------------------+ + * | | Module Buffers | HEAP_BUFFER_SIZE | + * +--------------------+-------------------------+-----------------------------+ + * | | Primary core Sys Heap | HEAP_SYSTEM_M_SIZE | + * +--------------------+-------------------------+-----------------------------+ + * | | Pri. Sys Runtime Heap | HEAP_SYS_RUNTIME_M_SIZE | + * +--------------------+-------------------------+-----------------------------+ + * | | Primary core Stack | SOF_STACK_SIZE | + * +--------------------+-------------------------+-----------------------------+ + * | | Sec. core Sys Heap | SOF_CORE_S_T_SIZE | + * | | Sec. Sys Runtime Heap | | + * | | Secondary core Stack | | + * +--------------------+-------------------------+-----------------------------+ */ /* HP SRAM */ From b540a30ce073f7e1c486d1e01d24bd47b2937358 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Wed, 21 Jul 2021 18:18:11 +0800 Subject: [PATCH 07/13] memory: cavs: calculate the runtime heap at run time Implementation of calculating the runtime heap size at run time, which leverage the value of the _runtime_heap_size from platform linker script at linking stage. This will help to make full use of the HP SRAM banks for each cAVS platforms, all of them available in .bss section will be used for runtime heap allocation. Signed-off-by: Keyon Jie --- src/platform/intel/cavs/lib/memory.c | 67 +++++++++++++++++----------- 1 file changed, 40 insertions(+), 27 deletions(-) diff --git a/src/platform/intel/cavs/lib/memory.c b/src/platform/intel/cavs/lib/memory.c index b372f27af72d..4c9da63ba878 100644 --- a/src/platform/intel/cavs/lib/memory.c +++ b/src/platform/intel/cavs/lib/memory.c @@ -74,40 +74,40 @@ static SHARED_DATA struct block_map sys_rt_heap_map[CONFIG_CORE_COUNT][3] = { }; /* Heap blocks for modules */ -static SHARED_DATA struct block_hdr mod_block64[HEAP_RT_COUNT64]; -static SHARED_DATA struct block_hdr mod_block128[HEAP_RT_COUNT128]; -static SHARED_DATA struct block_hdr mod_block256[HEAP_RT_COUNT256]; -static SHARED_DATA struct block_hdr mod_block512[HEAP_RT_COUNT512]; -static SHARED_DATA struct block_hdr mod_block1024[HEAP_RT_COUNT1024]; -static SHARED_DATA struct block_hdr mod_block2048[HEAP_RT_COUNT2048]; -static SHARED_DATA struct block_hdr mod_block4096[HEAP_RT_COUNT4096]; +static SHARED_DATA struct block_hdr mod_block64[HEAP_COUNT64 * RT_COUNT_MAX]; +static SHARED_DATA struct block_hdr mod_block128[HEAP_COUNT128 * RT_COUNT_MAX]; +static SHARED_DATA struct block_hdr mod_block256[HEAP_COUNT256 * RT_COUNT_MAX]; +static SHARED_DATA struct block_hdr mod_block512[HEAP_COUNT512 * RT_COUNT_MAX]; +static SHARED_DATA struct block_hdr mod_block1024[HEAP_COUNT1024 * RT_COUNT_MAX]; +static SHARED_DATA struct block_hdr mod_block2048[HEAP_COUNT2048 * RT_COUNT_MAX]; +static SHARED_DATA struct block_hdr mod_block4096[HEAP_COUNT4096 * RT_COUNT_MAX]; /* Heap memory map for modules */ static SHARED_DATA struct block_map rt_heap_map[] = { - BLOCK_DEF(64, HEAP_RT_COUNT64, uncached_block_hdr(mod_block64)), - BLOCK_DEF(128, HEAP_RT_COUNT128, uncached_block_hdr(mod_block128)), - BLOCK_DEF(256, HEAP_RT_COUNT256, uncached_block_hdr(mod_block256)), - BLOCK_DEF(512, HEAP_RT_COUNT512, uncached_block_hdr(mod_block512)), - BLOCK_DEF(1024, HEAP_RT_COUNT1024, uncached_block_hdr(mod_block1024)), - BLOCK_DEF(2048, HEAP_RT_COUNT2048, uncached_block_hdr(mod_block2048)), - BLOCK_DEF(4096, HEAP_RT_COUNT4096, uncached_block_hdr(mod_block4096)), + BLOCK_DEF(64, HEAP_COUNT64, uncached_block_hdr(mod_block64)), + BLOCK_DEF(128, HEAP_COUNT128, uncached_block_hdr(mod_block128)), + BLOCK_DEF(256, HEAP_COUNT256, uncached_block_hdr(mod_block256)), + BLOCK_DEF(512, HEAP_COUNT512, uncached_block_hdr(mod_block512)), + BLOCK_DEF(1024, HEAP_COUNT1024, uncached_block_hdr(mod_block1024)), + BLOCK_DEF(2048, HEAP_COUNT2048, uncached_block_hdr(mod_block2048)), + BLOCK_DEF(4096, HEAP_COUNT4096, uncached_block_hdr(mod_block4096)), }; #if CONFIG_CORE_COUNT > 1 /* Heap blocks for runtime shared */ -static SHARED_DATA struct block_hdr rt_shared_block64[HEAP_RUNTIME_SHARED_COUNT64]; -static SHARED_DATA struct block_hdr rt_shared_block128[HEAP_RUNTIME_SHARED_COUNT128]; -static SHARED_DATA struct block_hdr rt_shared_block256[HEAP_RUNTIME_SHARED_COUNT256]; -static SHARED_DATA struct block_hdr rt_shared_block512[HEAP_RUNTIME_SHARED_COUNT512]; -static SHARED_DATA struct block_hdr rt_shared_block1024[HEAP_RUNTIME_SHARED_COUNT1024]; +static SHARED_DATA struct block_hdr rt_shared_block64[HEAP_COUNT64 * RT_SHARED_COUNT]; +static SHARED_DATA struct block_hdr rt_shared_block128[HEAP_COUNT128 * RT_SHARED_COUNT]; +static SHARED_DATA struct block_hdr rt_shared_block256[HEAP_COUNT256 * RT_SHARED_COUNT]; +static SHARED_DATA struct block_hdr rt_shared_block512[HEAP_COUNT512 * RT_SHARED_COUNT]; +static SHARED_DATA struct block_hdr rt_shared_block1024[HEAP_COUNT1024 * RT_SHARED_COUNT]; /* Heap memory map for runtime shared */ static SHARED_DATA struct block_map rt_shared_heap_map[] = { - BLOCK_DEF(64, HEAP_RUNTIME_SHARED_COUNT64, uncached_block_hdr(rt_shared_block64)), - BLOCK_DEF(128, HEAP_RUNTIME_SHARED_COUNT128, uncached_block_hdr(rt_shared_block128)), - BLOCK_DEF(256, HEAP_RUNTIME_SHARED_COUNT256, uncached_block_hdr(rt_shared_block256)), - BLOCK_DEF(512, HEAP_RUNTIME_SHARED_COUNT512, uncached_block_hdr(rt_shared_block512)), - BLOCK_DEF(1024, HEAP_RUNTIME_SHARED_COUNT1024, uncached_block_hdr(rt_shared_block1024)), + BLOCK_DEF(64, HEAP_COUNT64 * RT_SHARED_COUNT, uncached_block_hdr(rt_shared_block64)), + BLOCK_DEF(128, HEAP_COUNT128 * RT_SHARED_COUNT, uncached_block_hdr(rt_shared_block128)), + BLOCK_DEF(256, HEAP_COUNT256 * RT_SHARED_COUNT, uncached_block_hdr(rt_shared_block256)), + BLOCK_DEF(512, HEAP_COUNT512 * RT_SHARED_COUNT, uncached_block_hdr(rt_shared_block512)), + BLOCK_DEF(1024, HEAP_COUNT1024 * RT_SHARED_COUNT, uncached_block_hdr(rt_shared_block1024)), }; #endif @@ -130,6 +130,8 @@ static SHARED_DATA struct mm memmap; void platform_init_memmap(struct sof *sof) { + uint32_t heap_runtime_size = SOF_FW_END - (uint32_t)&_module_heap; + uint32_t rt_count; int i; /* access memory map through uncached region */ @@ -155,6 +157,17 @@ void platform_init_memmap(struct sof *sof) SOF_MEM_CAPS_EXT | SOF_MEM_CAPS_CACHE | SOF_MEM_CAPS_DMA; + /* calculate the runtime heap size */ + rt_count = heap_runtime_size / HEAP_RUNTIME_UNIT_SIZE; + heap_runtime_size = rt_count * HEAP_RUNTIME_UNIT_SIZE; + + for (i = 0; i < ARRAY_SIZE(rt_heap_map); i++) { + rt_heap_map[i].count *= rt_count; + rt_heap_map[i].free_count *= rt_count; + } + dcache_writeback_region(rt_heap_map, + sizeof(struct block_map) * ARRAY_SIZE(rt_heap_map)); + /* .system and .system_runtime secondary core initialization */ for (i = 1; i < CONFIG_CORE_COUNT; i++) { /* .system init */ @@ -207,8 +220,8 @@ void platform_init_memmap(struct sof *sof) sof->memory_map->runtime[0].blocks = ARRAY_SIZE(rt_heap_map); sof->memory_map->runtime[0].map = uncached_block_map(rt_heap_map); sof->memory_map->runtime[0].heap = (uintptr_t)&_module_heap; - sof->memory_map->runtime[0].size = HEAP_RUNTIME_SIZE; - sof->memory_map->runtime[0].info.free = HEAP_RUNTIME_SIZE; + sof->memory_map->runtime[0].size = heap_runtime_size; + sof->memory_map->runtime[0].info.free = heap_runtime_size; sof->memory_map->runtime[0].caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_EXT | SOF_MEM_CAPS_CACHE; @@ -232,7 +245,7 @@ void platform_init_memmap(struct sof *sof) /* .total init */ sof->memory_map->total.free = HEAP_SYSTEM_T_SIZE + - HEAP_SYS_RUNTIME_T_SIZE + HEAP_RUNTIME_SIZE + HEAP_BUFFER_SIZE + + HEAP_SYS_RUNTIME_T_SIZE + heap_runtime_size + HEAP_BUFFER_SIZE + HEAP_LP_BUFFER_SIZE; } From b5940f38600459d9c162ad5110dcdad6a21ef856 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Fri, 2 Jul 2021 17:29:45 +0800 Subject: [PATCH 08/13] memory: tigerlake: make more full use of the SRAM Define more runtime and runtime shared section counts to make full use of the tigerlake platform. Signed-off-by: Keyon Jie --- .../tigerlake/include/platform/lib/memory.h | 41 +++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/src/platform/tigerlake/include/platform/lib/memory.h b/src/platform/tigerlake/include/platform/lib/memory.h index abdb18df8114..d9b783fb6358 100644 --- a/src/platform/tigerlake/include/platform/lib/memory.h +++ b/src/platform/tigerlake/include/platform/lib/memory.h @@ -249,14 +249,31 @@ #define HEAP_SYS_RT_X_COUNT512 8 #define HEAP_SYS_RT_X_COUNT1024 4 +/* Heap section counts base */ +#define HEAP_COUNT64 128 +#define HEAP_COUNT128 128 +#define HEAP_COUNT256 96 +#define HEAP_COUNT512 8 +#define HEAP_COUNT1024 4 +#define HEAP_COUNT2048 2 +#define HEAP_COUNT4096 1 + +#if HP_SRAM_SIZE < 0x200000 +#define RT_TIMES 3 +#define RT_SHARED_TIMES 6 +#else +#define RT_TIMES 8 +#define RT_SHARED_TIMES 16 +#endif + /* 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_COUNT2048 1 -#define HEAP_RT_COUNT4096 1 +#define HEAP_RT_COUNT64 (HEAP_COUNT64 * RT_TIMES) +#define HEAP_RT_COUNT128 (HEAP_COUNT128 * RT_TIMES) +#define HEAP_RT_COUNT256 (HEAP_COUNT256 * RT_TIMES) +#define HEAP_RT_COUNT512 (HEAP_COUNT512 * RT_TIMES) +#define HEAP_RT_COUNT1024 (HEAP_COUNT1024 * RT_TIMES) +#define HEAP_RT_COUNT2048 (HEAP_COUNT2048 * RT_TIMES) +#define HEAP_RT_COUNT4096 (HEAP_COUNT4096 * RT_TIMES) /* Heap configuration */ #define HEAP_RUNTIME_SIZE \ @@ -266,11 +283,11 @@ HEAP_RT_COUNT4096 * 4096) /* Heap section sizes for runtime shared heap */ -#define HEAP_RUNTIME_SHARED_COUNT64 (64 + 32 * CONFIG_CORE_COUNT) -#define HEAP_RUNTIME_SHARED_COUNT128 64 -#define HEAP_RUNTIME_SHARED_COUNT256 4 -#define HEAP_RUNTIME_SHARED_COUNT512 16 -#define HEAP_RUNTIME_SHARED_COUNT1024 (4 + CONFIG_CORE_COUNT) +#define HEAP_RUNTIME_SHARED_COUNT64 (HEAP_COUNT64 * RT_SHARED_TIMES) +#define HEAP_RUNTIME_SHARED_COUNT128 (HEAP_COUNT128 * RT_SHARED_TIMES) +#define HEAP_RUNTIME_SHARED_COUNT256 (HEAP_COUNT256 * RT_SHARED_TIMES) +#define HEAP_RUNTIME_SHARED_COUNT512 (HEAP_COUNT512 * RT_SHARED_TIMES) +#define HEAP_RUNTIME_SHARED_COUNT1024 (HEAP_COUNT1024 * RT_SHARED_TIMES) #define HEAP_RUNTIME_SHARED_SIZE \ (HEAP_RUNTIME_SHARED_COUNT64 * 64 + HEAP_RUNTIME_SHARED_COUNT128 * 128 + \ From afb5d6ebd9e6f1334e696e545fa6d73918f0d30f Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Wed, 21 Jul 2021 18:24:40 +0800 Subject: [PATCH 09/13] tigerlake: make full use of HP SRAM banks Implementation of calculating the runtime heap size at run time for Intel Tigerlake platforms. Signed-off-by: Keyon Jie --- .../tigerlake/include/platform/lib/memory.h | 55 ++++++------------- src/platform/tigerlake/tigerlake.x.in | 18 +++--- 2 files changed, 29 insertions(+), 44 deletions(-) diff --git a/src/platform/tigerlake/include/platform/lib/memory.h b/src/platform/tigerlake/include/platform/lib/memory.h index d9b783fb6358..9f5aa8ad6f73 100644 --- a/src/platform/tigerlake/include/platform/lib/memory.h +++ b/src/platform/tigerlake/include/platform/lib/memory.h @@ -158,8 +158,6 @@ * | | data | | * | | BSS | | * +--------------------+-------------------------+-----------------------------+ - * | | Runtime Heap | HEAP_RUNTIME_SIZE | - * +--------------------+-------------------------+-----------------------------+ * | | Runtime shared Heap | HEAP_RUNTIME_SHARED_SIZE | * | |-------------------------+-----------------------------+ * | | System shared Heap | HEAP_SYSTEM_SHARED_SIZE | @@ -176,6 +174,8 @@ * | | Sec. Sys Runtime Heap | | * | | Secondary core Stack | | * +--------------------+-------------------------+-----------------------------+ + * | | Runtime Heap | HEAP_RUNTIME_SIZE | + * +--------------------+-------------------------+-----------------------------+ */ /* HP SRAM */ @@ -236,6 +236,8 @@ /* max size for all var-size sections (text/rodata/bss) */ #define SOF_FW_MAX_SIZE (HP_SRAM_BASE + HP_SRAM_SIZE - SOF_FW_BASE) +#define SOF_FW_END (HP_SRAM_BASE + HP_SRAM_SIZE) + #define SOF_TEXT_START (SOF_FW_START) #define SOF_TEXT_BASE (SOF_FW_START) @@ -249,7 +251,7 @@ #define HEAP_SYS_RT_X_COUNT512 8 #define HEAP_SYS_RT_X_COUNT1024 4 -/* Heap section counts base */ +/* Heap section counts base, 64KB in total */ #define HEAP_COUNT64 128 #define HEAP_COUNT128 128 #define HEAP_COUNT256 96 @@ -258,41 +260,20 @@ #define HEAP_COUNT2048 2 #define HEAP_COUNT4096 1 -#if HP_SRAM_SIZE < 0x200000 -#define RT_TIMES 3 -#define RT_SHARED_TIMES 6 -#else -#define RT_TIMES 8 -#define RT_SHARED_TIMES 16 -#endif +#define HEAP_RUNTIME_UNIT_SIZE \ + (HEAP_COUNT64 * 64 + HEAP_COUNT128 * 128 + \ + HEAP_COUNT256 * 256 + HEAP_COUNT512 * 512 + \ + HEAP_COUNT1024 * 1024 + HEAP_COUNT2048 * 2048 + \ + HEAP_COUNT4096 * 4096) -/* Heap section sizes for module pool */ -#define HEAP_RT_COUNT64 (HEAP_COUNT64 * RT_TIMES) -#define HEAP_RT_COUNT128 (HEAP_COUNT128 * RT_TIMES) -#define HEAP_RT_COUNT256 (HEAP_COUNT256 * RT_TIMES) -#define HEAP_RT_COUNT512 (HEAP_COUNT512 * RT_TIMES) -#define HEAP_RT_COUNT1024 (HEAP_COUNT1024 * RT_TIMES) -#define HEAP_RT_COUNT2048 (HEAP_COUNT2048 * RT_TIMES) -#define HEAP_RT_COUNT4096 (HEAP_COUNT4096 * RT_TIMES) - -/* Heap configuration */ -#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_COUNT2048 * 2048 + \ - HEAP_RT_COUNT4096 * 4096) - -/* Heap section sizes for runtime shared heap */ -#define HEAP_RUNTIME_SHARED_COUNT64 (HEAP_COUNT64 * RT_SHARED_TIMES) -#define HEAP_RUNTIME_SHARED_COUNT128 (HEAP_COUNT128 * RT_SHARED_TIMES) -#define HEAP_RUNTIME_SHARED_COUNT256 (HEAP_COUNT256 * RT_SHARED_TIMES) -#define HEAP_RUNTIME_SHARED_COUNT512 (HEAP_COUNT512 * RT_SHARED_TIMES) -#define HEAP_RUNTIME_SHARED_COUNT1024 (HEAP_COUNT1024 * RT_SHARED_TIMES) - -#define HEAP_RUNTIME_SHARED_SIZE \ - (HEAP_RUNTIME_SHARED_COUNT64 * 64 + HEAP_RUNTIME_SHARED_COUNT128 * 128 + \ - HEAP_RUNTIME_SHARED_COUNT256 * 256 + HEAP_RUNTIME_SHARED_COUNT512 * 512 + \ - HEAP_RUNTIME_SHARED_COUNT1024 * 1024) +/* maximum all SRAM banks used as runtime heap */ +#define RT_COUNT_MAX (HP_SRAM_SIZE / HEAP_RUNTIME_UNIT_SIZE) + +#if CONFIG_CORE_COUNT > 1 +/* n times blocks for runtime_shared heap, increase me if needed */ +#define RT_SHARED_COUNT (HP_SRAM_SIZE < 0x200000 ? 2 : 4) /* use less for e.g. TGL-H */ +#define HEAP_RUNTIME_SHARED_SIZE (HEAP_RUNTIME_UNIT_SIZE * RT_SHARED_COUNT) +#endif /* Heap section sizes for system shared heap */ #define HEAP_SYSTEM_SHARED_SIZE 0x1500 diff --git a/src/platform/tigerlake/tigerlake.x.in b/src/platform/tigerlake/tigerlake.x.in index 0317b5d51132..a5ecd78779e8 100644 --- a/src/platform/tigerlake/tigerlake.x.in +++ b/src/platform/tigerlake/tigerlake.x.in @@ -529,11 +529,6 @@ SECTIONS *(.gnu.linkonce.b.*) *(COMMON) - . = ALIGN (SRAM_BANK_SIZE); - _runtime_heap_start = ABSOLUTE(.); - . = . + HEAP_RUNTIME_SIZE; - _runtime_heap_end = ABSOLUTE(.); - . = ALIGN (HEAP_BUF_ALIGNMENT); _buffer_heap_start = ABSOLUTE(.); . = . + HEAP_BUFFER_SIZE; @@ -549,6 +544,7 @@ SECTIONS . = . + HEAP_SYS_RUNTIME_M_SIZE; _system_runtime_heap_end = ABSOLUTE(.); +#if CONFIG_CORE_COUNT > 1 . = ALIGN (PLATFORM_DCACHE_ALIGN); _runtime_shared_heap_start = ABSOLUTE(.); . = . + HEAP_RUNTIME_SHARED_SIZE; @@ -560,16 +556,23 @@ SECTIONS . = . + HEAP_SYSTEM_SHARED_SIZE; . = ALIGN (PLATFORM_DCACHE_ALIGN); _system_shared_heap_end = ABSOLUTE(.); - +#endif . = ALIGN (4096); _sof_stack_start = ABSOLUTE(.); . = . + SOF_STACK_SIZE; _sof_stack_end = ABSOLUTE(.); +#if CONFIG_CORE_COUNT > 1 . = ALIGN (SRAM_BANK_SIZE); _sof_core_s_start = ABSOLUTE(.); . = . + SOF_CORE_S_T_SIZE; _sof_core_s_end = ABSOLUTE(.); +#endif + . = ALIGN (SRAM_BANK_SIZE); + _runtime_heap_start = ABSOLUTE(.); + /* make full use of the SRAM */ + . = . + SOF_FW_END - _runtime_heap_start; + _runtime_heap_end = ABSOLUTE(.); _bss_end = ABSOLUTE(.); } >sof_fw :sof_fw_phdr @@ -589,10 +592,11 @@ SECTIONS /* system runtime heap */ _system_runtime_heap = _system_runtime_heap_start; +#if CONFIG_CORE_COUNT > 1 /* Shared Heap */ _runtime_shared_heap = _runtime_shared_heap_start; _system_shared_heap = _system_shared_heap_start; - +#endif /* module heap */ _module_heap = _runtime_heap_start; From 1b40ffe5e02c56dc0df734e3e22c9231bd5d860a Mon Sep 17 00:00:00 2001 From: Slawomir Blauciak Date: Fri, 28 May 2021 12:44:03 +0200 Subject: [PATCH 10/13] update klocwork submodule Commit: 5aeb95b19bba15801fef4ee37760a6e776d3bd1a Signed-off-by: Slawomir Blauciak --- rimage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rimage b/rimage index 6f45b619210b..5aeb95b19bba 160000 --- a/rimage +++ b/rimage @@ -1 +1 @@ -Subproject commit 6f45b619210b2dc1fc84baa521e2d01a6b7a485a +Subproject commit 5aeb95b19bba15801fef4ee37760a6e776d3bd1a From d8ac44e7dc64fa4e697fb89731c1b9e23b229fc7 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Fri, 2 Jul 2021 23:41:34 +0800 Subject: [PATCH 11/13] rimage: update rimage submodule to support cAVS SRAM size correction 9a26e4558094 config: apl: change image_size to the real SRAM size 8a2ea0044dcf config: cnl: change image_size to the real SRAM size 1de9ccca3388 config: jsl: change image_size to the real SRAM size f52a078aadf1 config: icl: change image_size to the real SRAM size 8073ea3ef93c config: tgl-h: change image_size to the real SRAM size 9e50a02f1b0d config: tgl: change image_size to the real SRAM size Signed-off-by: Keyon Jie --- rimage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rimage b/rimage index 5aeb95b19bba..9a26e4558094 160000 --- a/rimage +++ b/rimage @@ -1 +1 @@ -Subproject commit 5aeb95b19bba15801fef4ee37760a6e776d3bd1a +Subproject commit 9a26e4558094f19f3f7becd89eb9e8a9a9dd82b9 From 11d555bd8ed34db420b3e2041c89e028a85dda5a Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Thu, 22 Jul 2021 21:46:00 +0800 Subject: [PATCH 12/13] rimage: update rimage for more cavs platforms 246ea6469abd config: skl: change image_size to the real SRAM size 9c9e07c6507d config: kbl: change image_size to the real SRAM size 44b37d19a24c config: sue: change image_size to the real SRAM size 580e4d674e06 config: tgl-cavs: change image_size to the real SRAM size Signed-off-by: Keyon Jie --- rimage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rimage b/rimage index 9a26e4558094..246ea6469abd 160000 --- a/rimage +++ b/rimage @@ -1 +1 @@ -Subproject commit 9a26e4558094f19f3f7becd89eb9e8a9a9dd82b9 +Subproject commit 246ea6469abdc677b7038285654fd64fc387c5f1 From 569a49ad5220ef2345c829264858faa5186ab813 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Fri, 30 Jul 2021 16:38:00 +0800 Subject: [PATCH 13/13] memory: tigerlake: use bigger buffer zone on TGL-U/LP On platforms where we have plenty of SRAM banks, we can use a bigger buffer zone to make running pipelines which ask for bigger periods/buffers. Signed-off-by: Keyon Jie --- src/platform/tigerlake/include/platform/lib/memory.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/platform/tigerlake/include/platform/lib/memory.h b/src/platform/tigerlake/include/platform/lib/memory.h index 9f5aa8ad6f73..91c3bf58e976 100644 --- a/src/platform/tigerlake/include/platform/lib/memory.h +++ b/src/platform/tigerlake/include/platform/lib/memory.h @@ -278,7 +278,8 @@ /* Heap section sizes for system shared heap */ #define HEAP_SYSTEM_SHARED_SIZE 0x1500 -#define HEAP_BUFFER_SIZE 0x80000 +/* use more buffer zone on TGL-U/LP */ +#define HEAP_BUFFER_SIZE (HP_SRAM_SIZE < 0x200000 ? 0x80000 : 0x100000) #define HEAP_BUFFER_BLOCK_SIZE 0x100 #define HEAP_BUFFER_COUNT (HEAP_BUFFER_SIZE / HEAP_BUFFER_BLOCK_SIZE)