Skip to content

Commit 9ebe16b

Browse files
committed
performance measurements: add global perf data get ipc
Implement global performance data get ipc which extracts performance data from MW3 Signed-off-by: Tobiasz Dryjanski <tobiaszx.dryjanski@intel.com>
1 parent 91e61c4 commit 9ebe16b

File tree

4 files changed

+79
-1
lines changed

4 files changed

+79
-1
lines changed

src/audio/base_fw.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,24 @@ int set_perf_meas_state(const char *data)
428428
return IPC4_SUCCESS;
429429
}
430430

431+
static int global_perf_data_get(uint32_t *data_off_size, char *data)
432+
{
433+
#ifdef CONFIG_SOF_TELEMETRY_PERFORMANCE_MEASUREMENTS
434+
int ret;
435+
struct global_perf_data *perf_data = (struct global_perf_data *)data;
436+
437+
ret = get_performance_data(perf_data);
438+
if (ret < 0)
439+
return IPC4_ERROR_INVALID_PARAM;
440+
*data_off_size = sizeof(*perf_data)
441+
+ perf_data->perf_item_count * sizeof(*perf_data->perf_items);
442+
443+
return IPC4_SUCCESS;
444+
#else
445+
return IPC4_UNAVAILABLE;
446+
#endif
447+
}
448+
431449
static int basefw_get_large_config(struct comp_dev *dev,
432450
uint32_t param_id,
433451
bool first_block,
@@ -467,13 +485,14 @@ static int basefw_get_large_config(struct comp_dev *dev,
467485
return basefw_modules_info_get(data_offset, data);
468486
case IPC4_LIBRARIES_INFO_GET:
469487
return basefw_libraries_info_get(data_offset, data);
488+
case IPC4_GLOBAL_PERF_DATA:
489+
return global_perf_data_get(data_offset, data);
470490
/* TODO: add more support */
471491
case IPC4_DSP_RESOURCE_STATE:
472492
case IPC4_NOTIFICATION_MASK:
473493
case IPC4_PIPELINE_PROPS_GET:
474494
case IPC4_GATEWAYS_INFO_GET:
475495
case IPC4_PERF_MEASUREMENTS_STATE:
476-
case IPC4_GLOBAL_PERF_DATA:
477496
COMPILER_FALLTHROUGH;
478497
default:
479498
break;

src/debug/telemetry/telemetry.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,49 @@ void perf_data_item_comp_init(struct perf_data_item_comp *perf, uint32_t resourc
167167
perf->item.power_mode = power_mode;
168168
}
169169

170+
int get_performance_data(struct global_perf_data * const global_perf_data)
171+
{
172+
if (!global_perf_data) {
173+
tr_err(&ipc_tr, "IPC data is NULL");
174+
return -EINVAL;
175+
}
176+
177+
size_t slots_count;
178+
size_t slot_idx = 0;
179+
struct telemetry_wnd_data *wnd_data =
180+
(struct telemetry_wnd_data *)ADSP_DW->slots[SOF_DW_TELEMETRY_SLOT];
181+
struct system_tick_info *systick_info =
182+
(struct system_tick_info *)wnd_data->system_tick_info;
183+
184+
/* Fill one performance record with performance stats per core */
185+
for (size_t core_id = 0; core_id < CONFIG_MAX_CORE_COUNT; ++core_id) {
186+
if (!(cpu_enabled_cores() & BIT(core_id)))
187+
continue;
188+
memset(&global_perf_data->perf_items[slot_idx], 0, sizeof(struct perf_data_item));
189+
190+
global_perf_data->perf_items[slot_idx].resource_id = core_id;
191+
global_perf_data->perf_items[slot_idx].avg_kcps =
192+
systick_info[core_id].avg_utilization;
193+
global_perf_data->perf_items[slot_idx].peak_kcps =
194+
systick_info[core_id].peak_utilization;
195+
++slot_idx;
196+
}
197+
slots_count = perf_bitmap_get_occupied(&performance_data_bitmap) + slot_idx;
198+
global_perf_data->perf_item_count = slots_count;
199+
200+
/* fill the rest of the IPC records with data from
201+
* components registered in MW3 for performance measurement
202+
*/
203+
for (size_t idx = 0; idx < perf_bitmap_get_size(&performance_data_bitmap) &&
204+
slot_idx < slots_count; ++idx) {
205+
if (perf_bitmap_is_bit_clear(&performance_data_bitmap, idx))
206+
continue;
207+
global_perf_data->perf_items[slot_idx] = perf_data[idx].item;
208+
++slot_idx;
209+
}
210+
return 0;
211+
}
212+
170213
int free_performance_data(struct perf_data_item_comp *item)
171214
{
172215
int ret;

src/include/ipc4/base_fw.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,4 +758,12 @@ struct perf_data_item_comp {
758758

759759
} __packed __aligned(4);
760760

761+
struct global_perf_data {
762+
/* Specifies number of items in perf_items array. */
763+
uint32_t perf_item_count;
764+
/* Array of global performance measurements. */
765+
struct perf_data_item perf_items[0];
766+
767+
} __packed __aligned(4);
768+
761769
#endif /* __SOF_IPC4_BASE_FW_H__ */

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,12 @@ void perf_meas_set_state(enum ipc4_perf_measurements_state_set state);
129129
*/
130130
enum ipc4_perf_measurements_state_set perf_meas_get_state(void);
131131

132+
/**
133+
* Get global performance data entries.
134+
*
135+
* @param[out] global_perf_data Struct to be filled with data
136+
* @return 0 if succeeded, error code otherwise.
137+
*/
138+
int get_performance_data(struct global_perf_data * const global_perf_data);
139+
132140
#endif /*__SOF_TELEMETRY_H__ */

0 commit comments

Comments
 (0)