Skip to content

Commit

Permalink
build: make cold data and code support universal
Browse files Browse the repository at this point in the history
This extends LLEXT cold data and code support to the entire SOF code
base. Using the same __cold and __cold_rodata qualifies any code or
data can be marked to be used directly in DRAM without being copied
to SRAM.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
  • Loading branch information
lyakh committed Dec 20, 2024
1 parent c910127 commit 8c16eb2
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 10 deletions.
8 changes: 4 additions & 4 deletions scripts/llext_link_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ def main():
# run at arbitrary memory locations. One of the use-cases is running
# parts of the module directly in DRAM - sacrificing performance but
# saving scarce SRAM. We achieve this by placing non-performance
# critical functions in a .text.dram ELF section. When compiling and
# linking such functions, an additional .literal.dram section is
# automatically created. Note, that for some reason the compiler also
# marks that section as executable.
# critical functions in a .cold ELF section. When compiling and linking
# such functions, an additional .cold.literal section is automatically
# created. Note, that for some reason the compiler also marks that
# section as executable.
# This script links those sections at address 0. We could hard-code
# section names, but so far we choose to only link .text the "original"
# way and all other executable sections we link at 0.
Expand Down
6 changes: 0 additions & 6 deletions src/include/module/module/llext.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,4 @@ static const struct sof_module_api_build_info buildinfo __section(".mod_buildinf
.api_version_number.full = SOF_MODULE_API_CURRENT_VERSION, \
}

#if CONFIG_LLEXT_TYPE_ELF_RELOCATABLE && defined(LL_EXTENSION_BUILD)
#define __cold __section(".text.dram")
#else
#define __cold
#endif

#endif
6 changes: 6 additions & 0 deletions src/platform/ace30/include/platform/lib/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
*/
#define HEAPMEM_SIZE 0xD0000

#if CONFIG_COLD_STORE_EXECUTE_DRAM && \
(CONFIG_LLEXT_TYPE_ELF_RELOCATABLE || !defined(LL_EXTENSION_BUILD))
#define __cold __section(".cold")
#define __cold_rodata __section(".coldrodata")
#endif

#endif /* __PLATFORM_LIB_MEMORY_H__ */

#else
Expand Down
6 changes: 6 additions & 0 deletions src/platform/lunarlake/include/platform/lib/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
*/
#define HEAPMEM_SIZE 0xF0000

#if CONFIG_COLD_STORE_EXECUTE_DRAM && \
(CONFIG_LLEXT_TYPE_ELF_RELOCATABLE || !defined(LL_EXTENSION_BUILD))
#define __cold __section(".cold")
#define __cold_rodata __section(".coldrodata")
#endif

#endif /* __PLATFORM_LIB_MEMORY_H__ */

#else
Expand Down
6 changes: 6 additions & 0 deletions src/platform/meteorlake/include/platform/lib/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
*/
#define HEAPMEM_SIZE 0xF0000

#if CONFIG_COLD_STORE_EXECUTE_DRAM && \
(CONFIG_LLEXT_TYPE_ELF_RELOCATABLE || !defined(LL_EXTENSION_BUILD))
#define __cold __section(".cold")
#define __cold_rodata __section(".coldrodata")
#endif

#endif /* __PLATFORM_LIB_MEMORY_H__ */

#else
Expand Down
8 changes: 8 additions & 0 deletions zephyr/include/sof/lib/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,12 @@

#include <platform/lib/memory.h>

#ifndef __cold
#define __cold
#endif

#ifndef __cold_rodata
#define __cold_rodata
#endif

#endif /* __SOF_LIB_MEMORY_H__ */

0 comments on commit 8c16eb2

Please sign in to comment.