Skip to content

Commit 8750270

Browse files
committed
base_fw: sync time between host and fw for logging
It is a general implementation for logging and it doesn't use intel audio hardware feature like ART counter. 64bits timerstamp is needed for accurate since the timestamp used by host is beyond 32bits in most cases. Signed-off-by: Rander Wang <rander.wang@intel.com>
1 parent 529277f commit 8750270

5 files changed

Lines changed: 25 additions & 0 deletions

File tree

app/boards/intel_adsp_ace15_mtpm.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,4 @@ CONFIG_DEBUG_COREDUMP_MEMORY_DUMP_MIN=y
9090

9191
CONFIG_PROBE=y
9292
CONFIG_PROBE_DMA_MAX=2
93+
CONFIG_LOG_TIMESTAMP_64BIT=y

app/boards/intel_adsp_ace20_lnl.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,4 @@ CONFIG_COMP_KPB=y
7575
CONFIG_COMP_ARIA=y
7676
CONFIG_CLOCK_CONTROL_ADSP=y
7777
CONFIG_CLOCK_CONTROL=y
78+
CONFIG_LOG_TIMESTAMP_64BIT=y

app/boards/intel_adsp_cavs25.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,4 @@ CONFIG_DMA_DW_FIFO_PARTITION=y
7575
CONFIG_DMA_INTEL_ADSP_GPDMA_HAS_LLP=y
7676

7777
CONFIG_HEAP_MEM_POOL_SIZE=8192
78+
CONFIG_LOG_TIMESTAMP_64BIT=y

app/boards/intel_adsp_cavs25_tgph.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,4 @@ CONFIG_DMA_DW_FIFO_PARTITION=y
7474
CONFIG_DMA_INTEL_ADSP_GPDMA_HAS_LLP=y
7575

7676
CONFIG_HEAP_MEM_POOL_SIZE=8192
77+
CONFIG_LOG_TIMESTAMP_64BIT=y

src/audio/base_fw.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <zephyr/device.h>
1919
#include <zephyr/drivers/counter.h>
2020
#endif
21+
#include <zephyr/logging/log_ctrl.h>
2122

2223
/* TODO: Remove platform-specific code, see https://github.com/thesofproject/sof/issues/7549 */
2324
#if defined(CONFIG_SOC_SERIES_INTEL_ACE) || defined(CONFIG_INTEL_ADSP_CAVS)
@@ -32,6 +33,7 @@ DECLARE_SOF_RT_UUID("basefw", basefw_comp_uuid, 0xe398c32, 0x5ade, 0xba4b,
3233
DECLARE_TR_CTX(basefw_comp_tr, SOF_UUID(basefw_comp_uuid), LOG_LEVEL_INFO);
3334

3435
static struct ipc4_system_time_info global_system_time_info;
36+
static uint64_t time_delta;
3537

3638
static int basefw_config(uint32_t *data_offset, char *data)
3739
{
@@ -234,12 +236,22 @@ static int basefw_mem_state_info(uint32_t *data_offset, char *data)
234236
return 0;
235237
}
236238

239+
/* Assumed time interval between host sends timestamp and fw process it */
240+
#define TIME_SETTING_LATENCY_NS 120000
241+
static log_timestamp_t basefw_get_timestamp(void)
242+
{
243+
return k_cycle_get_64() + time_delta;
244+
}
245+
237246
static uint32_t basefw_set_system_time(uint32_t param_id,
238247
bool first_block,
239248
bool last_block,
240249
uint32_t data_offset,
241250
const char *data)
242251
{
252+
uint64_t host_time;
253+
uint64_t dsp_time;
254+
243255
/* TODO: configurate time to logging subsystem */
244256
if (!(first_block && last_block))
245257
return IPC4_INVALID_REQUEST;
@@ -252,6 +264,15 @@ static uint32_t basefw_set_system_time(uint32_t param_id,
252264
global_system_time_info.dsp_time.val_l = (uint32_t)(current_dsp_time);
253265
global_system_time_info.dsp_time.val_u = (uint32_t)(current_dsp_time >> 32);
254266

267+
/* use default timestamp if 64bit is not enabled since 64bit is necessary for host time */
268+
if (!IS_ENABLED(CONFIG_LOG_TIMESTAMP_64BIT))
269+
return IPC4_SUCCESS;
270+
271+
host_time = k_ns_to_cyc_ceil64(*(uint64_t *)data + TIME_SETTING_LATENCY_NS);
272+
time_delta = host_time - current_dsp_time;
273+
log_set_timestamp_func(basefw_get_timestamp,
274+
sys_clock_hw_cycles_per_sec());
275+
255276
return IPC4_SUCCESS;
256277
}
257278

0 commit comments

Comments
 (0)