Skip to content

Commit

Permalink
logging: add logging through probes
Browse files Browse the repository at this point in the history
Logging with probes was not implemented. This implements
ipc that enables logging with probe configuration.

Signed-off-by: Jakub Dabek <[email protected]>
  • Loading branch information
dabekjakub committed Sep 13, 2023
1 parent d964b7b commit 84c2126
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 16 deletions.
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
60 changes: 45 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>

#ifdef 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,49 @@ 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 */
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) {
if (!probe_is_backend_configured())
return -EINVAL;

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

0 comments on commit 84c2126

Please sign in to comment.