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

loging: add logging through probes #8163

Merged
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
1 change: 1 addition & 0 deletions app/boards/intel_adsp_ace15_mtpm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/include/sof/probe/probe.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
62 changes: 47 additions & 15 deletions src/ipc/ipc4/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,26 @@
//
// Author: Kai Vehmanen <[email protected]>

#if CONFIG_LOG_BACKEND_SOF_PROBE && CONFIG_LOG_BACKEND_ADSP_MTRACE
#error Cannot have both backends enabled
#endif

#include <stdint.h>
#include <sof/lib/uuid.h>
#include <sof/ipc/common.h>
#include <ipc4/base_fw.h>
#include <ipc4/error_status.h>
#include <ipc4/logging.h>
#include <zephyr/logging/log_backend.h>
#include <zephyr/logging/log.h>
dabekjakub marked this conversation as resolved.
Show resolved Hide resolved

#if CONFIG_LOG_BACKEND_SOF_PROBE
#include <sof/probe/probe.h>
#endif

#ifdef CONFIG_LOG_BACKEND_ADSP_MTRACE

#include <zephyr/logging/log_backend.h>
#include <zephyr/logging/log_backend_adsp_mtrace.h>
#include <zephyr/logging/log.h>

#include <sof/schedule/edf_schedule.h>
#include <sof/schedule/schedule.h>
Expand Down Expand Up @@ -150,27 +158,51 @@ 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;

/* Make sure we work on correct ipc data by invalidating cache
* data may be taken from different core to the one we are working
* on right now.
*/
dcache_invalidate_region((__sparse_force void __sparse_cache *)data, data_offset_or_size);
dabekjakub marked this conversation as resolved.
Show resolved Hide resolved

log_state = (const struct ipc4_log_state_info *)data;

if (log_state->enable) {
kv2019i marked this conversation as resolved.
Show resolved Hide resolved
if (!probe_is_backend_configured())
return -EINVAL;

log_backend_activate(log_backend, probe_logging_hook);

} else {
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);
}
10 changes: 10 additions & 0 deletions src/logging/log_backend_probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,13 @@ 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;
}

bool probe_is_backend_configured(void)
{
return probe_hook != NULL;
}
2 changes: 1 addition & 1 deletion src/probe/probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading