From 16b6dae7acbd4c4888781cc647df8bfb936edbd3 Mon Sep 17 00:00:00 2001 From: Paul Olaru Date: Thu, 20 Jun 2019 14:54:17 +0300 Subject: [PATCH 1/3] memory: Add HEAP_BUF_ALIGNMENT define for i.MX8 platform This value will determine the alignment for heap buffers Signed-off-by: Paul Olaru --- src/platform/imx8/include/platform/memory.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/platform/imx8/include/platform/memory.h b/src/platform/imx8/include/platform/memory.h index 4edab8d966bf..b3854a1f88ff 100644 --- a/src/platform/imx8/include/platform/memory.h +++ b/src/platform/imx8/include/platform/memory.h @@ -161,6 +161,8 @@ #define cache_to_uncache(address) address #define is_uncached(address) 0 +#define HEAP_BUF_ALIGNMENT XCHAL_DCACHE_LINESIZE + #if !defined(__ASSEMBLER__) && !defined(LINKER) void platform_init_memmap(void); #endif From f0d8fe7c438079b601a7324eb7cebd33bba23ba3 Mon Sep 17 00:00:00 2001 From: Paul Olaru Date: Thu, 20 Jun 2019 14:55:43 +0300 Subject: [PATCH 2/3] memory: Add static assert for heap_buf_alignment value This will check if heap buffers alignment is valid Signed-off-by: Paul Olaru --- src/platform/imx8/memory.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/platform/imx8/memory.c b/src/platform/imx8/memory.c index 17ed4fd547e3..34f9c2c19983 100644 --- a/src/platform/imx8/memory.c +++ b/src/platform/imx8/memory.c @@ -7,6 +7,9 @@ #include #include +STATIC_ASSERT(0 == (HEAP_BUF_ALIGNMENT % PLATFORM_DCACHE_ALIGN), + invalid_heap_buf_alignment); + /* Heap blocks for system runtime */ static struct block_hdr sys_rt_block64[HEAP_SYS_RT_COUNT64]; static struct block_hdr sys_rt_block512[HEAP_SYS_RT_COUNT512]; From d8377f046c6fe394a834863ac3a2ca1f94d87219 Mon Sep 17 00:00:00 2001 From: Paul Olaru Date: Thu, 20 Jun 2019 14:56:22 +0300 Subject: [PATCH 3/3] memory: Make buffers aligned to HEAP_BUF_ALIGNMENT in i.MX8 It provides better memory/cache performance since it aligns with cache line size Signed-off-by: Paul Olaru --- src/platform/imx8/imx8.x.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platform/imx8/imx8.x.in b/src/platform/imx8/imx8.x.in index b2ce62a28999..916d41ccec3b 100644 --- a/src/platform/imx8/imx8.x.in +++ b/src/platform/imx8/imx8.x.in @@ -461,7 +461,7 @@ SECTIONS .system_runtime_heap (NOLOAD) : ALIGN(8) { - . = ALIGN (32); + . = ALIGN (HEAP_BUF_ALIGNMENT); _system_runtime_heap_start = ABSOLUTE(.); . = . + HEAP_SYS_RUNTIME_SIZE; _system_runtime_heap_end = ABSOLUTE(.); @@ -477,7 +477,7 @@ SECTIONS .buffer_heap (NOLOAD) : ALIGN(8) { - . = ALIGN (32); + . = ALIGN (HEAP_BUF_ALIGNMENT); _buffer_heap_start = ABSOLUTE(.); . = . + HEAP_BUFFER_SIZE; _buffer_heap_end = ABSOLUTE(.);