Skip to content

Commit

Permalink
lib-manager: isolate instance-count handling for system-services
Browse files Browse the repository at this point in the history
.bss splitting is specific to system-service module loading, other
use-cases use a traditional shared .bss ELF section.

Signed-off-by: Guennadi Liakhovetski <[email protected]>
  • Loading branch information
lyakh committed Jan 19, 2024
1 parent a226676 commit ec1864f
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/library_manager/lib_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ static void __sparse_cache *lib_manager_get_instance_bss_address(uint32_t module
uint32_t instance_id,
struct sof_man_module *mod)
{
if (mod->type.load_type == SOF_MAN_MOD_TYPE_LLEXT)
return (void __sparse_cache *)mod->segment[SOF_MAN_SEGMENT_BSS].v_base_addr;

uint32_t instance_bss_size =
mod->segment[SOF_MAN_SEGMENT_BSS].flags.r.length / mod->instance_max_count;
uint32_t inst_offset = instance_bss_size * PAGE_SZ * instance_id;
Expand All @@ -250,11 +253,15 @@ static void __sparse_cache *lib_manager_get_instance_bss_address(uint32_t module
static int lib_manager_allocate_module_instance(uint32_t module_id, uint32_t instance_id,
uint32_t is_pages, struct sof_man_module *mod)
{
size_t bss_size =
(mod->segment[SOF_MAN_SEGMENT_BSS].flags.r.length / mod->instance_max_count)
* PAGE_SZ;
void __sparse_cache *va_base = lib_manager_get_instance_bss_address(module_id,
instance_id, mod);
size_t bss_size;

if (mod->type.load_type == SOF_MAN_MOD_TYPE_LLEXT)
bss_size = mod->segment[SOF_MAN_SEGMENT_BSS].flags.r.length * PAGE_SZ;
else
bss_size = (mod->segment[SOF_MAN_SEGMENT_BSS].flags.r.length /
mod->instance_max_count) * PAGE_SZ;

if ((is_pages * PAGE_SZ) > bss_size) {
tr_err(&lib_manager_tr,
Expand All @@ -275,12 +282,16 @@ static int lib_manager_allocate_module_instance(uint32_t module_id, uint32_t ins
static int lib_manager_free_module_instance(uint32_t module_id, uint32_t instance_id,
struct sof_man_module *mod)
{
size_t bss_size =
(mod->segment[SOF_MAN_SEGMENT_BSS].flags.r.length / mod->instance_max_count)
* PAGE_SZ;
size_t bss_size;
void __sparse_cache *va_base = lib_manager_get_instance_bss_address(module_id,
instance_id, mod);

if (mod->type.load_type == SOF_MAN_MOD_TYPE_LLEXT)
bss_size = mod->segment[SOF_MAN_SEGMENT_BSS].flags.r.length * PAGE_SZ;
else
bss_size = (mod->segment[SOF_MAN_SEGMENT_BSS].flags.r.length /
mod->instance_max_count) * PAGE_SZ;

/* Unmap bss memory. */
return lib_manager_align_unmap(va_base, bss_size);
}
Expand Down

0 comments on commit ec1864f

Please sign in to comment.