From 2cd2524997e9742fd00f45ab8d2cf7fa1994d210 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Tue, 20 Aug 2024 17:15:57 +0300 Subject: [PATCH] drc: move logging context to the base image Logging context can be accessed from the deferred logging thread. Therefore it must be always available to avoid access to unmapped memory when an LLEXT module is unloaded. Signed-off-by: Guennadi Liakhovetski --- src/audio/drc/CMakeLists.txt | 15 +++++++++------ src/audio/drc/drc.c | 7 +++---- src/audio/drc/drc_log.c | 15 +++++++++++++++ zephyr/CMakeLists.txt | 6 ++++++ 4 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 src/audio/drc/drc_log.c diff --git a/src/audio/drc/CMakeLists.txt b/src/audio/drc/CMakeLists.txt index 650b09b40612..4e2751035ee5 100644 --- a/src/audio/drc/CMakeLists.txt +++ b/src/audio/drc/CMakeLists.txt @@ -1,6 +1,9 @@ -add_local_sources(sof drc.c) -add_local_sources(sof drc_generic.c) -add_local_sources(sof drc_hifi3.c) -add_local_sources(sof drc_hifi4.c) -add_local_sources(sof drc_math_generic.c) -add_local_sources(sof drc_math_hifi3.c) +add_local_sources(sof + drc.c + drc_generic.c + drc_hifi3.c + drc_hifi4.c + drc_math_generic.c + drc_math_hifi3.c + drc_log.c +) diff --git a/src/audio/drc/drc.c b/src/audio/drc/drc.c index 16c6d89524ac..13b33415953b 100644 --- a/src/audio/drc/drc.c +++ b/src/audio/drc/drc.c @@ -36,11 +36,10 @@ #include "drc.h" #include "drc_algorithm.h" -LOG_MODULE_REGISTER(drc, CONFIG_SOF_LOG_LEVEL); +LOG_MODULE_DECLARE(drc, CONFIG_SOF_LOG_LEVEL); -SOF_DEFINE_REG_UUID(drc); - -DECLARE_TR_CTX(drc_tr, SOF_UUID(drc_uuid), LOG_LEVEL_INFO); +extern const struct sof_uuid drc_uuid; +extern struct tr_ctx drc_tr; void drc_reset_state(struct drc_state *state) { diff --git a/src/audio/drc/drc_log.c b/src/audio/drc/drc_log.c new file mode 100644 index 000000000000..63c88e65101a --- /dev/null +++ b/src/audio/drc/drc_log.c @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: BSD-3-Clause +// +// Copyright(c) 2024 Intel Corporation. + +#include +#include +#include +#include + +SOF_DEFINE_REG_UUID(drc); +LOG_MODULE_REGISTER(drc, CONFIG_SOF_LOG_LEVEL); +DECLARE_TR_CTX(drc_tr, SOF_UUID(drc_uuid), LOG_LEVEL_INFO); +EXPORT_SYMBOL(drc_tr); +EXPORT_SYMBOL(drc_uuid); +EXPORT_SYMBOL(log_const_drc); diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 43003dec8529..e383ec93ff0f 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -755,6 +755,12 @@ elseif(CONFIG_COMP_DRC) ) endif() +if(NOT CONFIG_COMP_DRC STREQUAL "n") + zephyr_library_sources( + ${SOF_AUDIO_PATH}/drc/drc_log.c + ) +endif() + zephyr_library_sources_ifdef(CONFIG_COMP_MULTIBAND_DRC ${SOF_AUDIO_PATH}/multiband_drc/multiband_drc.c ${SOF_AUDIO_PATH}/multiband_drc/multiband_drc_generic.c