Skip to content
Open
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
7 changes: 7 additions & 0 deletions app/boards/intel_adsp/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,10 @@ config LOG_TIMESTAMP_64BIT

config ZTEST
default SOF_BOOT_TEST_SUPPORTED && SOF_BOOT_TEST_ALLOWED

# Zephyr / debug slot manager
# ----------------------------------------

config INTEL_ADSP_DEBUG_SLOT_MANAGER
default y

19 changes: 19 additions & 0 deletions src/debug/debug_stream/debug_stream_slot.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,25 @@ struct cpu_mutex {
/* CPU specific mutexes for each circular buffer */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some typoes in commit (hardocded, "debug lost management"), code looks good.

static struct cpu_mutex cpu_mutex[CONFIG_MP_MAX_NUM_CPUS];

#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
static struct debug_stream_slot_hdr *slot;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please give it a longer name. Names like this make grepping / tagging quite difficult. Can be an incremental patch.

#else
static const int debug_stream_slot = CONFIG_SOF_DEBUG_STREAM_SLOT_NUMBER;
#endif

static struct debug_stream_slot_hdr *debug_stream_get_slot(void)
{
#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
if (!slot) {
struct adsp_dw_desc slot_desc = { .type = ADSP_DW_SLOT_DEBUG_STREAM, };

slot = (struct debug_stream_slot_hdr *)adsp_dw_request_slot(&slot_desc, NULL);
}

return slot;
#else
return (struct debug_stream_slot_hdr *)ADSP_DW->slots[debug_stream_slot];
#endif
}

static
Expand Down Expand Up @@ -113,10 +127,15 @@ static int debug_stream_slot_init(void)
CONFIG_MP_MAX_NUM_CPUS, section_size, hdr_size,
section_area_size);

#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
if (!hdr)
return -ENOMEM;
#else
if (ADSP_DW->descs[debug_stream_slot].type != 0)
LOG_WRN("Slot %d was not free: %u", debug_stream_slot,
ADSP_DW->descs[debug_stream_slot].type);
ADSP_DW->descs[debug_stream_slot].type = ADSP_DW_SLOT_DEBUG_STREAM;
#endif

hdr->hdr.magic = DEBUG_STREAM_IDENTIFIER;
hdr->hdr.hdr_size = hdr_size;
Expand Down
14 changes: 14 additions & 0 deletions src/debug/telemetry/performance_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,17 @@ int get_performance_data(struct global_perf_data * const global_perf_data)

size_t slots_count;
size_t slot_idx = 0;
#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
struct system_tick_info *systick_info = telemetry_get_systick_info_ptr();

if (!systick_info)
return 0;
#else
struct telemetry_wnd_data *wnd_data =
(struct telemetry_wnd_data *)ADSP_DW->slots[SOF_DW_TELEMETRY_SLOT];
struct system_tick_info *systick_info =
(struct system_tick_info *)wnd_data->system_tick_info;
#endif

/* Fill one performance record with performance stats per core */
for (int core_id = 0; core_id < CONFIG_MAX_CORE_COUNT; ++core_id) {
Expand Down Expand Up @@ -369,10 +376,17 @@ int reset_performance_counters(void)
if (perf_measurements_state == IPC4_PERF_MEASUREMENTS_DISABLED)
return -EINVAL;

#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
struct system_tick_info *systick_info = telemetry_get_systick_info_ptr();

if (!systick_info)
return 0;
#else
struct telemetry_wnd_data *wnd_data =
(struct telemetry_wnd_data *)ADSP_DW->slots[SOF_DW_TELEMETRY_SLOT];
struct system_tick_info *systick_info =
(struct system_tick_info *)wnd_data->system_tick_info;
#endif

for (int core_id = 0; core_id < CONFIG_MAX_CORE_COUNT; ++core_id) {
if (!(cpu_enabled_cores() & BIT(core_id)))
Expand Down
44 changes: 40 additions & 4 deletions src/debug/telemetry/telemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ LOG_MODULE_DECLARE(ipc, CONFIG_SOF_LOG_LEVEL);

/* Systic variables, one set per core */
static int telemetry_systick_counter[CONFIG_MAX_CORE_COUNT];
#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
static struct telemetry_wnd_data *wnd_data;
#endif

#ifdef CONFIG_SOF_TELEMETRY_PERFORMANCE_MEASUREMENTS
static int telemetry_prev_ccount[CONFIG_MAX_CORE_COUNT];
static int telemetry_perf_period_sum[CONFIG_MAX_CORE_COUNT];
Expand Down Expand Up @@ -68,19 +72,45 @@ static size_t telemetry_perf_queue_avg(struct telemetry_perf_queue *q)
}
#endif

#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
struct system_tick_info *telemetry_get_systick_info_ptr(void)
{
if (!wnd_data)
return NULL;

return (struct system_tick_info *)wnd_data->system_tick_info;
}
#endif

int telemetry_init(void)
{
/* systick_init */
#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
struct adsp_dw_desc slot_desc = { .type = ADSP_DW_SLOT_TELEMETRY, };
struct system_tick_info *systick_info;

if (wnd_data)
return 0;

wnd_data = (struct telemetry_wnd_data *)adsp_dw_request_slot(&slot_desc,
NULL);
if (!wnd_data)
return -ENOMEM;

systick_info = (struct system_tick_info *)wnd_data->system_tick_info;
#else
uint8_t slot_num = SOF_DW_TELEMETRY_SLOT;
volatile struct adsp_debug_window *window = ADSP_DW;
struct telemetry_wnd_data *wnd_data = (struct telemetry_wnd_data *)ADSP_DW->slots[slot_num];
struct system_tick_info *systick_info =
(struct system_tick_info *)wnd_data->system_tick_info;

tr_info(&ipc_tr, "Telemetry enabled. May affect performance");

window->descs[slot_num].type = ADSP_DW_SLOT_TELEMETRY;
window->descs[slot_num].resource_id = 0;
#endif

tr_info(&ipc_tr, "Telemetry enabled. May affect performance");

wnd_data->separator_1 = 0x0000C0DE;

/* Zero values per core */
Expand All @@ -101,13 +131,19 @@ int telemetry_init(void)
void telemetry_update(uint32_t begin_stamp, uint32_t current_stamp)
{
int prid = cpu_get_id();
#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
struct system_tick_info *systick_info = telemetry_get_systick_info_ptr();

++telemetry_systick_counter[prid];

if (!systick_info)
return;
#else
struct telemetry_wnd_data *wnd_data =
(struct telemetry_wnd_data *)ADSP_DW->slots[SOF_DW_TELEMETRY_SLOT];
struct system_tick_info *systick_info =
(struct system_tick_info *)wnd_data->system_tick_info;
#endif

++telemetry_systick_counter[prid];

systick_info[prid].count = telemetry_systick_counter[prid];
systick_info[prid].last_time_elapsed = current_stamp - begin_stamp;
Expand Down
6 changes: 6 additions & 0 deletions src/include/sof/debug/telemetry/telemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
#include <zephyr/timing/timing.h>
#endif

#ifndef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
/* Slot in memory window 2 (Debug Window) to be used as telemetry slot */
#define SOF_DW_TELEMETRY_SLOT 1
#endif

/* Memory of average algorithm of performance queue */
#define SOF_AVG_PERF_MEAS_DEPTH 64
/* Number of runs taken to calculate average (algorithm resolution) */
Expand Down Expand Up @@ -87,6 +90,9 @@ struct telemetry_perf_queue {
};

void telemetry_update(uint32_t begin_ccount, uint32_t current_ccount);
#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
struct system_tick_info *telemetry_get_systick_info_ptr(void);
#endif

#ifdef CONFIG_TIMING_FUNCTIONS
#define telemetry_timestamp timing_counter_get
Expand Down
Loading