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

LLEXT multiple modules #9090

Merged
merged 9 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 0 deletions app/overlays/mtl/module_overlay.conf
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
CONFIG_SAMPLE_SMART_AMP=m
CONFIG_COMP_MIXIN_MIXOUT=m
CONFIG_COMP_IIR=m
8 changes: 4 additions & 4 deletions scripts/xtensa-build-zephyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,10 +931,10 @@ def install_lib(sof_lib_dir, abs_build_dir, platform_wconfig):
dst = sof_lib_dir / llext_file

rimage_cfg = entry_path / 'rimage_config.toml'
llext_input = entry_path / (llext_base + '.so')
llext_output = entry_path / llext_file
llext_input = entry_path / (llext_base + '.llext')
llext_output = entry_path / (llext_file + '.ri')
Copy link
Collaborator

@marc-hb marc-hb May 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Err... no, please don't go from .llext to .ri and then BACK to .llext where each step is a different file type; this is incredibly confusing!

One suggestion:

  1. .llext because that's what comes from Zephyr so you don't have a choice?
  2. .ri0 because that's the first rimage stage. Similar to zephyr_pre0
  3. Either .ri or .llext.ri.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marc-hb yeah, .llext -> something else -> .llext is ugly, I agree. There was a wish to have .llext as the final suffix, but now with the use of Zephyr cmake .llext comes out of those functions. Maybe yes - .llext.ri would be a good option for the final output


sign_cmd = [str(platform_wconfig.get("rimage.path")), "-o", str(llext_output),
sign_cmd = [platform_wconfig.get("rimage.path"), "-o", str(llext_output),
"-e", "-c", str(rimage_cfg),
"-k", str(signing_key), "-l", "-r",
str(llext_input)]
Expand All @@ -947,7 +947,7 @@ def install_lib(sof_lib_dir, abs_build_dir, platform_wconfig):
# Thus we're left with a choice between a 150-character
# long line and an illogical split like this
with open(dst, 'wb') as fdst, open(llext_output, 'rb') as fllext, open(
llext_output.with_suffix('.llext.xman'), 'rb') as fman:
llext_output.with_suffix('.ri.xman'), 'rb') as fman:
# Concatenate the manifest and the llext
shutil.copyfileobj(fman, fdst)
shutil.copyfileobj(fllext, fdst)
Expand Down
4 changes: 3 additions & 1 deletion src/audio/audio_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// Copyright(c) 2023 Intel Corporation. All rights reserved.
//

#include <rtos/symbol.h>

#include <sof/audio/audio_stream.h>
#include <sof/audio/buffer.h>

Expand Down Expand Up @@ -101,7 +103,7 @@ void audio_stream_set_align(const uint32_t byte_align,
stream->frame_align_req = frame_align_req;
audio_stream_recalc_align(stream);
}

EXPORT_SYMBOL(audio_stream_set_align);

static int audio_stream_release_data(struct sof_source *source, size_t free_size)
{
Expand Down
2 changes: 2 additions & 0 deletions src/audio/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <sof/lib/notifier.h>
#include <sof/list.h>
#include <rtos/spinlock.h>
#include <rtos/symbol.h>
#include <ipc/topology.h>
#include <errno.h>
#include <stddef.h>
Expand Down Expand Up @@ -156,6 +157,7 @@ int buffer_set_params(struct comp_buffer *buffer,

return 0;
}
EXPORT_SYMBOL(buffer_set_params);

bool buffer_params_match(struct comp_buffer *buffer,
struct sof_ipc_stream_params *params, uint32_t flag)
Expand Down
2 changes: 2 additions & 0 deletions src/audio/component.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ int comp_set_state(struct comp_dev *dev, int cmd)

return 0;
}
EXPORT_SYMBOL(comp_set_state);

void sys_comp_init(struct sof *sof)
{
Expand Down Expand Up @@ -419,6 +420,7 @@ void cir_buf_copy(void *src, void *src_addr, void *src_end, void *dst,
}

#endif
EXPORT_SYMBOL(audio_stream_copy);

void audio_stream_copy_from_linear(const void *linear_source, int ioffset,
struct audio_stream *sink, int ooffset,
Expand Down
4 changes: 4 additions & 0 deletions src/audio/data_blob.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ void *comp_get_data_blob(struct comp_data_blob_handler *blob_handler,

return blob_handler->data;
}
EXPORT_SYMBOL(comp_get_data_blob);

bool comp_is_new_data_blob_available(struct comp_data_blob_handler
*blob_handler)
Expand All @@ -119,6 +120,7 @@ bool comp_is_new_data_blob_available(struct comp_data_blob_handler

return false;
}
EXPORT_SYMBOL(comp_is_new_data_blob_available);

bool comp_is_current_data_blob_valid(struct comp_data_blob_handler
*blob_handler)
Expand Down Expand Up @@ -162,6 +164,7 @@ int comp_init_data_blob(struct comp_data_blob_handler *blob_handler,

return 0;
}
EXPORT_SYMBOL(comp_init_data_blob);

int comp_data_blob_set(struct comp_data_blob_handler *blob_handler,
enum module_cfg_fragment_position pos, uint32_t data_offset_size,
Expand Down Expand Up @@ -615,6 +618,7 @@ int comp_data_blob_get_cmd(struct comp_data_blob_handler *blob_handler,

return ret;
}
EXPORT_SYMBOL(comp_data_blob_get_cmd);

static void *default_alloc(size_t size)
{
Expand Down
2 changes: 1 addition & 1 deletion src/audio/eq_iir/Kconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause

config COMP_IIR
bool "IIR component"
tristate "IIR component"
select COMP_BLOB
default y
depends on COMP_MODULE_ADAPTER
Expand Down
20 changes: 20 additions & 0 deletions src/audio/eq_iir/eq_iir.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,23 @@ static const struct module_interface eq_iir_interface = {

DECLARE_MODULE_ADAPTER(eq_iir_interface, eq_iir_uuid, eq_iir_tr);
SOF_MODULE_INIT(eq_iir, sys_comp_module_eq_iir_interface_init);

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

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

#include <module/module/llext.h>

#define UUID_EQIIR 0xE6, 0xC0, 0x50, 0x51, 0xF9, 0x27, 0xC8, 0x4E, \
0x83, 0x51, 0xC7, 0x05, 0xB6, 0x42, 0xD1, 0x2F

SOF_LLEXT_MOD_ENTRY(eq_iir, &eq_iir_interface);

static const struct sof_man_module_manifest mod_manifest __section(".module") __used =
SOF_LLEXT_MODULE_MANIFEST("EQIIR", eq_iir_llext_entry, 1, UUID_EQIIR);

SOF_LLEXT_BUILDINFO;

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

REM # eq iir module config
[[module.entry]]
name = "EQIIR"
uuid = "5150C0E6-27F9-4EC8-8351-C705B642D12F"
affinity_mask = "0x1"
instance_count = "40"
domain_types = "0"
load_type = "0"
load_type = LOAD_TYPE
module_type = "9"
auto_start = "0"
sched_caps = [1, 0x00008000]
Expand Down
10 changes: 10 additions & 0 deletions src/audio/eq_iir/llext/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2024 Intel Corporation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this file will be shrunk/replaced when Zephyr llext cmake helpers are used ?

# SPDX-License-Identifier: Apache-2.0

# Hard-coded .text address to be moved to a common place
sof_llext_build("eq_iir"
SOURCES ../eq_iir.c
../eq_iir_ipc4.c
../eq_iir_generic.c
TEXT_ADDR 0xa06ea000
)
6 changes: 6 additions & 0 deletions src/audio/eq_iir/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 "../eq_iir.toml"

[module]
count = __COUNTER__
2 changes: 1 addition & 1 deletion src/audio/mixin_mixout/Kconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause

config COMP_MIXIN_MIXOUT
bool "Mixin_mixout component"
tristate "Mixin_mixout component"
depends on IPC_MAJOR_4
default y
help
Expand Down
11 changes: 11 additions & 0 deletions src/audio/mixin_mixout/llext/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +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("mixin_mixout"
SOURCES ../mixin_mixout.c
../mixin_mixout_hifi3.c
../mixin_mixout_hifi5.c
../mixin_mixout_generic.c
TEXT_ADDR 0xa06aa000
)
6 changes: 6 additions & 0 deletions src/audio/mixin_mixout/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 "../mixin_mixout.toml"

[module]
count = __COUNTER__
28 changes: 27 additions & 1 deletion src/audio/mixin_mixout/mixin_mixout.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include "mixin_mixout.h"

LOG_MODULE_REGISTER(mixer, CONFIG_SOF_LOG_LEVEL);
LOG_MODULE_REGISTER(mixin_mixout, CONFIG_SOF_LOG_LEVEL);

/* mixin 39656eb2-3b71-4049-8d3f-f92cd5c43c09 */
DECLARE_SOF_RT_UUID("mix_in", mixin_uuid, 0x39656eb2, 0x3b71, 0x4049,
Expand Down Expand Up @@ -964,3 +964,29 @@ static const struct module_interface mixout_interface = {

DECLARE_MODULE_ADAPTER(mixout_interface, mixout_uuid, mixout_tr);
SOF_MODULE_INIT(mixout, sys_comp_module_mixout_interface_init);

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

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

#include <module/module/llext.h>

#define UUID_MIXIN 0xB2, 0x6E, 0x65, 0x39, 0x71, 0x3B, 0x49, 0x40, \
0x8D, 0x3F, 0xF9, 0x2C, 0xD5, 0xC4, 0x3C, 0x09
#define UUID_MIXOUT 0x5A, 0x50, 0x56, 0x3C, 0xD7, 0x24, 0x8F, 0x41, \
0xBD, 0xDC, 0xC1, 0xF5, 0xA3, 0xAC, 0x2A, 0xE0

SOF_LLEXT_MOD_ENTRY(mixin, &mixin_interface);
SOF_LLEXT_MOD_ENTRY(mixout, &mixout_interface);

static const struct sof_man_module_manifest mod_manifest[] __section(".module") __used =
{
SOF_LLEXT_MODULE_MANIFEST("MIXIN", mixin_llext_entry, 1, UUID_MIXIN),
SOF_LLEXT_MODULE_MANIFEST("MIXOUT", mixout_llext_entry, 1, UUID_MIXOUT),
};

SOF_LLEXT_BUILDINFO;

#endif
8 changes: 6 additions & 2 deletions src/audio/mixin_mixout/mixin_mixout.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#ifndef LOAD_TYPE
#define LOAD_TYPE "0"
#endif

[[module.entry]]
name = "MIXIN"
uuid = "39656EB2-3B71-4049-8D3F-F92CD5C43C09"
affinity_mask = "0x1"
instance_count = "30"
domain_types = "0"
load_type = "0"
load_type = LOAD_TYPE
module_type = "1"
auto_start = "0"
sched_caps = [1, 0x00008000]
Expand All @@ -30,7 +34,7 @@
affinity_mask = "0x1"
instance_count = "30"
domain_types = "0"
load_type = "0"
load_type = LOAD_TYPE
module_type = "2"
auto_start = "0"
sched_caps = [1, 0x00008000]
Expand Down
3 changes: 3 additions & 0 deletions src/audio/module_adapter/module/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*
*/

#include <rtos/symbol.h>

#include <sof/audio/module_adapter/module/generic.h>

LOG_MODULE_DECLARE(module_adapter, CONFIG_SOF_LOG_LEVEL);
Expand Down Expand Up @@ -537,3 +539,4 @@ void module_update_buffer_position(struct input_stream_buffer *input_buffers,
input_buffers->consumed += audio_stream_frame_bytes(source) * frames;
output_buffers->size += audio_stream_frame_bytes(sink) * frames;
}
EXPORT_SYMBOL(module_update_buffer_position);
36 changes: 36 additions & 0 deletions src/include/module/module/llext.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* SPDX-License-Identifier: BSD-3-Clause */
/*
* Copyright(c) 2024 Intel Corporation. All rights reserved.
*/

#ifndef MODULE_LLEXT_H
#define MODULE_LLEXT_H

#define SOF_LLEXT_MODULE_MANIFEST(manifest_name, entry, affinity, mod_uuid) \
{ \
.module = { \
.name = manifest_name, \
.uuid = {mod_uuid}, \
.entry_point = (uint32_t)(entry), \
.type = { \
.load_type = SOF_MAN_MOD_TYPE_LLEXT, \
.domain_ll = 1, \
}, \
.affinity_mask = (affinity), \
} \
}

#define SOF_LLEXT_MOD_ENTRY(name, interface) \
static const struct module_interface *name##_llext_entry(void *mod_cfg, \
void *parent_ppl, void **mod_ptr) \
{ \
return interface; \
}

#define SOF_LLEXT_BUILDINFO \
static const struct sof_module_api_build_info buildinfo __section(".mod_buildinfo") __used = { \
.format = SOF_MODULE_API_BUILD_INFO_FORMAT, \
.api_version_number.full = SOF_MODULE_API_CURRENT_VERSION, \
}

#endif
6 changes: 3 additions & 3 deletions src/include/sof/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
#define container_of(ptr, type, member) \
({const typeof(((type *)0)->member)*__memberptr = (ptr); \
({const __typeof__(((type *)0)->member)*__memberptr = (ptr); \
(type *)((char *)__memberptr - offsetof(type, member)); })
/*
* typeof() doesn't preserve __attribute__((address_space(x))) sparse
Expand All @@ -127,7 +127,7 @@
* re-inforce the address space onto the new pointer.
*/
#define attr_container_of(ptr, type, member, attr) \
({const typeof(((type *)0)->member) attr *__memberptr = (ptr); \
({const __typeof__(((type *)0)->member) attr *__memberptr = (ptr); \
(type *)((char attr *)__memberptr - offsetof(type, member)); })

#define ffs(i) __builtin_ffs(i)
Expand Down Expand Up @@ -219,7 +219,7 @@
* alignment. This compiler builtin may not be available on all compilers so
* this macro can be defined as NULL if needed.
*/
#define ASSUME_ALIGNED(x, a) ((typeof(x))__builtin_assume_aligned((x), a))
#define ASSUME_ALIGNED(x, a) ((__typeof__(x))__builtin_assume_aligned((x), a))
#endif /* __XCC__ */

#endif /* __ASSEMBLER__ */
Expand Down
10 changes: 5 additions & 5 deletions src/include/sof/debug/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@

/* swap an endianness of 32-bit word */
#define bswap32(N) ({ \
typeof(N) n = (N); \
__typeof__(N) n = (N); \
((n & 0x000000FF) << 24) | \
((n & 0x0000FF00) << 8) | \
((n & 0x00FF0000) >> 8) | \
Expand All @@ -153,10 +153,10 @@
*/
#define dump_hex(ptr, idx, len) \
do { \
typeof(idx) __i = (idx); \
typeof(ptr) __p = (ptr) + __i; \
typeof(idx) __l = (len) - __i; \
typeof(idx) __n = __l > 4 ? 4 : __l; \
__typeof__(idx) __i = (idx); \
__typeof__(ptr) __p = (ptr) + __i; \
__typeof__(idx) __l = (len) - __i; \
__typeof__(idx) __n = __l > 4 ? 4 : __l; \
if (__n == 4) { \
comp_info(dev, "%08x%08x%08x%08x", bswap32(__p[0]), bswap32(__p[1]), \
bswap32(__p[2]), bswap32(__p[3])); \
Expand Down
8 changes: 4 additions & 4 deletions src/include/sof/math/numbers.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
#define MAX(a, b) ((a) < (b) ? (b) : (a))

#define ROUND_DOWN(size, alignment) ({ \
typeof(size) __size = (size); \
typeof(alignment) __alignment = (alignment); \
__typeof__(size) __size = (size); \
__typeof__(alignment) __alignment = (alignment); \
__size - (__size % __alignment); \
})
#endif /* ! __ZEPHYR__ */

#define ABS(a) ({ \
typeof(a) __a = (a); \
__typeof__(a) __a = (a); \
__a < 0 ? -__a : __a; \
})
#define SGN(a) ({ \
typeof(a) __a = (a); \
__typeof__(a) __a = (a); \
__a < 0 ? -1 : \
__a > 0 ? 1 : 0; \
})
Expand Down
Loading
Loading