Skip to content

Commit cf2cf37

Browse files
committed
debug: Add support for debug slot manager
Add support for Zephyr debug slot manager API to move away from hardocded slot allocation. The support is added with ifdef to be able to switch back to the old hardcoded debug lost 'management' Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 77790ce commit cf2cf37

File tree

4 files changed

+79
-4
lines changed

4 files changed

+79
-4
lines changed

src/debug/debug_stream/debug_stream_slot.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,25 @@ struct cpu_mutex {
2020
/* CPU specific mutexes for each circular buffer */
2121
static struct cpu_mutex cpu_mutex[CONFIG_MP_MAX_NUM_CPUS];
2222

23+
#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
24+
static struct debug_stream_slot_hdr *slot;
25+
#else
2326
static const int debug_stream_slot = CONFIG_SOF_DEBUG_STREAM_SLOT_NUMBER;
27+
#endif
2428

2529
static struct debug_stream_slot_hdr *debug_stream_get_slot(void)
2630
{
31+
#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
32+
if (!slot) {
33+
struct adsp_dw_desc slot_desc = { .type = ADSP_DW_SLOT_DEBUG_STREAM, };
34+
35+
slot = (struct debug_stream_slot_hdr *)adsp_dw_request_slot(&slot_desc, NULL);
36+
}
37+
38+
return slot;
39+
#else
2740
return (struct debug_stream_slot_hdr *)ADSP_DW->slots[debug_stream_slot];
41+
#endif
2842
}
2943

3044
static
@@ -113,10 +127,15 @@ static int debug_stream_slot_init(void)
113127
CONFIG_MP_MAX_NUM_CPUS, section_size, hdr_size,
114128
section_area_size);
115129

130+
#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
131+
if (!hdr)
132+
return -ENOMEM;
133+
#else
116134
if (ADSP_DW->descs[debug_stream_slot].type != 0)
117135
LOG_WRN("Slot %d was not free: %u", debug_stream_slot,
118136
ADSP_DW->descs[debug_stream_slot].type);
119137
ADSP_DW->descs[debug_stream_slot].type = ADSP_DW_SLOT_DEBUG_STREAM;
138+
#endif
120139

121140
hdr->hdr.magic = DEBUG_STREAM_IDENTIFIER;
122141
hdr->hdr.hdr_size = hdr_size;

src/debug/telemetry/performance_monitor.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,17 @@ int get_performance_data(struct global_perf_data * const global_perf_data)
211211

212212
size_t slots_count;
213213
size_t slot_idx = 0;
214+
#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
215+
struct system_tick_info *systick_info = telemetry_get_systick_info_ptr();
216+
217+
if (!systick_info)
218+
return 0;
219+
#else
214220
struct telemetry_wnd_data *wnd_data =
215221
(struct telemetry_wnd_data *)ADSP_DW->slots[SOF_DW_TELEMETRY_SLOT];
216222
struct system_tick_info *systick_info =
217223
(struct system_tick_info *)wnd_data->system_tick_info;
224+
#endif
218225

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

379+
#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
380+
struct system_tick_info *systick_info = telemetry_get_systick_info_ptr();
381+
382+
if (!systick_info)
383+
return 0;
384+
#else
372385
struct telemetry_wnd_data *wnd_data =
373386
(struct telemetry_wnd_data *)ADSP_DW->slots[SOF_DW_TELEMETRY_SLOT];
374387
struct system_tick_info *systick_info =
375388
(struct system_tick_info *)wnd_data->system_tick_info;
389+
#endif
376390

377391
for (int core_id = 0; core_id < CONFIG_MAX_CORE_COUNT; ++core_id) {
378392
if (!(cpu_enabled_cores() & BIT(core_id)))

src/debug/telemetry/telemetry.c

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ LOG_MODULE_DECLARE(ipc, CONFIG_SOF_LOG_LEVEL);
2727

2828
/* Systic variables, one set per core */
2929
static int telemetry_systick_counter[CONFIG_MAX_CORE_COUNT];
30+
#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
31+
static struct telemetry_wnd_data *wnd_data;
32+
#endif
33+
3034
#ifdef CONFIG_SOF_TELEMETRY_PERFORMANCE_MEASUREMENTS
3135
static int telemetry_prev_ccount[CONFIG_MAX_CORE_COUNT];
3236
static int telemetry_perf_period_sum[CONFIG_MAX_CORE_COUNT];
@@ -68,19 +72,45 @@ static size_t telemetry_perf_queue_avg(struct telemetry_perf_queue *q)
6872
}
6973
#endif
7074

75+
#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
76+
struct system_tick_info *telemetry_get_systick_info_ptr(void)
77+
{
78+
if (!wnd_data)
79+
return NULL;
80+
81+
return (struct system_tick_info *)wnd_data->system_tick_info;
82+
}
83+
#endif
84+
7185
int telemetry_init(void)
7286
{
7387
/* systick_init */
88+
#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
89+
struct adsp_dw_desc slot_desc = { .type = ADSP_DW_SLOT_TELEMETRY, };
90+
struct system_tick_info *systick_info;
91+
92+
if (wnd_data)
93+
return 0;
94+
95+
wnd_data = (struct telemetry_wnd_data *)adsp_dw_request_slot(&slot_desc,
96+
NULL);
97+
if (!wnd_data)
98+
return -ENOMEM;
99+
100+
systick_info = (struct system_tick_info *)wnd_data->system_tick_info;
101+
#else
74102
uint8_t slot_num = SOF_DW_TELEMETRY_SLOT;
75103
volatile struct adsp_debug_window *window = ADSP_DW;
76104
struct telemetry_wnd_data *wnd_data = (struct telemetry_wnd_data *)ADSP_DW->slots[slot_num];
77105
struct system_tick_info *systick_info =
78106
(struct system_tick_info *)wnd_data->system_tick_info;
79107

80-
tr_info(&ipc_tr, "Telemetry enabled. May affect performance");
81-
82108
window->descs[slot_num].type = ADSP_DW_SLOT_TELEMETRY;
83109
window->descs[slot_num].resource_id = 0;
110+
#endif
111+
112+
tr_info(&ipc_tr, "Telemetry enabled. May affect performance");
113+
84114
wnd_data->separator_1 = 0x0000C0DE;
85115

86116
/* Zero values per core */
@@ -101,13 +131,19 @@ int telemetry_init(void)
101131
void telemetry_update(uint32_t begin_stamp, uint32_t current_stamp)
102132
{
103133
int prid = cpu_get_id();
134+
#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
135+
struct system_tick_info *systick_info = telemetry_get_systick_info_ptr();
104136

105-
++telemetry_systick_counter[prid];
106-
137+
if (!systick_info)
138+
return;
139+
#else
107140
struct telemetry_wnd_data *wnd_data =
108141
(struct telemetry_wnd_data *)ADSP_DW->slots[SOF_DW_TELEMETRY_SLOT];
109142
struct system_tick_info *systick_info =
110143
(struct system_tick_info *)wnd_data->system_tick_info;
144+
#endif
145+
146+
++telemetry_systick_counter[prid];
111147

112148
systick_info[prid].count = telemetry_systick_counter[prid];
113149
systick_info[prid].last_time_elapsed = current_stamp - begin_stamp;

src/include/sof/debug/telemetry/telemetry.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
#include <zephyr/timing/timing.h>
1212
#endif
1313

14+
#ifndef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
1415
/* Slot in memory window 2 (Debug Window) to be used as telemetry slot */
1516
#define SOF_DW_TELEMETRY_SLOT 1
17+
#endif
18+
1619
/* Memory of average algorithm of performance queue */
1720
#define SOF_AVG_PERF_MEAS_DEPTH 64
1821
/* Number of runs taken to calculate average (algorithm resolution) */
@@ -87,6 +90,9 @@ struct telemetry_perf_queue {
8790
};
8891

8992
void telemetry_update(uint32_t begin_ccount, uint32_t current_ccount);
93+
#ifdef CONFIG_INTEL_ADSP_DEBUG_SLOT_MANAGER
94+
struct system_tick_info *telemetry_get_systick_info_ptr(void);
95+
#endif
9096

9197
#ifdef CONFIG_TIMING_FUNCTIONS
9298
#define telemetry_timestamp timing_counter_get

0 commit comments

Comments
 (0)