Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 7 additions & 3 deletions src/include/sof/debug/telemetry/performance_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,12 @@ int get_performance_data(struct global_perf_data * const global_perf_data);
* \brief Retrieve extended global performance telemetry data with per-core breakdown.
* \ingroup telemetry_perf_api
* @param[out] ext_global_perf_data Destination structure to populate.
* @return 0 on success, or negative error code on failure.
* @param[in] size Size of the destination buffer in bytes.
* @return 0 on success, -ENOBUFS when the report does not fit in size bytes, or another
* negative error code on failure.
*/
int get_extended_performance_data(struct extended_global_perf_data * const ext_global_perf_data);
int get_extended_performance_data(struct extended_global_perf_data * const ext_global_perf_data,
uint32_t size);

/**
* \brief Reset all performance measurement counters across all components.
Expand Down Expand Up @@ -176,7 +179,8 @@ static inline int get_performance_data(struct global_perf_data * const global_pe
}

static inline
int get_extended_performance_data(struct extended_global_perf_data * const ext_global_perf_data)
int get_extended_performance_data(struct extended_global_perf_data * const ext_global_perf_data,
uint32_t size)
{
return 0;
}
Expand Down
10 changes: 8 additions & 2 deletions src/ipc/ipc4/handler-user.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,11 @@ __cold int ipc4_get_vendor_config_module_instance(struct comp_dev *dev,
uint32_t data_off_size_local;
struct sof_tlv *output_tlv = (struct sof_tlv *)(data_out + produced_data);

if (produced_data + input_tl[i].max_length > MAILBOX_DSPBOX_SIZE) {
/* the TLV header is written in front of the value, so it
* must fit in the DSPBOX together with max_length
*/
if (produced_data + sizeof(*output_tlv) + input_tl[i].max_length >
MAILBOX_DSPBOX_SIZE) {
tr_err(&ipc_tr, "error: response payload bigger than DSPBOX size");
return IPC4_FAILURE;
}
Expand Down Expand Up @@ -758,7 +762,9 @@ __cold int ipc4_get_vendor_config_module_instance(struct comp_dev *dev,
struct sof_tlv *tl_header;

if (init_block) {
*data_off_size = input_tl->max_length;
/* the first block carries the TL header in front of the value */
*data_off_size = MIN(input_tl->max_length,
MAILBOX_DSPBOX_SIZE - sizeof(*tl_header));
output_buffer = data_out + sizeof(*tl_header);
} else {
output_buffer = data_out;
Expand Down
11 changes: 10 additions & 1 deletion src/kernel/audio/base_fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Copyright(c) 2024 Intel Corporation.
//

#include <errno.h>
#include <stdint.h>

#include <sof/audio/component.h>
Expand All @@ -19,6 +20,7 @@
#include <sof/lib/cpu-clk-manager.h>
#include <sof/lib/cpu.h>
#include <sof/lib/mailbox.h>
#include <sof/math/numbers.h>
#include <sof/platform.h>
#include <sof/lib_manager.h>
#include <rtos/clk.h>
Expand Down Expand Up @@ -696,8 +698,15 @@ __cold static int extended_global_perf_data_get(uint32_t *data_off_size, char *d
#ifdef CONFIG_SOF_TELEMETRY_PERFORMANCE_MEASUREMENTS
int ret;
struct extended_global_perf_data *perf_data = (struct extended_global_perf_data *)data;
/* data_off_size is in/out: the host max reply length comes in, the
* vendor config path sets it to what is left of the reply buffer, and
* neither may exceed the IPC buffer data points into.
*/
uint32_t size = MIN(*data_off_size, SOF_IPC_MSG_MAX_SIZE);

ret = get_extended_performance_data(perf_data);
ret = get_extended_performance_data(perf_data, size);
if (ret == -ENOBUFS)
return IPC4_OUT_OF_MEMORY;
if (ret < 0)
return IPC4_ERROR_INVALID_PARAM;
*data_off_size = sizeof(*perf_data)
Expand Down
17 changes: 16 additions & 1 deletion src/kernel/debug/telemetry/performance_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ __cold int get_performance_data(struct global_perf_data * const global_perf_data
}

__cold int
get_extended_performance_data(struct extended_global_perf_data * const ext_global_perf_data)
get_extended_performance_data(struct extended_global_perf_data * const ext_global_perf_data,
uint32_t size)
{
assert_can_be_cold();

Expand All @@ -413,6 +414,20 @@ get_extended_performance_data(struct extended_global_perf_data * const ext_globa
size_t slot_idx = 0;
uint64_t total_dsp_cycles[CONFIG_MAX_CORE_COUNT];

/* One item per enabled core plus one per occupied perf slot. Refuse the
* request when they do not all fit rather than return a report with
* items silently dropped, the host cannot tell a short report apart
* from a complete one.
*/
slots_count = popcount(cpu_enabled_cores()) +
perf_bitmap_get_occupied(&performance_data_bitmap);
if (size < sizeof(*ext_global_perf_data) ||
slots_count > (size - sizeof(*ext_global_perf_data)) /
sizeof(struct ext_perf_data_item)) {
tr_err(&ipc_tr, "%zu perf items do not fit in %u bytes", slots_count, size);
return -ENOBUFS;
}

/* TODO
* Setting temporary values here.
* Replace this with actual total dsp cycles info once it is available.
Expand Down