From fa11388e081965a1f0c18e99d35a3d1c54c7fe62 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Mon, 5 Sep 2022 19:12:13 +0300 Subject: [PATCH] ipc4: logging: fix use of k_uptime_delta() Fix incorrect usage of k_uptime_delta() that leads to incorrect decisions when to send the BUFFER_NOTIFY IPC. k_uptime_delta() not only calculates the delta, but also stores the current uptime to the argument passed as reftime. This breaks the logic in code as mtrace_notify_last_sent was updated unintentionally. Signed-off-by: Kai Vehmanen --- src/ipc/ipc4/logging.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ipc/ipc4/logging.c b/src/ipc/ipc4/logging.c index 55b364ca2..5654c6823 100644 --- a/src/ipc/ipc4/logging.c +++ b/src/ipc/ipc4/logging.c @@ -61,7 +61,7 @@ static void mtrace_log_hook(size_t written, size_t space_left) { if (arch_proc_id() == MTRACE_IPC_CORE && (space_left < NOTIFY_BUFFER_STATUS_THRESHOLD || - k_uptime_delta(&mtrace_notify_last_sent) >= mtrace_aging_timer)) { + k_uptime_get() - mtrace_notify_last_sent >= mtrace_aging_timer)) { ipc_send_buffer_status_notify(); mtrace_notify_last_sent = k_uptime_get(); mtrace_bytes_pending = 0; @@ -79,7 +79,7 @@ static void mtrace_log_hook(size_t written, size_t space_left) static enum task_state mtrace_task_run(void *data) { - if (k_uptime_delta(&mtrace_notify_last_sent) >= mtrace_aging_timer && + if (k_uptime_get() - mtrace_notify_last_sent >= mtrace_aging_timer && mtrace_bytes_pending) mtrace_log_hook(0, 0);