Skip to content

Commit

Permalink
performance measurements: add global perf data get ipc
Browse files Browse the repository at this point in the history
Implement global performance data get ipc which extracts performance data
from MW3

Signed-off-by: Tobiasz Dryjanski <tobiaszx.dryjanski@intel.com>
  • Loading branch information
tobonex committed Jun 3, 2024
1 parent ccaa897 commit e4f69af
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/audio/base_fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,20 @@ int set_perf_meas_state(const char *data)
return IPC4_SUCCESS;
}

static int global_perf_data_get(uint32_t *data_off_size, char *data)
{
int ret;
struct global_perf_data *perf_data = (struct global_perf_data *)data;

ret = get_performance_data(perf_data);
if (ret < 0)
return ret;
*data_off_size = sizeof(*perf_data)
+ perf_data->perf_item_count * sizeof(struct perf_data_item);

return IPC4_SUCCESS;
}

static int basefw_get_large_config(struct comp_dev *dev,
uint32_t param_id,
bool first_block,
Expand Down Expand Up @@ -467,13 +481,14 @@ static int basefw_get_large_config(struct comp_dev *dev,
return basefw_modules_info_get(data_offset, data);
case IPC4_LIBRARIES_INFO_GET:
return basefw_libraries_info_get(data_offset, data);
case IPC4_GLOBAL_PERF_DATA:
return global_perf_data_get(data_offset, data);
/* TODO: add more support */
case IPC4_DSP_RESOURCE_STATE:
case IPC4_NOTIFICATION_MASK:
case IPC4_PIPELINE_PROPS_GET:
case IPC4_GATEWAYS_INFO_GET:
case IPC4_PERF_MEASUREMENTS_STATE:
case IPC4_GLOBAL_PERF_DATA:
COMPILER_FALLTHROUGH;
default:
break;
Expand Down
37 changes: 37 additions & 0 deletions src/debug/telemetry/telemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,43 @@ void perf_data_item_comp_init(struct perf_data_item_comp *perf, uint32_t resourc
perf->item.power_mode = power_mode;
}

int get_performance_data(struct global_perf_data * const global_perf_data)
{
if (!global_perf_data)
return -EINVAL;
size_t avg_utilization, peak_utilization, slots_count;
size_t slot_idx = 0;
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;

for (size_t core_id = 0; core_id < CONFIG_MAX_CORE_COUNT; ++core_id) {
if (!(cpu_enabled_cores() & BIT(core_id)))
continue;
avg_utilization = systick_info[core_id].avg_utilization;
peak_utilization = systick_info[core_id].peak_utilization;
memset(&global_perf_data->perf_items[slot_idx], 0, sizeof(struct perf_data_item));

/* 0 is id of base_fw */
global_perf_data->perf_items[slot_idx].resource_id = 0 + core_id;
global_perf_data->perf_items[slot_idx].avg_kcps = avg_utilization;
global_perf_data->perf_items[slot_idx].peak_kcps = peak_utilization;
++slot_idx;
}
slots_count = perf_bitmap_get_occupied(&performance_data_bitmap) + slot_idx;
global_perf_data->perf_item_count = slots_count;

for (size_t idx = 0; idx < perf_bitmap_get_size(&performance_data_bitmap) &&
slot_idx < slots_count; ++idx) {
if (perf_bitmap_is_bit_clear(&performance_data_bitmap, idx))
continue;
global_perf_data->perf_items[slot_idx] = perf_data_[idx].item;
++slot_idx;
}
return IPC4_SUCCESS;
}

int free_performance_data(struct perf_data_item_comp *item)
{
int ret;
Expand Down
8 changes: 8 additions & 0 deletions src/include/ipc4/base_fw.h
Original file line number Diff line number Diff line change
Expand Up @@ -755,4 +755,12 @@ struct perf_data_item_comp {

} __packed __aligned(4);

struct global_perf_data {
/* Specifies number of items in perf_items array. */
uint32_t perf_item_count;
/* Array of global performance measurements. */
struct perf_data_item perf_items[0];

} __packed __aligned(4);

#endif /* __SOF_IPC4_BASE_FW_H__ */
2 changes: 2 additions & 0 deletions src/include/sof/debug/telemetry/telemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,6 @@ int perf_data_free(struct perf_data_item_comp *item);

int free_performance_data(struct perf_data_item_comp *item);

int get_performance_data(struct global_perf_data * const global_perf_data);

#endif /*__SOF_TELEMETRY_H__ */

0 comments on commit e4f69af

Please sign in to comment.