From 88340c33b34a8d7b864221a6d3f2d53926fe2c84 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Thu, 2 Sep 2021 10:47:32 +0800 Subject: [PATCH 1/3] buffer: remove the unneeded size check The allocator will return failure if the request size is too big, remove the unsuitable check here. Signed-off-by: Keyon Jie --- src/audio/buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/buffer.c b/src/audio/buffer.c index 5cb439c181be..7555469cedf2 100644 --- a/src/audio/buffer.c +++ b/src/audio/buffer.c @@ -31,7 +31,7 @@ struct comp_buffer *buffer_alloc(uint32_t size, uint32_t caps, uint32_t align) tr_dbg(&buffer_tr, "buffer_alloc()"); /* validate request */ - if (size == 0 || size > HEAP_BUFFER_SIZE) { + if (size == 0) { tr_err(&buffer_tr, "buffer_alloc(): new size = %u is invalid", size); return NULL; @@ -85,7 +85,7 @@ int buffer_set_size(struct comp_buffer *buffer, uint32_t size) void *new_ptr = NULL; /* validate request */ - if (size == 0 || size > HEAP_BUFFER_SIZE) { + if (size == 0) { buf_err(buffer, "resize size = %u is invalid", size); return -EINVAL; } From cc7dc16b0a1645e9861686b7b97c6658895fed60 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Thu, 22 Jul 2021 21:46:00 +0800 Subject: [PATCH 2/3] 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 e3414b9c27264956484368ee7992fc30937d65e1 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Thu, 26 Aug 2021 19:10:37 +0800 Subject: [PATCH 3/3] zephyr: wrapper: hardcode SIZEs to unblock building We have change the size of runtime_shared zone to be decided at link stage, here hardcode HEAP_RUNTIME_SHARED_SIZE to unblock the Zephyr building. Signed-off-by: Keyon Jie --- zephyr/wrapper.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/zephyr/wrapper.c b/zephyr/wrapper.c index e99ee5c8a716..1bbe36fd025a 100644 --- a/zephyr/wrapper.c +++ b/zephyr/wrapper.c @@ -72,18 +72,38 @@ __section(".heap_mem") static uint8_t __aligned(64) heapmem[HEAPMEM_SIZE]; #else -#define HEAPMEM_SHARED_SIZE (HEAP_SYSTEM_SIZE + HEAP_RUNTIME_SIZE + \ - HEAP_RUNTIME_SHARED_SIZE + HEAP_SYSTEM_SHARED_SIZE) +/* + * TODO: heap size should be set based on Zephyr linker output. + * At the moment, the HEAP_SIZEs are approximations from the XTOS linker scripts + * (e.g. src/platform/apollolake/apollolake.x.in for APL): + * (_bss_end - _runtime_heap_start) + */ +#if (CONFIG_HP_MEMORY_BANKS < 16) +/* e.g. APL */ +#define HEAP_SIZE 0x30000 +#elif (CONFIG_HP_MEMORY_BANKS < 30) +/* e.g. JSL */ +#define HEAP_SIZE 0x80000 +#elif (CONFIG_HP_MEMORY_BANKS < 45) +/* e.g. TGL-H */ +#define HEAP_SIZE 0x100000 +#else +/* e.g. CNL/ICL/TGL */ +#define HEAP_SIZE 0x200000 +#endif + #ifdef ENABLE_CACHED_HEAP -#define HEAPMEM_SIZE HEAP_BUFFER_SIZE +/* hard code the cached portion at the moment */ +#define HEAP_SYSTEM_CACHED_SIZE (HEAP_SIZE / 2) #else -#define HEAPMEM_SIZE (HEAP_BUFFER_SIZE + HEAPMEM_SHARED_SIZE) +#define HEAP_SYSTEM_CACHED_SIZE 0 #endif +#define HEAPMEM_SIZE (HEAP_SIZE - HEAP_SYSTEM_CACHED_SIZE) static uint8_t __aligned(PLATFORM_DCACHE_ALIGN)heapmem[HEAPMEM_SIZE]; #ifdef ENABLE_CACHED_HEAP -static uint8_t __aligned(PLATFORM_DCACHE_ALIGN)heapmem_shared[HEAPMEM_SHARED_SIZE]; -static struct k_heap sof_heap_shared; +static uint8_t __aligned(PLATFORM_DCACHE_ALIGN)heapmem_cached[HEAP_SYSTEM_CACHED_SIZE]; +static struct k_heap sof_heap_cached; #endif #endif @@ -96,7 +116,7 @@ static int statics_init(const struct device *unused) sys_heap_init(&sof_heap.heap, heapmem, HEAPMEM_SIZE); #ifdef ENABLE_CACHED_HEAP - sys_heap_init(&sof_heap_shared.heap, heapmem_shared, HEAPMEM_SHARED_SIZE); + sys_heap_init(&sof_heap_cached.heap, heapmem_cached, HEAP_SYSTEM_CACHED_SIZE); #endif return 0; }