From a06a75e50cca06484404e0e85c56ca6a36b41822 Mon Sep 17 00:00:00 2001 From: majingyun Date: Tue, 13 May 2025 19:28:35 +0800 Subject: [PATCH] driver/note: To support clock_gettime for CPU sleep scenario Signed-off-by: Majingyun --- drivers/note/Kconfig | 13 +++++++++++++ drivers/note/note_driver.c | 10 ++++++++++ drivers/note/noteram_driver.c | 10 ++++++++++ 3 files changed, 33 insertions(+) diff --git a/drivers/note/Kconfig b/drivers/note/Kconfig index d9f8ebf3cb9..04e047e64f9 100644 --- a/drivers/note/Kconfig +++ b/drivers/note/Kconfig @@ -36,6 +36,19 @@ config DRIVERS_NOTECTL If this option is selected, the instrumentation filter control device /dev/notectl is provided. +config NOTE_GET_PERF_TIME + bool "Note get time config" + default y + ---help--- + If this option is selected, then note get time from perf time + +config NOTE_GET_CLOCK_TIME + bool "Note get time config" + default n + depends on !NOTE_GET_PERF_TIME + ---help--- + If this option is selected, then note get time from clock time + config DRIVERS_NOTERAM bool "Note RAM driver" default y diff --git a/drivers/note/note_driver.c b/drivers/note/note_driver.c index e4f702cf3d7..b2bcf9e0d66 100644 --- a/drivers/note/note_driver.c +++ b/drivers/note/note_driver.c @@ -217,7 +217,17 @@ static void note_common(FAR struct tcb_s *tcb, note->nc_pid = tcb->pid; } +#if defined (CONFIG_NOTE_GET_PERF_TIME) note->nc_systime = perf_gettime(); + +#elif defined (CONFIG_NOTE_GET_CLOCK_TIME) + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + note->nc_systime = ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec; + +#else + +#endif } /**************************************************************************** diff --git a/drivers/note/noteram_driver.c b/drivers/note/noteram_driver.c index 3464e5e0719..73da22fc4d2 100644 --- a/drivers/note/noteram_driver.c +++ b/drivers/note/noteram_driver.c @@ -794,7 +794,17 @@ static int noteram_dump_header(FAR struct lib_outstream_s *s, pid_t pid; int ret; + +#if defined (CONFIG_NOTE_GET_PERF_TIME) perf_convert(note->nc_systime, &ts); + +#elif defined (CONFIG_NOTE_GET_CLOCK_TIME) + ts.tv_sec = note->nc_systime / NSEC_PER_SEC; + ts.tv_nsec = note->nc_systime % NSEC_PER_SEC; + +#else +#endif + pid = note->nc_pid; #ifdef CONFIG_SMP int cpu = note->nc_cpu;