From 02e0ce84a710acf85a08c01281ce48ff4238a3bf Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Fri, 8 Nov 2024 00:22:07 +0200 Subject: [PATCH 1/8] probe: Fix wrong name in SOF_MODULE_INIT() macro call Fix copy-paste error from SOF_MODULE_INIT() macro call. Signed-off-by: Jyri Sarha --- src/probe/probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/probe/probe.c b/src/probe/probe.c index b6e689bd75d3..c04bf8768b7e 100644 --- a/src/probe/probe.c +++ b/src/probe/probe.c @@ -1511,6 +1511,6 @@ static const struct module_interface probe_interface = { }; DECLARE_MODULE_ADAPTER(probe_interface, PROBE_UUID, pr_tr); -SOF_MODULE_INIT(asrc, sys_comp_module_probe_interface_init); +SOF_MODULE_INIT(probe, sys_comp_module_probe_interface_init); #endif From 1e46fd9b81cdf1c9a7b9543a94c4b5a863d6bfc4 Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Tue, 5 Nov 2024 19:05:52 +0200 Subject: [PATCH 2/8] probe: logging: Fix implicit declaration of function warning Add declaration for symbol probe_is_backend_configured(). Signed-off-by: Jyri Sarha --- src/include/sof/probe/probe.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/include/sof/probe/probe.h b/src/include/sof/probe/probe.h index 7b6623737895..5a7f730aaf1c 100644 --- a/src/include/sof/probe/probe.h +++ b/src/include/sof/probe/probe.h @@ -20,6 +20,7 @@ typedef void(*probe_logging_hook_t)(uint8_t *buffer, size_t length); #if CONFIG_LOG_BACKEND_SOF_PROBE void probe_logging_hook(uint8_t *buffer, size_t length); const struct log_backend *log_backend_probe_get(void); +bool probe_is_backend_configured(void); #endif /** From 9dd5c5200551905e9b0277804fe53e6698d96fed Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Wed, 6 Nov 2024 21:15:07 +0200 Subject: [PATCH 3/8] probe: logging: Remove bogus reference to probe_logging_hook() The probe logging back-end does not use the ctx argument of log_backend_activate() for anything and putting the hook-function there is just a result of brainless copy-pasting from mtrace implementation. Signed-off-by: Jyri Sarha --- src/include/sof/probe/probe.h | 1 - src/ipc/ipc4/logging.c | 2 +- src/probe/probe.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/include/sof/probe/probe.h b/src/include/sof/probe/probe.h index 5a7f730aaf1c..158d60b573e1 100644 --- a/src/include/sof/probe/probe.h +++ b/src/include/sof/probe/probe.h @@ -18,7 +18,6 @@ typedef void(*probe_logging_hook_t)(uint8_t *buffer, size_t length); #if CONFIG_LOG_BACKEND_SOF_PROBE -void probe_logging_hook(uint8_t *buffer, size_t length); const struct log_backend *log_backend_probe_get(void); bool probe_is_backend_configured(void); #endif diff --git a/src/ipc/ipc4/logging.c b/src/ipc/ipc4/logging.c index 29ba657d17c7..01a981435e6e 100644 --- a/src/ipc/ipc4/logging.c +++ b/src/ipc/ipc4/logging.c @@ -185,7 +185,7 @@ int ipc4_logging_enable_logs(bool first_block, if (!probe_is_backend_configured()) return -EINVAL; - log_backend_activate(log_backend, probe_logging_hook); + log_backend_activate(log_backend, NULL); } else { log_backend_deactivate(log_backend); diff --git a/src/probe/probe.c b/src/probe/probe.c index c04bf8768b7e..e09520eee30b 100644 --- a/src/probe/probe.c +++ b/src/probe/probe.c @@ -836,7 +836,7 @@ static void kick_probe_task(struct probe_pdata *_probe) } #if CONFIG_LOG_BACKEND_SOF_PROBE -void probe_logging_hook(uint8_t *buffer, size_t length) +static void probe_logging_hook(uint8_t *buffer, size_t length) { struct probe_pdata *_probe = probe_get(); uint64_t checksum; From 5e7067496ed185ec7af9b050f9a339cce6ffdb31 Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Tue, 12 Nov 2024 20:08:38 +0200 Subject: [PATCH 4/8] probe: ipc4: Fix enable_logs() test The only valid log identifier should be full_id == 0, not anything with module_id == 0. This is not a functional problems as 0 should not be a valid module_id value. Signed-off-by: Jyri Sarha --- src/probe/probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/probe/probe.c b/src/probe/probe.c index e09520eee30b..0e10ad27b293 100644 --- a/src/probe/probe.c +++ b/src/probe/probe.c @@ -1088,7 +1088,7 @@ static struct comp_buffer *ipc4_get_buffer(struct ipc_comp_dev *dev, probe_point static bool enable_logs(const struct probe_point *probe) { #if CONFIG_IPC_MAJOR_4 - return probe->buffer_id.fields.module_id == 0; + return probe->buffer_id.full_id == 0; #else return probe->purpose == PROBE_PURPOSE_LOGGING; #endif From 3305a66d76c47129aa9e05b5b90b3e976539fc7e Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Wed, 13 Nov 2024 00:10:01 +0200 Subject: [PATCH 5/8] probe: remove idle #if around probe.h contents The declarations do not cause any harm, even if the implementation is not compiled in. Signed-off-by: Jyri Sarha --- src/include/sof/probe/probe.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/include/sof/probe/probe.h b/src/include/sof/probe/probe.h index 158d60b573e1..f3f01435902b 100644 --- a/src/include/sof/probe/probe.h +++ b/src/include/sof/probe/probe.h @@ -8,8 +8,6 @@ #ifndef __SOF_PROBE_PROBE_H__ #define __SOF_PROBE_PROBE_H__ -#if CONFIG_PROBE - #include /** @@ -106,6 +104,4 @@ static inline struct probe_pdata *probe_get(void) return sof_get()->probe; } -#endif /* CONFIG_PROBE */ - #endif /* __SOF_PROBE_PROBE_H__ */ From 8724aed7a9d192c18a0fc3a5118c26406f3ff763 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Mon, 16 Sep 2024 17:24:15 +0200 Subject: [PATCH 6/8] llext: export symbols needed for probes Export base firmware symbols needed for modular probes. Signed-off-by: Guennadi Liakhovetski Signed-off-by: Jyri Sarha --- src/init/init.c | 2 ++ src/ipc/ipc-common.c | 2 ++ src/lib/dma.c | 4 ++++ src/lib/notifier.c | 3 +++ src/schedule/zephyr_ll.c | 2 ++ zephyr/schedule.c | 2 ++ 6 files changed, 15 insertions(+) diff --git a/src/init/init.c b/src/init/init.c index 738ce9233e69..530e82a537de 100644 --- a/src/init/init.c +++ b/src/init/init.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -53,6 +54,7 @@ struct sof *sof_get(void) { return &sof; } +EXPORT_SYMBOL(sof_get); #if CONFIG_NO_SECONDARY_CORE_ROM /** diff --git a/src/ipc/ipc-common.c b/src/ipc/ipc-common.c index 7714a4650150..e9de1efdd2a0 100644 --- a/src/ipc/ipc-common.c +++ b/src/ipc/ipc-common.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -95,6 +96,7 @@ struct ipc_comp_dev *ipc_get_comp_dev(struct ipc *ipc, uint16_t type, uint32_t i return NULL; } +EXPORT_SYMBOL(ipc_get_comp_dev); /* Walks through the list of components looking for a sink/source endpoint component * of the given pipeline diff --git a/src/lib/dma.c b/src/lib/dma.c index 639bca4734a4..d95633c45234 100644 --- a/src/lib/dma.c +++ b/src/lib/dma.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -278,6 +279,8 @@ void dma_put(struct dma *dma) k_spin_unlock(&dma->lock, key); } #endif +EXPORT_SYMBOL(dma_get); +EXPORT_SYMBOL(dma_put); int dma_sg_alloc(struct dma_sg_elem_array *elem_array, enum mem_zone zone, @@ -318,6 +321,7 @@ void dma_sg_free(struct dma_sg_elem_array *elem_array) rfree(elem_array->elems); dma_sg_init(elem_array); } +EXPORT_SYMBOL(dma_sg_free); int dma_buffer_copy_from(struct comp_buffer *source, struct comp_buffer *sink, diff --git a/src/lib/notifier.c b/src/lib/notifier.c index 98fbad4346fc..4b096111019c 100644 --- a/src/lib/notifier.c +++ b/src/lib/notifier.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -78,6 +79,7 @@ int notifier_register(void *receiver, void *caller, enum notify_id type, k_spin_unlock(¬ify->lock, key); return ret; } +EXPORT_SYMBOL(notifier_register); void notifier_unregister(void *receiver, void *caller, enum notify_id type) { @@ -114,6 +116,7 @@ void notifier_unregister(void *receiver, void *caller, enum notify_id type) k_spin_unlock(¬ify->lock, key); } +EXPORT_SYMBOL(notifier_unregister); void notifier_unregister_all(void *receiver, void *caller) { diff --git a/src/schedule/zephyr_ll.c b/src/schedule/zephyr_ll.c index 49b1cc0d63a2..899fb5b37268 100644 --- a/src/schedule/zephyr_ll.c +++ b/src/schedule/zephyr_ll.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -522,6 +523,7 @@ int zephyr_ll_task_init(struct task *task, return 0; } +EXPORT_SYMBOL(zephyr_ll_task_init); /* TODO: low-power mode clock support */ /* Runs on each core during initialisation with the same domain argument */ diff --git a/zephyr/schedule.c b/zephyr/schedule.c index e675beece766..75155b5d4913 100644 --- a/zephyr/schedule.c +++ b/zephyr/schedule.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -22,3 +23,4 @@ struct schedulers **arch_schedulers_get(void) { return _schedulers + cpu_get_id(); } +EXPORT_SYMBOL(arch_schedulers_get); From b011319dde2b054743fea74e5f2e77e6a67f07bf Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Fri, 8 Nov 2024 12:17:53 +0200 Subject: [PATCH 7/8] probe: Remove the single assert() that is problematic for llext Remove the single assert() pulls in problematic symbols for llext. Signed-off-by: Jyri Sarha --- src/probe/probe.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/probe/probe.c b/src/probe/probe.c index 0e10ad27b293..2e19ad0f5b3b 100644 --- a/src/probe/probe.c +++ b/src/probe/probe.c @@ -759,7 +759,6 @@ static uint32_t probe_gen_format(uint32_t frame_fmt, uint32_t rate, default: tr_err(&pr_tr, "probe_gen_format(): Invalid frame format specified = 0x%08x", frame_fmt); - assert(false); return 0; } From bb6b35cf2bf0045d33aa92723a5fd710073b7ffe Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Mon, 4 Nov 2024 12:17:41 +0200 Subject: [PATCH 8/8] probe: llext: Enable building probe as loadable llext module To build PROBE as module just set CONFIG_PROBE=m in Kconfig. Signed-off-by: Jyri Sarha --- src/logging/log_backend_probe.c | 1 + src/probe/Kconfig | 8 +++++++- src/probe/llext/CMakeLists.txt | 6 ++++++ src/probe/llext/llext.toml.h | 10 ++++++++++ src/probe/probe.c | 21 ++++++++++++++++++++- src/probe/probe.toml | 6 +++++- zephyr/CMakeLists.txt | 10 +++++++--- 7 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 src/probe/llext/CMakeLists.txt create mode 100644 src/probe/llext/llext.toml.h diff --git a/src/logging/log_backend_probe.c b/src/logging/log_backend_probe.c index 6baf22df2e14..b701fb88756b 100644 --- a/src/logging/log_backend_probe.c +++ b/src/logging/log_backend_probe.c @@ -109,6 +109,7 @@ void probe_logging_init(probe_logging_hook_t fn) { probe_hook = fn; } +EXPORT_SYMBOL(probe_logging_init); const struct log_backend *log_backend_probe_get(void) { diff --git a/src/probe/Kconfig b/src/probe/Kconfig index 20fcbbe9cd3d..a45947ab5181 100644 --- a/src/probe/Kconfig +++ b/src/probe/Kconfig @@ -5,11 +5,14 @@ menu "Probe" config PROBE - bool "Probes enabled" + tristate "Probes enabled" + default m if LIBRARY_DEFAULT_MODULAR default y if CAVS help Select for enabling debug probes to extract/inject buffers +if PROBE != n + config PROBE_POINTS_MAX int "Maximum probe points" depends on PROBE @@ -23,4 +26,7 @@ config PROBE_DMA_MAX default 0 help Define maximum number of injection DMAs. + +endif + endmenu diff --git a/src/probe/llext/CMakeLists.txt b/src/probe/llext/CMakeLists.txt new file mode 100644 index 000000000000..c77ad93ee88d --- /dev/null +++ b/src/probe/llext/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright (c) 2024 Intel Corporation. +# SPDX-License-Identifier: Apache-2.0 + +sof_llext_build("probe" + SOURCES ../probe.c +) diff --git a/src/probe/llext/llext.toml.h b/src/probe/llext/llext.toml.h new file mode 100644 index 000000000000..4567111f4c52 --- /dev/null +++ b/src/probe/llext/llext.toml.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2024 Intel Corporation. All rights reserved. + */ +#include +#define LOAD_TYPE "2" +#include "../probe.toml" + +[module] +count = __COUNTER__ diff --git a/src/probe/probe.c b/src/probe/probe.c index 2e19ad0f5b3b..4ac38e49b8cc 100644 --- a/src/probe/probe.c +++ b/src/probe/probe.c @@ -1512,4 +1512,23 @@ static const struct module_interface probe_interface = { DECLARE_MODULE_ADAPTER(probe_interface, PROBE_UUID, pr_tr); SOF_MODULE_INIT(probe, sys_comp_module_probe_interface_init); -#endif +#if CONFIG_PROBE_MODULE +/* modular: llext dynamic link */ + +#include +#include +#include + +#define UUID_PROBE 0x08, 0x08, 0xAD, 0x7C, 0x10, 0xAB, 0x23, 0xCD, 0xEF, 0x45, \ + 0x12, 0xAB, 0x34, 0xCD, 0x56, 0xEF, + +SOF_LLEXT_MOD_ENTRY(probe, &probe_interface); + +static const struct sof_man_module_manifest mod_manifest __section(".module") __used = + SOF_LLEXT_MODULE_MANIFEST("PROBE", probe_llext_entry, 1, UUID_PROBE, 40); + +SOF_LLEXT_BUILDINFO; + +#endif /* CONFIG_COMP_PROBE_MODULE */ + +#endif /* CONFIG_IPC_MAJOR_4 */ diff --git a/src/probe/probe.toml b/src/probe/probe.toml index b3ae8f8d4c9e..848234b0085c 100644 --- a/src/probe/probe.toml +++ b/src/probe/probe.toml @@ -1,10 +1,14 @@ +#ifndef LOAD_TYPE +#define LOAD_TYPE "0" +#endif + [[module.entry]] name = "PROBE" uuid = "7CAD0808-AB10-CD23-EF45-12AB34CD56EF" affinity_mask = "0x1" instance_count = "1" domain_types = "0" - load_type = "0" + load_type = LOAD_TYPE module_type = "9" auto_start = "0" sched_caps = [1, 0x00008000] diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index c27f407ec891..c583a837203d 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -1129,9 +1129,13 @@ zephyr_library_sources_ifdef(CONFIG_WAVES_CODEC_STUB ${SOF_AUDIO_PATH}/module_adapter/module/waves/maxx_stub.c ) -zephyr_library_sources_ifdef(CONFIG_PROBE - ${SOF_SRC_PATH}/probe/probe.c -) +if(CONFIG_PROBE STREQUAL "m") + add_subdirectory(${SOF_SRC_PATH}/probe/llext + ${PROJECT_BINARY_DIR}/probe_llext) + add_dependencies(app probe) +elseif(CONFIG_PROBE) + zephyr_library_sources(${SOF_SRC_PATH}/probe/probe.c) +endif() zephyr_library_sources_ifdef(CONFIG_MULTICORE ${SOF_SRC_PATH}/idc/idc.c