Skip to content
Open
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
25 changes: 21 additions & 4 deletions src/kernel/debug/telemetry/performance_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <ipc4/logging.h>
#include <ipc4/base_fw.h>
#include <ipc4/base_fw_vendor.h>
#include <ipc4/module.h>

LOG_MODULE_DECLARE(ipc, CONFIG_SOF_LOG_LEVEL);

Expand Down Expand Up @@ -185,6 +186,7 @@ __cold struct perf_data_item_comp *perf_data_getnext(void)
perf_bitmap_free(&performance_data_bitmap, idx);
return NULL;
}
memset(&perf_data[idx], 0, sizeof(perf_data[idx]));
return &perf_data[idx];
}

Expand All @@ -196,9 +198,11 @@ int perf_data_free(struct perf_data_item_comp * const item)
if (ret < 0)
return ret;

if (idx >= 0 && idx < PERFORMANCE_DATA_ENTRIES_COUNT)
memset(item, 0, sizeof(*item));

#ifdef CONFIG_SOF_TELEMETRY_MODULE_RESOURCES
if (mod_hot_data && idx >= 0 && idx < PERFORMANCE_DATA_ENTRIES_COUNT) {
memset(item, 0, sizeof(*item));
memset(&mod_hot_data[idx], 0, sizeof(mod_hot_data[idx]));
memset(&mod_cold_data[idx], 0, sizeof(mod_cold_data[idx]));
}
Expand Down Expand Up @@ -230,6 +234,7 @@ __cold void perf_data_item_comp_init(struct perf_data_item_comp *perf, uint32_t
{
assert_can_be_cold();

memset(perf, 0, sizeof(*perf));
perf_data_item_comp_reset(perf);
perf->item.resource_id = resource_id;
perf->item.is_removed = false;
Expand Down Expand Up @@ -347,6 +352,15 @@ void perf_meas_set_state(enum ipc4_perf_measurements_state_set state)
perf_measurements_state = state;
}

/** Encode the module ID in bits 31:16 and the instance ID in bits 15:0. */
static uint32_t perf_report_module_id(uint32_t component_id)
{
uint32_t module_id = IPC4_MOD_ID(component_id);
uint32_t instance_id = IPC4_INST_ID(component_id);

return (module_id << 16) | instance_id;
}

__cold int get_performance_data(struct global_perf_data * const global_perf_data)
{
assert_can_be_cold();
Expand Down Expand Up @@ -394,6 +408,8 @@ __cold int get_performance_data(struct global_perf_data * const global_perf_data
if (perf_bitmap_is_bit_clear(&performance_data_bitmap, idx))
continue;
global_perf_data->perf_items[slot_idx] = perf_data[idx].item;
global_perf_data->perf_items[slot_idx].resource_id =
perf_report_module_id(perf_data[idx].item.resource_id);
++slot_idx;
}
return 0;
Expand Down Expand Up @@ -461,7 +477,7 @@ get_extended_performance_data(struct extended_global_perf_data * const ext_globa
continue;

ext_global_perf_data->perf_items[slot_idx].resource_id =
perf_data[idx].item.resource_id;
perf_report_module_id(perf_data[idx].item.resource_id);
ext_global_perf_data->perf_items[slot_idx].power_mode =
perf_data[idx].item.power_mode;
ext_global_perf_data->perf_items[slot_idx].is_removed =
Expand Down Expand Up @@ -527,7 +543,8 @@ __cold int enable_performance_counters(void)
SOF_MAN_MODULE_OFFSET(mod_id));

for (int inst_id = 0; inst_id < man_module->instance_max_count; inst_id++) {
comp_id = IPC4_COMP_ID(mod_id, inst_id);
comp_id = IPC4_COMP_ID(LIB_MANAGER_PACK_MODULE_ID(lib_id, mod_id),
inst_id);
dev = ipc4_get_comp_dev(comp_id);

if (dev)
Expand Down Expand Up @@ -581,12 +598,12 @@ __cold int performance_monitor_init(void)
perf_data = (struct perf_data_item_comp *)ADSP_PMW;
perf_bitmap_init(&performance_data_bitmap, &performance_data_bit_array,
PERFORMANCE_DATA_ENTRIES_COUNT);
memset(perf_data, 0, sizeof(*perf_data) * PERFORMANCE_DATA_ENTRIES_COUNT);

#ifdef CONFIG_SOF_TELEMETRY_MODULE_RESOURCES
uint8_t *pmw_base = (uint8_t *)ADSP_PMW;
struct sof_tel_mw3_hdr *hdr = (struct sof_tel_mw3_hdr *)(pmw_base + SOF_TEL_MW3_HDR_OFFSET);

memset(perf_data, 0, sizeof(*perf_data) * PERFORMANCE_DATA_ENTRIES_COUNT);
mod_hot_data = (struct sof_tel_mod_hot *)(pmw_base + SOF_TEL_MW3_MOD_HOT_OFFSET);
mod_cold_data = (struct sof_tel_mod_cold *)(pmw_base + SOF_TEL_MW3_MOD_COLD_OFFSET);
memset(mod_hot_data, 0, sizeof(*mod_hot_data) * PERFORMANCE_DATA_ENTRIES_COUNT);
Expand Down
Loading