Skip to content

Commit 2adc03d

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

File tree

4 files changed

+128
-0
lines changed

4 files changed

+128
-0
lines changed

src/audio/base_fw.c

Lines changed: 20 additions & 0 deletions
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 extended_global_perf_data_get(uint32_t *data_off_size, char *data)
432+
{
433+
#ifdef CONFIG_SOF_TELEMETRY_PERFORMANCE_MEASUREMENTS
434+
int ret;
435+
struct extended_global_perf_data *perf_data = (struct extended_global_perf_data *)data;
436+
437+
ret = get_extended_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 global_perf_data_get(uint32_t *data_off_size, char *data)
432450
{
433451
#ifdef CONFIG_SOF_TELEMETRY_PERFORMANCE_MEASUREMENTS
@@ -485,6 +503,8 @@ static int basefw_get_large_config(struct comp_dev *dev,
485503
return basefw_modules_info_get(data_offset, data);
486504
case IPC4_LIBRARIES_INFO_GET:
487505
return basefw_libraries_info_get(data_offset, data);
506+
case IPC4_EXTENDED_GLOBAL_PERF_DATA:
507+
return extended_global_perf_data_get(data_offset, data);
488508
case IPC4_GLOBAL_PERF_DATA:
489509
return global_perf_data_get(data_offset, data);
490510
/* TODO: add more support */

src/debug/telemetry/telemetry.c

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,73 @@ void perf_meas_set_state(enum ipc4_perf_measurements_state_set state)
238238
perf_measurements_state = state;
239239
}
240240

241+
int get_extended_performance_data(struct extended_global_perf_data * const ext_global_perf_data)
242+
{
243+
if (!ext_global_perf_data) {
244+
tr_err(&ipc_tr, "IPC data is NULL");
245+
return -EINVAL;
246+
}
247+
248+
size_t slots_count;
249+
size_t slot_idx = 0;
250+
uint64_t total_dsp_cycles[CONFIG_MAX_CORE_COUNT];
251+
252+
/* TODO
253+
* Setting temporary values here.
254+
* Replace this with actual total dsp cycles info once it is available.
255+
*/
256+
for (size_t core_id = 0; core_id < CONFIG_MAX_CORE_COUNT; ++core_id)
257+
total_dsp_cycles[core_id] = 1;
258+
259+
/* Fill one performance record per core with total dsp cycles */
260+
for (size_t core_id = 0; core_id < CONFIG_MAX_CORE_COUNT; ++core_id) {
261+
if (!(cpu_enabled_cores() & BIT(core_id)))
262+
continue;
263+
264+
memset(&ext_global_perf_data->perf_items[slot_idx], 0,
265+
sizeof(struct ext_perf_data_item));
266+
267+
ext_global_perf_data->perf_items[slot_idx].resource_id = core_id;
268+
ext_global_perf_data->perf_items[slot_idx].module_total_dsp_cycles_consumed =
269+
total_dsp_cycles[core_id];
270+
++slot_idx;
271+
}
272+
273+
slots_count = perf_bitmap_get_occupied(&performance_data_bitmap) + slot_idx;
274+
ext_global_perf_data->perf_item_count = slots_count;
275+
276+
/* fill the rest of the IPC records with data from
277+
* components registered in MW3 for performance measurement
278+
*/
279+
for (size_t idx = 0; idx < perf_bitmap_get_size(&performance_data_bitmap) &&
280+
slot_idx < slots_count; ++idx) {
281+
if (perf_bitmap_is_bit_clear(&performance_data_bitmap, idx))
282+
continue;
283+
284+
ext_global_perf_data->perf_items[slot_idx].resource_id =
285+
perf_data[idx].item.resource_id;
286+
ext_global_perf_data->perf_items[slot_idx].power_mode =
287+
perf_data[idx].item.power_mode;
288+
ext_global_perf_data->perf_items[slot_idx].is_removed =
289+
perf_data[idx].item.is_removed;
290+
ext_global_perf_data->perf_items[slot_idx].module_total_dsp_iterations =
291+
perf_data[idx].total_iteration_count;
292+
ext_global_perf_data->perf_items[slot_idx].module_total_dsp_cycles_consumed =
293+
perf_data[idx].total_cycles_consumed;
294+
ext_global_perf_data->perf_items[slot_idx].module_peak_dsp_cycles =
295+
perf_data[idx].item.peak_kcps * 1000;
296+
ext_global_perf_data->perf_items[slot_idx].module_peak_restricted_cycles =
297+
perf_data[idx].restricted_peak_cycles;
298+
ext_global_perf_data->perf_items[slot_idx].module_total_restricted_cycles_consumed =
299+
perf_data[idx].restricted_total_cycles;
300+
ext_global_perf_data->perf_items[slot_idx].module_total_restricted_iterations =
301+
perf_data[idx].restricted_total_iterations;
302+
ext_global_perf_data->perf_items[slot_idx].rsvd = 0;
303+
++slot_idx;
304+
}
305+
return 0;
306+
}
307+
241308
#ifdef CONFIG_SOF_TELEMETRY_PERFORMANCE_MEASUREMENTS
242309
static void telemetry_perf_queue_append(struct telemetry_perf_queue *q, size_t element)
243310
{

src/include/ipc4/base_fw.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,39 @@ struct perf_data_item {
745745
uint32_t avg_kcps;
746746
} __packed __aligned(4);
747747

748+
struct ext_perf_data_item {
749+
/* ID of the FW component */
750+
uint32_t resource_id;
751+
/* 0 - D0, 1 - D0i3. */
752+
uint32_t power_mode : 1;
753+
uint32_t rsvd : 30;
754+
/* the component still exists (0) or has been already deleted (1) */
755+
uint32_t is_removed : 1;
756+
/* peak number of DSP cycles used by a module */
757+
uint32_t module_peak_dsp_cycles;
758+
/* total number of DSP used since by a module start of measurements, */
759+
uint64_t module_total_dsp_cycles_consumed;
760+
/* how many times a module was executed */
761+
uint64_t module_total_dsp_iterations;
762+
/* peak number of <restricted> cycles used by a module.
763+
* It is measured against DSP wall clock
764+
*/
765+
uint32_t module_peak_restricted_cycles;
766+
/* total number of <restricted> cycles used by a module since start of
767+
* measurements. It is measured against DSP wall clock
768+
*/
769+
uint64_t module_total_restricted_cycles_consumed;
770+
/* how many times a module invoke <restricted> */
771+
uint64_t module_total_restricted_iterations;
772+
} __packed __aligned(4);
773+
774+
struct extended_global_perf_data {
775+
/* Specifies number of items in perf_items array. */
776+
uint32_t perf_item_count;
777+
/* Array of extended global performance measurements. */
778+
struct ext_perf_data_item perf_items[0];
779+
} __packed __aligned(4);
780+
748781
struct perf_data_item_comp {
749782
struct perf_data_item item;
750783
/* Total iteration count of module instance */

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,12 @@ enum ipc4_perf_measurements_state_set perf_meas_get_state(void);
137137
*/
138138
int get_performance_data(struct global_perf_data * const global_perf_data);
139139

140+
/**
141+
* Get extended global performance data entries.
142+
*
143+
* @param[out] ext_global_perf_data Struct to be filled with data
144+
* @return 0 if succeeded, error code otherwise.
145+
*/
146+
int get_extended_performance_data(struct extended_global_perf_data * const ext_global_perf_data);
147+
140148
#endif /*__SOF_TELEMETRY_H__ */

0 commit comments

Comments
 (0)