From ee9fa5ee27dc42c8390410f571d0798a9d34a42a Mon Sep 17 00:00:00 2001 From: Jakub Dabek Date: Wed, 30 Aug 2023 13:02:12 +0200 Subject: [PATCH] loging: add logging through probes Logging with probes was not implemented. This implements ipc that enables logging with probe configuration. Signed-off-by: Jakub Dabek --- app/boards/intel_adsp_ace15_mtpm.conf | 1 + src/include/sof/probe/probe.h | 5 +++ src/ipc/ipc4/logging.c | 54 +++++++++++++++++++-------- src/logging/log_backend_probe.c | 5 +++ src/probe/probe.c | 2 +- 5 files changed, 51 insertions(+), 16 deletions(-) diff --git a/app/boards/intel_adsp_ace15_mtpm.conf b/app/boards/intel_adsp_ace15_mtpm.conf index 8bbcc0278c58..ac1a3c846441 100644 --- a/app/boards/intel_adsp_ace15_mtpm.conf +++ b/app/boards/intel_adsp_ace15_mtpm.conf @@ -67,6 +67,7 @@ CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000 CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=38400000 CONFIG_LOG_BACKEND_ADSP_MTRACE=y +CONFIG_LOG_BACKEND_SOF_PROBE=n CONFIG_SOF_LOG_LEVEL_INF=y CONFIG_ZEPHYR_LOG=y CONFIG_LOG_OUTPUT_FORMAT_LINUX_TIMESTAMP=y diff --git a/src/include/sof/probe/probe.h b/src/include/sof/probe/probe.h index 22522fb09fe3..7b6623737895 100644 --- a/src/include/sof/probe/probe.h +++ b/src/include/sof/probe/probe.h @@ -17,6 +17,11 @@ */ 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); +#endif + /** * @brief Initialize the probe logging backend. * diff --git a/src/ipc/ipc4/logging.c b/src/ipc/ipc4/logging.c index 08cbfa870727..f05da8735b9d 100644 --- a/src/ipc/ipc4/logging.c +++ b/src/ipc/ipc4/logging.c @@ -10,12 +10,16 @@ #include #include #include +#include +#include + +#ifdef CONFIG_LOG_BACKEND_SOF_PROBE +#include +#endif #ifdef CONFIG_LOG_BACKEND_ADSP_MTRACE -#include #include -#include #include #include @@ -150,27 +154,47 @@ int ipc4_logging_enable_logs(bool first_block, return 0; } -int ipc4_logging_shutdown(void) -{ - struct ipc4_log_state_info log_state = { 0 }; - - /* log_state.enable set to 0 above */ - - return ipc4_logging_enable_logs(true, true, sizeof(log_state), (char *)&log_state); -} +#endif -#else +#ifdef CONFIG_LOG_BACKEND_SOF_PROBE int ipc4_logging_enable_logs(bool first_block, bool last_block, uint32_t data_offset_or_size, const char *data) { - return IPC4_UNKNOWN_MESSAGE_TYPE; -} + const struct log_backend *log_backend = log_backend_probe_get(); + const struct ipc4_log_state_info *log_state; + + if (!(first_block && last_block)) + return -EINVAL; + + if (data_offset_or_size < sizeof(struct ipc4_log_state_info)) + return -EINVAL; + + dcache_invalidate_region((__sparse_force void __sparse_cache *)data, data_offset_or_size); + + log_state = (const struct ipc4_log_state_info *)data; + + if (log_state->enable) { + probe_logging_init(probe_logging_hook); + + log_backend_activate(log_backend, probe_logging_hook); + + } else { + probe_logging_init(NULL); + log_backend_deactivate(log_backend); + } -int ipc4_logging_shutdown(void) -{ return 0; } #endif + +int ipc4_logging_shutdown(void) +{ + struct ipc4_log_state_info log_state = { 0 }; + + /* log_state.enable set to 0 above */ + + return ipc4_logging_enable_logs(true, true, sizeof(log_state), (char *)&log_state); +} diff --git a/src/logging/log_backend_probe.c b/src/logging/log_backend_probe.c index b99da2e0a795..5a27c1b944f9 100644 --- a/src/logging/log_backend_probe.c +++ b/src/logging/log_backend_probe.c @@ -109,3 +109,8 @@ void probe_logging_init(probe_logging_hook_t fn) { probe_hook = fn; } + +const struct log_backend *log_backend_probe_get(void) +{ + return &log_backend_adsp_probe; +} diff --git a/src/probe/probe.c b/src/probe/probe.c index 91344e08c56a..351521306449 100644 --- a/src/probe/probe.c +++ b/src/probe/probe.c @@ -841,7 +841,7 @@ static void kick_probe_task(struct probe_pdata *_probe) } #if CONFIG_LOG_BACKEND_SOF_PROBE -static void probe_logging_hook(uint8_t *buffer, size_t length) +void probe_logging_hook(uint8_t *buffer, size_t length) { struct probe_pdata *_probe = probe_get(); uint64_t checksum;