Skip to content

Commit 708181c

Browse files
RanderWangbroonie
authored andcommitted
ASoC: SOF: mtrace: rework mtrace timestamp setting
The original timestamp is built base on windows epoch time which is not fit for Linux system and difficult to be used for kernel debugging. This patch adopts syslog timestamp so that we can simply use dmesg to check the timestamp between fw and kernel. Signed-off-by: Rander Wang <[email protected]> Reviewed-by: Péter Ujfalusi <[email protected]> Reviewed-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Kai Vehmanen <[email protected]> Signed-off-by: Peter Ujfalusi <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent e2d7ad7 commit 708181c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

sound/soc/sof/ipc4-mtrace.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <linux/debugfs.h>
66
#include <linux/sched/signal.h>
7+
#include <linux/sched/clock.h>
78
#include <sound/sof/ipc4/header.h>
89
#include "sof-priv.h"
910
#include "ipc4-priv.h"
@@ -412,7 +413,6 @@ static int ipc4_mtrace_enable(struct snd_sof_dev *sdev)
412413
const struct sof_ipc_ops *iops = sdev->ipc->ops;
413414
struct sof_ipc4_msg msg;
414415
u64 system_time;
415-
ktime_t kt;
416416
int ret;
417417

418418
if (priv->mtrace_state != SOF_MTRACE_DISABLED)
@@ -424,9 +424,12 @@ static int ipc4_mtrace_enable(struct snd_sof_dev *sdev)
424424
msg.primary |= SOF_IPC4_MOD_INSTANCE(SOF_IPC4_MOD_INIT_BASEFW_INSTANCE_ID);
425425
msg.extension = SOF_IPC4_MOD_EXT_MSG_PARAM_ID(SOF_IPC4_FW_PARAM_SYSTEM_TIME);
426426

427-
/* The system time is in usec, UTC, epoch is 1601-01-01 00:00:00 */
428-
kt = ktime_add_us(ktime_get_real(), FW_EPOCH_DELTA * USEC_PER_SEC);
429-
system_time = ktime_to_us(kt);
427+
/*
428+
* local_clock() is used to align with dmesg, so both kernel and firmware logs have
429+
* the same base and a minor delta due to the IPC. system time is in us format but
430+
* local_clock() returns the time in ns, so convert to ns.
431+
*/
432+
system_time = div64_u64(local_clock(), NSEC_PER_USEC);
430433
msg.data_size = sizeof(system_time);
431434
msg.data_ptr = &system_time;
432435
ret = iops->set_get_data(sdev, &msg, msg.data_size, true);

0 commit comments

Comments
 (0)