Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency: add support for loading auxiliary code as LLEXT modules #9399

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
736e7a9
llext: add a convenience Kconfig option to build LLEXT modules
lyakh Jun 13, 2024
11e76b6
lnl: build all supporting code as LLEXT modules
lyakh Jul 23, 2024
afc30e4
llext: automatically calculate module addresses
lyakh May 30, 2024
859996e
llext: add missing modules to LNL overlay
lyakh Jun 13, 2024
543ee6a
src: convert to a loadable module
lyakh Jun 13, 2024
45ae3a2
volume: move gain.toml and peakvol.toml into volume.toml
lyakh May 28, 2024
877dbf3
llext: export 2 symbols, required for modular volume
lyakh May 28, 2024
4f0e94c
volume: add LLEXT support
lyakh May 28, 2024
4c2eca8
eq-fir: enable building as an llext module
lyakh Jun 3, 2024
830f9a2
llext: move logging context to base firmware
lyakh Aug 21, 2024
80abcf7
asrc: enable building as an llext module
lyakh Jun 3, 2024
75ee4a0
llext: export symbols, required for eq_fir
lyakh Jun 19, 2024
951ea73
llext: fix multi-core use cases
lyakh Jun 26, 2024
dfe4bce
tdfb: enable building as an llext module
lyakh Jul 4, 2024
1bc75fc
llext: add auxiliary library type
lyakh Jul 4, 2024
ba52d85
fir: enable building FIR support code as an LLEXT object
lyakh Jul 4, 2024
b83285d
llext: change a function parameter
lyakh Jul 16, 2024
21a5246
llext: move the llext pointer to struct lib_manager_mod_ctx
lyakh Jul 16, 2024
8d47ad3
llext: (cosmetic) remove function names from logs
lyakh Aug 23, 2024
b8c5357
llext: call llext_unload() internally
lyakh Aug 23, 2024
7381cd1
llext: add auxiliary library dependency support
lyakh Aug 23, 2024
4bc7ca5
test Zephyr PR 77473
lyakh Aug 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/boards/intel_adsp_ace15_mtpm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ CONFIG_METEORLAKE=y
CONFIG_IPC_MAJOR_4=y
CONFIG_IPC4_BASE_FW_INTEL=y

CONFIG_COMP_SRC=y
CONFIG_COMP_SRC_IPC4_FULL_MATRIX=y
CONFIG_COMP_SRC_LITE=y
CONFIG_COMP_DRC=m
Expand Down Expand Up @@ -88,6 +87,7 @@ CONFIG_MEMORY_WIN_2_SIZE=12288
CONFIG_LLEXT=y
CONFIG_LLEXT_STORAGE_WRITABLE=y
CONFIG_MODULES=y
CONFIG_LIBRARY_BASE_ADDRESS=0xa0688000

# Temporary disabled options
CONFIG_TRACE=n
Expand Down
4 changes: 2 additions & 2 deletions app/boards/intel_adsp_ace20_lnl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ CONFIG_LUNARLAKE=y
CONFIG_IPC_MAJOR_4=y
CONFIG_IPC4_BASE_FW_INTEL=y

CONFIG_COMP_SRC=y
CONFIG_COMP_SRC_IPC4_FULL_MATRIX=y
CONFIG_COMP_DRC=m

Expand Down Expand Up @@ -82,7 +81,8 @@ CONFIG_MEMORY_WIN_2_SIZE=12288
CONFIG_LLEXT=y
CONFIG_LLEXT_STORAGE_WRITABLE=y
CONFIG_MODULES=y

CONFIG_LIBRARY_DEFAULT_MODULAR=y
CONFIG_LIBRARY_BASE_ADDRESS=0xa0688000

# Temporary disabled options
CONFIG_TRACE=n
Expand Down
8 changes: 8 additions & 0 deletions app/overlays/lnl/module_overlay.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
CONFIG_LIBRARY_BASE_ADDRESS=0xa0688000
CONFIG_SAMPLE_SMART_AMP=m
CONFIG_COMP_MIXIN_MIXOUT=m
CONFIG_COMP_TDFB=m
CONFIG_COMP_FIR=m
CONFIG_COMP_IIR=m
CONFIG_COMP_DRC=m
CONFIG_COMP_SRC=m
CONFIG_COMP_ASRC=m
CONFIG_COMP_VOLUME=m
6 changes: 6 additions & 0 deletions app/overlays/mtl/module_overlay.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
CONFIG_LIBRARY_BASE_ADDRESS=0xa0688000
CONFIG_SAMPLE_SMART_AMP=m
CONFIG_COMP_MIXIN_MIXOUT=m
CONFIG_COMP_TDFB=m
CONFIG_COMP_FIR=m
CONFIG_COMP_IIR=m
CONFIG_COMP_DRC=m
CONFIG_COMP_SRC=m
CONFIG_COMP_ASRC=m
CONFIG_COMP_VOLUME=m
17 changes: 15 additions & 2 deletions scripts/llext_link_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def parse_args():
help='Object file name')
parser.add_argument("-t", "--text-addr", required=True, type=str,
help='.text section address')
parser.add_argument("-s", "--size-file", required=True, type=str,
help='File with stored accumulated size')

args = parser.parse_args()

Expand All @@ -43,11 +45,20 @@ def max_alignment(addr, align1, align2):
return upper - (upper % align1)

def main():
global args

parse_args()

elf = ELFFile(open(args.file, 'rb'))
# Get the size of the previous module, if this isn't the first one.
# It is used to automatically calculate starting address of the current
# module.
try:
with open(args.size_file, 'r') as f_size:
size = int(f_size.read().strip(), base = 0)
except OSError:
size = 0

text_addr = int(args.text_addr, 0)
text_addr = int(args.text_addr, 0) + size
text_size = 0

# File names differ when building shared or relocatable objects
Expand All @@ -65,6 +76,8 @@ def main():
writable = []
readonly = []

elf = ELFFile(open(args.file, 'rb'))

# Create an object file with sections grouped by their properties,
# similar to how program segments are created: all executable sections,
# then all read-only data sections, and eventually all writable data
Expand Down
47 changes: 47 additions & 0 deletions scripts/llext_offset_calc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause

# Add rounded new file size to accumulated module size cache

import argparse
import pathlib
import os

args = None

def parse_args():
global args

parser = argparse.ArgumentParser(description='Add a file size to a sum in a file')

parser.add_argument("-i", "--input", required=True, type=str,
help='Object file name')
parser.add_argument("-s", "--size-file", required=True, type=str,
help='File to store accumulated size')

args = parser.parse_args()

def main():
global args

parse_args()

f_output = pathlib.Path(args.size_file)

try:
with open(f_output, 'r') as f_size:
size = int(f_size.read().strip(), base = 0)
except OSError:
size = 0

# Failure will raise an exception
f_size = open(f_output, "w")

# align to a page border
size += os.path.getsize(args.input) + 0xfff
size &= ~0xfff

f_size.write(f'0x{size:x}\n')

if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion src/audio/asrc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause

add_local_sources(sof asrc.c asrc_farrow.c asrc_farrow_generic.c
asrc_farrow_hifi3.c)
asrc_farrow_hifi3.c asrc_log.c)

if(CONFIG_IPC_MAJOR_3)
add_local_sources(sof asrc_ipc3.c)
Expand Down
5 changes: 3 additions & 2 deletions src/audio/asrc/Kconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# SPDX-License-Identifier: BSD-3-Clause

config COMP_ASRC
bool "ASRC component"
tristate "ASRC component"
default m if LIBRARY_DEFAULT_MODULAR
default y
help
Select for Asynchronous sample rate conversion (ASRC)
Expand All @@ -14,7 +15,7 @@ config COMP_ASRC
not have pre-computed filter coefficients for every
conversion fraction that SRC does.

if COMP_ASRC
if COMP_ASRC != n

rsource "Kconfig.simd"

Expand Down
25 changes: 21 additions & 4 deletions src/audio/asrc/asrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <stdint.h>
#include "asrc.h"

LOG_MODULE_REGISTER(asrc, CONFIG_SOF_LOG_LEVEL);
LOG_MODULE_DECLARE(asrc, CONFIG_SOF_LOG_LEVEL);

/* In-line functions */

Expand Down Expand Up @@ -318,7 +318,7 @@ static int asrc_free(struct processing_module *mod)
struct comp_data *cd = module_get_private_data(mod);
struct comp_dev *dev = mod->dev;

comp_info(dev, "asrc_free()");
comp_dbg(dev, "asrc_free()");

rfree(cd->buf);
asrc_release_buffers(cd->asrc_obj);
Expand Down Expand Up @@ -850,8 +850,7 @@ static int asrc_reset(struct processing_module *mod)
struct comp_dev *dev = mod->dev;
struct comp_data *cd = module_get_private_data(mod);

comp_info(dev, "asrc_reset(), skew_min=%d, skew_max=%d", cd->skew_min, cd->skew_max);

comp_dbg(dev, "asrc_reset(), skew_min=%d, skew_max=%d", cd->skew_min, cd->skew_max);

/* If any resources feasible to stop */
if (cd->track_drift)
Expand Down Expand Up @@ -879,3 +878,21 @@ static const struct module_interface asrc_interface = {

DECLARE_MODULE_ADAPTER(asrc_interface, ASRC_UUID, asrc_tr);
SOF_MODULE_INIT(asrc, sys_comp_module_asrc_interface_init);

#if CONFIG_COMP_ASRC_MODULE
/* modular: llext dynamic link */

#include <module/module/api_ver.h>
#include <module/module/llext.h>
#include <rimage/sof/user/manifest.h>

#define UUID_ASRC 0x2d, 0x40, 0xb4, 0x66, 0x68, 0xb4, 0xf2, 0x42, \
0x81, 0xa7, 0xb3, 0x71, 0x21, 0x86, 0x3d, 0xd4
SOF_LLEXT_MOD_ENTRY(asrc, &asrc_interface);

static const struct sof_man_module_manifest mod_manifest[] __section(".module") __used = {
SOF_LLEXT_MODULE_MANIFEST("ASRC", asrc_llext_entry, 1, UUID_ASRC, 2),
};

SOF_LLEXT_BUILDINFO;
#endif
6 changes: 5 additions & 1 deletion src/audio/asrc/asrc.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#ifndef LOAD_TYPE
#define LOAD_TYPE "0"
#endif

[[module.entry]]
name = "ASRC"
uuid = "66B4402D-B468-42F2-81A7-B37121863DD4"
affinity_mask = "0x3"
instance_count = "2"
domain_types = "0"

load_type = "0"
load_type = LOAD_TYPE
module_type = "9"
auto_start = "0"
sched_caps = [1, 0x00008000]
Expand Down
4 changes: 0 additions & 4 deletions src/audio/asrc/asrc_ipc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
#include <errno.h>
#include "asrc.h"

SOF_DEFINE_REG_UUID(asrc);

DECLARE_TR_CTX(asrc_tr, SOF_UUID(asrc_uuid), LOG_LEVEL_INFO);

int asrc_dai_configure_timestamp(struct comp_data *cd)
{
if (cd->dai_dev)
Expand Down
4 changes: 0 additions & 4 deletions src/audio/asrc/asrc_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
#include <errno.h>
#include "asrc.h"

SOF_DEFINE_REG_UUID(asrc4);

DECLARE_TR_CTX(asrc_tr, SOF_UUID(asrc4_uuid), LOG_LEVEL_INFO);

int asrc_dai_configure_timestamp(struct comp_data *cd)
{
if (!cd->dai_dev)
Expand Down
21 changes: 21 additions & 0 deletions src/audio/asrc/asrc_log.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2024 Intel Corporation.

#include <rtos/symbol.h>
#include <sof/lib/uuid.h>
#include <sof/trace/trace.h>
#include <user/trace.h>

LOG_MODULE_REGISTER(asrc, CONFIG_SOF_LOG_LEVEL);
#if CONFIG_IPC_MAJOR_4
SOF_DEFINE_REG_UUID(asrc4);
DECLARE_TR_CTX(asrc_tr, SOF_UUID(asrc4_uuid), LOG_LEVEL_INFO);
EXPORT_SYMBOL(asrc4_uuid);
#elif CONFIG_IPC_MAJOR_3
SOF_DEFINE_REG_UUID(asrc);
DECLARE_TR_CTX(asrc_tr, SOF_UUID(asrc_uuid), LOG_LEVEL_INFO);
EXPORT_SYMBOL(asrc_uuid);
#endif
EXPORT_SYMBOL(asrc_tr);
EXPORT_SYMBOL(log_const_asrc);
10 changes: 10 additions & 0 deletions src/audio/asrc/llext/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2024 Intel Corporation.
# SPDX-License-Identifier: Apache-2.0

sof_llext_build("asrc"
SOURCES ../asrc.c
../asrc_farrow_hifi3.c
../asrc_farrow.c
../asrc_farrow_generic.c
../asrc_ipc4.c
)
6 changes: 6 additions & 0 deletions src/audio/asrc/llext/llext.toml.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <tools/rimage/config/platform.toml>
#define LOAD_TYPE "2"
#include "../asrc.toml"

[module]
count = __COUNTER__
1 change: 1 addition & 0 deletions src/audio/data_blob.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void comp_data_blob_set_validator(struct comp_data_blob_handler *blob_handler,

blob_handler->validator = validator;
}
EXPORT_SYMBOL(comp_data_blob_set_validator);

void *comp_get_data_blob(struct comp_data_blob_handler *blob_handler,
size_t *size, uint32_t *crc)
Expand Down
2 changes: 0 additions & 2 deletions src/audio/drc/llext/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Copyright (c) 2024 Intel Corporation.
# SPDX-License-Identifier: Apache-2.0

# Hard-coded .text address to be moved to a common place
sof_llext_build("drc"
SOURCES ../drc.c
../drc_generic.c
../drc_math_generic.c
../drc_hifi3.c
../drc_hifi4.c
../drc_math_hifi3.c
TEXT_ADDR 0xa068a000
)
2 changes: 1 addition & 1 deletion src/audio/eq_fir/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause

add_local_sources(sof eq_fir.c eq_fir_generic.c eq_fir_hifi2ep.c eq_fir_hifi3.c)
add_local_sources(sof eq_fir.c eq_fir_generic.c eq_fir_hifi2ep.c eq_fir_hifi3.c eq_fir_log.c)
if(CONFIG_IPC_MAJOR_3)
add_local_sources(sof eq_fir_ipc3.c)
elseif(CONFIG_IPC_MAJOR_4)
Expand Down
3 changes: 2 additions & 1 deletion src/audio/eq_fir/Kconfig
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# SPDX-License-Identifier: BSD-3-Clause

config COMP_FIR
bool "FIR component"
tristate "FIR component"
select MATH_FIR
select COMP_BLOB
depends on COMP_MODULE_ADAPTER
default m if LIBRARY_DEFAULT_MODULAR
default y
help
Select for FIR component. FIR performance can differ between DSP
Expand Down
Loading
Loading