From 45df06018e380a41c4d38e03acb52c5eb2c21b73 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Tue, 6 Jul 2021 03:45:16 +0000 Subject: [PATCH 1/6] zephyr_ll.c: declare missing ll_tr trace context Commit a439ea93f64f ("zephyr: ll-schedule: switch over to a simplified implementation") replaced ll_schedule.c with zephyr_ll.c when compiling with Zephyr. So the struct tr_ctx named "ll_tr" is now missing. Declare it in ll_schedule.c too. No one noticed that ll_tr was missing because the DMA trace does not work in Zephyr and the main branch yet. Signed-off-by: Marc Herbert --- src/schedule/zephyr_ll.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/schedule/zephyr_ll.c b/src/schedule/zephyr_ll.c index 0c18eb8a1597..8d073602e3de 100644 --- a/src/schedule/zephyr_ll.c +++ b/src/schedule/zephyr_ll.c @@ -15,6 +15,12 @@ #include +/* 1547fe68-de0c-11eb-8461-3158a1294853 */ +DECLARE_SOF_UUID("zll-schedule", zll_sched_uuid, 0x1547fe68, 0xde0c, 0x11eb, + 0x84, 0x61, 0x31, 0x58, 0xa1, 0x29, 0x48, 0x53); + +DECLARE_TR_CTX(ll_tr, SOF_UUID(zll_sched_uuid), LOG_LEVEL_INFO); + /* per-scheduler data */ struct zephyr_ll { struct list_item tasks; /* list of ll tasks */ From a985f95a077249df47c3e0d522ec78612a3ad720 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Tue, 6 Jul 2021 04:00:12 +0000 Subject: [PATCH 2/6] cavs/platform.c: don't guard trace initialization with #ifdef ZEPHYR Because it's mostly working now and avoids macro nesting complexity; there is already #ifdef CONFIG_DW_SPI #elif CONFIG_TRACE Just for the record this is reverting a very tiny part of commit cf8e35f860a7 ("zephyr: init: create a zephyr entry point in SOF.") Signed-off-by: Marc Herbert --- src/platform/intel/cavs/platform.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/platform/intel/cavs/platform.c b/src/platform/intel/cavs/platform.c index 9f529efdd822..4356a880e150 100644 --- a/src/platform/intel/cavs/platform.c +++ b/src/platform/intel/cavs/platform.c @@ -505,7 +505,6 @@ int platform_init(struct sof *sof) if (ret < 0) return ret; -#ifndef __ZEPHYR__ #if CONFIG_DW_SPI /* initialize the SPI slave */ trace_point(TRACE_BOOT_PLATFORM_SPI); @@ -530,7 +529,7 @@ int platform_init(struct sof *sof) /* show heap status */ heap_trace_all(1); -#endif /* __ZEPHYR__ */ + return 0; } From f787e5d2694e87cc00a41344abc2c0f65a57f57e Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Tue, 6 Jul 2021 04:31:24 +0000 Subject: [PATCH 3/6] ipc3/handler.c: re-enable DMA trace for Zephyr Reverts commit 74cacc313868 ("zephyr: ipc: dont enable DMA trace transport.") modified by commit d7282762bcd1 ("ipc3: don't declare unused variables") Signed-off-by: Marc Herbert --- src/ipc/ipc3/handler.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ipc/ipc3/handler.c b/src/ipc/ipc3/handler.c index c5d1c034e7cd..30e72e91a1bf 100644 --- a/src/ipc/ipc3/handler.c +++ b/src/ipc/ipc3/handler.c @@ -729,7 +729,7 @@ static int ipc_glb_pm_message(uint32_t header) /* * Debug IPC Operations. */ -#if CONFIG_SUECREEK || defined __ZEPHYR__ +#if CONFIG_SUECREEK static int ipc_dma_trace_config(uint32_t header) { return 0; @@ -799,7 +799,7 @@ static int ipc_dma_trace_config(uint32_t header) error: return err; } -#endif /* CONFIG_SUECREEK || defined __ZEPHYR__ */ +#endif /* CONFIG_SUECREEK */ static int ipc_trace_filter_update(uint32_t header) { From 98b55c8926975d76f448dea47f72b4e389be375c Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Fri, 16 Jul 2021 07:07:17 +0000 Subject: [PATCH 4/6] trace: add 'atomic' argument to mtrace_dict_entry() Preparation to use mtrace_dict_entry() also the _log_message() level too and not just for very early mtrace_printf() tracing. Signed-off-by: Marc Herbert --- src/include/sof/trace/trace.h | 22 ++++++++++++++++------ src/trace/trace.c | 15 ++++++++++++--- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/include/sof/trace/trace.h b/src/include/sof/trace/trace.h index b8d68b0d5ce3..1d759a6bb95c 100644 --- a/src/include/sof/trace/trace.h +++ b/src/include/sof/trace/trace.h @@ -116,6 +116,7 @@ struct trace_filter { * image size. This way more elaborate log messages are possible and encouraged, * for better debugging experience, without worrying about runtime performance. */ + /* Map the different trace_xxxx_with_ids(... ) levels to the * _trace_event_with_ids(level_xxxx, ...) macro shared across log * levels. @@ -158,6 +159,20 @@ int trace_filter_update(const struct trace_filter *elem); #define _trace_event_atomic_with_ids(lvl, class, ctx, id_1, id_2, format, ...) \ _log_message(trace_log_filtered, true, lvl, class, ctx, id_1, id_2, format, ##__VA_ARGS__) +/** + * Appends one SOF dictionary entry and log statement to the ring buffer + * implementing the 'etrace' in shared memory. + * + * @param atomic_context Take the trace->lock if false. + * @param log_entry_pointer dictionary index produced by the + * _DECLARE_LOG_ENTRY macro. + * @param n_args number of va_args + */ +void mtrace_dict_entry(bool atomic_context, uint32_t log_entry_pointer, int n_args, ...); + +/** Posts a fully prepared log header + log entry */ +void mtrace_event(const char *complete_packet, uint32_t length); + /** The start of this linker output MUST match the 'ldc_entry_header' * struct defined in the logger program running in user space. */ @@ -431,16 +446,11 @@ struct tr_ctx { too_many_mtrace_printf_arguments); \ _DECLARE_LOG_ENTRY(log_level, format_str, _TRACE_INV_CLASS, \ META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__)); \ - mtrace_dict_entry((uint32_t)&log_entry, \ + mtrace_dict_entry(true, (uint32_t)&log_entry, \ META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__), \ ##__VA_ARGS__); \ } while (0) -/** Adds log_header prefix and appends arguments before sending */ -void mtrace_dict_entry(uint32_t log_entry_pointer, int n_args, ...); - -/** Posts a fully prepared log header + log entry */ -void mtrace_event(const char *complete_packet, uint32_t length); #else diff --git a/src/trace/trace.c b/src/trace/trace.c index 04d2393171de..f31fb3a1c3e8 100644 --- a/src/trace/trace.c +++ b/src/trace/trace.c @@ -532,7 +532,7 @@ void trace_init(struct sof *sof) dma_trace_init_early(sof); } -void mtrace_dict_entry(uint32_t dict_entry_address, int n_args, ...) +void mtrace_dict_entry(bool atomic_context, uint32_t dict_entry_address, int n_args, ...) { va_list ap; int i; @@ -544,9 +544,18 @@ void mtrace_dict_entry(uint32_t dict_entry_address, int n_args, ...) dict_entry_address, tstamp); va_start(ap, n_args); - for (i = 0; i < n_args; i++) + for (i = 0; i < MIN(n_args, _TRACE_EVENT_MAX_ARGUMENT_COUNT); i++) args[i] = va_arg(ap, uint32_t); va_end(ap); - mtrace_event(packet, MESSAGE_SIZE(n_args)); + if (atomic_context) { + mtrace_event(packet, MESSAGE_SIZE(n_args)); + } else { + struct trace * const trace = trace_get(); + uint32_t saved_flags; + + spin_lock_irq(&trace->lock, saved_flags); + mtrace_event(packet, MESSAGE_SIZE(n_args)); + spin_unlock_irq(&trace->lock, saved_flags); + } } From c8f178f6f62f6d876c39da7fa6bd96f47246f7fd Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Fri, 16 Jul 2021 08:00:02 +0000 Subject: [PATCH 5/6] trace: move CONFIG_TRACEM implementation up a couple levels From deep down trace.c:va_tracelog() up to the _log_message() level. Also rename va_tracelog() to the more specific dma_tracelog() Preparation to support the DMA trace in Zephyr. The only functional change in this commit is that DMA messages copied to the shared memory are not de-duplicated any more (a.k.a "adaptive rate limiting" or CONFIG_TRACE_FILTERING_ADAPTIVE). These are generally supposed to be high level hence rare enough; otherwise there is probably a "bigger problem". Signed-off-by: Marc Herbert --- src/include/sof/trace/trace.h | 28 ++++++++++--- src/trace/trace.c | 72 +++++++++++++++++----------------- test/cmocka/src/common_mocks.c | 10 ++++- 3 files changed, 67 insertions(+), 43 deletions(-) diff --git a/src/include/sof/trace/trace.h b/src/include/sof/trace/trace.h index 1d759a6bb95c..b874fafc8b2f 100644 --- a/src/include/sof/trace/trace.h +++ b/src/include/sof/trace/trace.h @@ -97,6 +97,9 @@ struct trace_filter { #if CONFIG_TRACE +#include +#include /* LOG_LEVEL_... */ + /* * trace_event macro definition * @@ -144,10 +147,13 @@ void trace_off(void); void trace_init(struct sof *sof); /* All tracing macros in this file end up calling these functions in the end. */ +typedef void (*log_func_t)(bool send_atomic, const void *log_entry, const struct tr_ctx *ctx, + uint32_t lvl, uint32_t id_1, uint32_t id_2, int arg_count, va_list args); + void trace_log_filtered(bool send_atomic, const void *log_entry, const struct tr_ctx *ctx, - uint32_t lvl, uint32_t id_1, uint32_t id_2, int arg_count, ...); + uint32_t lvl, uint32_t id_1, uint32_t id_2, int arg_count, va_list args); void trace_log_unfiltered(bool send_atomic, const void *log_entry, const struct tr_ctx *ctx, - uint32_t lvl, uint32_t id_1, uint32_t id_2, int arg_count, ...); + uint32_t lvl, uint32_t id_1, uint32_t id_2, int arg_count, va_list args); struct sof_ipc_trace_filter_elem *trace_filter_fill(struct sof_ipc_trace_filter_elem *elem, struct sof_ipc_trace_filter_elem *end, struct trace_filter *filter); @@ -198,6 +204,17 @@ void mtrace_event(const char *complete_packet, uint32_t length); format \ } +#ifdef CONFIG_TRACEM /* Send everything to shared memory too */ +# define MTRACE_DUPLICATION_LEVEL LOG_LEVEL_DEBUG +#else /* copy only ERRORS */ +# define MTRACE_DUPLICATION_LEVEL LOG_LEVEL_ERROR +#endif /* CONFIG_TRACEM */ + +/* This function is _not_ passed the format string to save space */ +void _log_sofdict(log_func_t sofdict_logf, bool atomic, const void *log_entry, + const struct tr_ctx *ctx, const uint32_t lvl, + uint32_t id_1, uint32_t id_2, int arg_count, ...); + /* _log_message() */ #ifdef CONFIG_LIBRARY @@ -237,7 +254,8 @@ _thrown_from_macro_BASE_LOG_in_trace_h /** _log_message is where the memory-saving dictionary magic described * above happens: the "format" string argument is moved to a special - * linker section and replaced by a &log_entry pointer to it. + * linker section and replaced by a &log_entry pointer to it. This must + * be a macro for the source location to be meaningful. */ #define _log_message(log_func, atomic, lvl, comp_class, ctx, id_1, id_2, format, ...) \ do { \ @@ -248,8 +266,8 @@ do { \ META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__), \ BASE_LOG_ASSERT_FAIL_MSG \ ); \ - log_func(atomic, &log_entry, ctx, lvl, id_1, id_2, \ - META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__), ##__VA_ARGS__); \ + _log_sofdict(log_func, atomic, &log_entry, ctx, lvl, id_1, id_2, \ + META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__), ##__VA_ARGS__); \ } while (0) #endif /* CONFIG_LIBRARY */ diff --git a/src/trace/trace.c b/src/trace/trace.c index f31fb3a1c3e8..4cdb11cd9843 100644 --- a/src/trace/trace.c +++ b/src/trace/trace.c @@ -222,21 +222,15 @@ static bool trace_filter_flood(uint32_t log_level, uint32_t entry, uint64_t mess /** Implementation shared and invoked by both adaptive filtering and * not. Serializes events into trace messages and passes them to - * dtrace_event() or to mtrace_event() or to both depending on the log - * lvl and the Kconfiguration. + * dtrace_event() */ -static void vatrace_log(bool send_atomic, uint32_t log_entry, const struct tr_ctx *ctx, - uint32_t lvl, uint32_t id_1, uint32_t id_2, int arg_count, va_list vargs) +static void dma_trace_log(bool send_atomic, uint32_t log_entry, const struct tr_ctx *ctx, + uint32_t lvl, uint32_t id_1, uint32_t id_2, int arg_count, va_list vargs) { uint32_t data[MESSAGE_SIZE_DWORDS(_TRACE_EVENT_MAX_ARGUMENT_COUNT)]; const int message_size = MESSAGE_SIZE(arg_count); int i; -#if CONFIG_TRACEM - unsigned long flags; - struct trace *trace = trace_get(); -#endif /* CONFIG TRACEM */ - /* fill log content. arg_count is in the dictionary. */ put_header(data, ctx->uuid_p, id_1, id_2, log_entry, platform_safe_get_time(timer_get())); @@ -250,42 +244,25 @@ static void vatrace_log(bool send_atomic, uint32_t log_entry, const struct tr_ct else dtrace_event((const char *)data, message_size); -#if CONFIG_TRACEM - /* send event by mail box too. */ - if (send_atomic) { - mtrace_event((const char *)data, MESSAGE_SIZE(arg_count)); - } else { - spin_lock_irq(&trace->lock, flags); - mtrace_event((const char *)data, MESSAGE_SIZE(arg_count)); - spin_unlock_irq(&trace->lock, flags); - } -#else - /* send event by mail box if level is LOG_LEVEL_CRITICAL. */ - if (lvl == LOG_LEVEL_CRITICAL) - mtrace_event((const char *)data, MESSAGE_SIZE(arg_count)); -#endif /* CONFIG_TRACEM */ } void trace_log_unfiltered(bool send_atomic, const void *log_entry, const struct tr_ctx *ctx, - uint32_t lvl, uint32_t id_1, uint32_t id_2, int arg_count, ...) + uint32_t lvl, uint32_t id_1, uint32_t id_2, int arg_count, va_list vl) { struct trace *trace = trace_get(); - va_list vl; if (!trace->enable) { return; } - va_start(vl, arg_count); - vatrace_log(send_atomic, (uint32_t)log_entry, ctx, lvl, id_1, id_2, arg_count, vl); - va_end(vl); + dma_trace_log(send_atomic, (uint32_t)log_entry, ctx, lvl, id_1, id_2, arg_count, vl); } void trace_log_filtered(bool send_atomic, const void *log_entry, const struct tr_ctx *ctx, - uint32_t lvl, uint32_t id_1, uint32_t id_2, int arg_count, ...) + uint32_t lvl, uint32_t id_1, uint32_t id_2, int arg_count, va_list vl) { struct trace *trace = trace_get(); - va_list vl; + #if CONFIG_TRACE_FILTERING_ADAPTIVE uint64_t current_ts; #endif /* CONFIG_TRACE_FILTERING_ADAPTIVE */ @@ -310,9 +287,7 @@ void trace_log_filtered(bool send_atomic, const void *log_entry, const struct tr } #endif /* CONFIG_TRACE_FILTERING_ADAPTIVE */ - va_start(vl, arg_count); - vatrace_log(send_atomic, (uint32_t)log_entry, ctx, lvl, id_1, id_2, arg_count, vl); - va_end(vl); + dma_trace_log(send_atomic, (uint32_t)log_entry, ctx, lvl, id_1, id_2, arg_count, vl); } struct sof_ipc_trace_filter_elem *trace_filter_fill(struct sof_ipc_trace_filter_elem *elem, @@ -532,9 +507,9 @@ void trace_init(struct sof *sof) dma_trace_init_early(sof); } -void mtrace_dict_entry(bool atomic_context, uint32_t dict_entry_address, int n_args, ...) +static void mtrace_dict_entry_vl(bool atomic_context, uint32_t dict_entry_address, + int n_args, va_list ap) { - va_list ap; int i; char packet[MESSAGE_SIZE(_TRACE_EVENT_MAX_ARGUMENT_COUNT)]; uint32_t *args = (uint32_t *)&packet[MESSAGE_SIZE(0)]; @@ -543,10 +518,8 @@ void mtrace_dict_entry(bool atomic_context, uint32_t dict_entry_address, int n_a put_header(packet, dt_tr.uuid_p, _TRACE_INV_ID, _TRACE_INV_ID, dict_entry_address, tstamp); - va_start(ap, n_args); for (i = 0; i < MIN(n_args, _TRACE_EVENT_MAX_ARGUMENT_COUNT); i++) args[i] = va_arg(ap, uint32_t); - va_end(ap); if (atomic_context) { mtrace_event(packet, MESSAGE_SIZE(n_args)); @@ -559,3 +532,28 @@ void mtrace_dict_entry(bool atomic_context, uint32_t dict_entry_address, int n_a spin_unlock_irq(&trace->lock, saved_flags); } } + +void mtrace_dict_entry(bool atomic_context, uint32_t dict_entry_address, int n_args, ...) +{ + va_list ap; + + va_start(ap, n_args); + mtrace_dict_entry_vl(atomic_context, dict_entry_address, n_args, ap); + va_end(ap); +} + +void _log_sofdict(log_func_t sofdict_logf, bool atomic, const void *log_entry, + const struct tr_ctx *ctx, const uint32_t lvl, + uint32_t id_1, uint32_t id_2, int arg_count, ...) +{ + va_list ap; + + if (lvl <= MTRACE_DUPLICATION_LEVEL) { + va_start(ap, arg_count); + mtrace_dict_entry_vl(atomic, (uint32_t)log_entry, arg_count, ap); + va_end(ap); + } + va_start(ap, arg_count); + sofdict_logf(atomic, log_entry, ctx, lvl, id_1, id_2, arg_count, ap); + va_end(ap); +} diff --git a/test/cmocka/src/common_mocks.c b/test/cmocka/src/common_mocks.c index 59ed9fce496c..a5a6626f0796 100644 --- a/test/cmocka/src/common_mocks.c +++ b/test/cmocka/src/common_mocks.c @@ -101,7 +101,8 @@ void WEAK __panic(uint32_t p, char *filename, uint32_t linenum) } void WEAK trace_log_filtered(bool send_atomic, const void *log_entry, const struct tr_ctx *ctx, - uint32_t lvl, uint32_t id_1, uint32_t id_2, int arg_count, ...) + uint32_t lvl, uint32_t id_1, uint32_t id_2, int arg_count, + va_list args) { (void) send_atomic; (void) log_entry; @@ -110,6 +111,13 @@ void WEAK trace_log_filtered(bool send_atomic, const void *log_entry, const stru (void) id_1; (void) id_2; (void) arg_count; + (void) args; +} + +void WEAK _log_sofdict(log_func_t sofdict_logf, bool atomic, const void *log_entry, + const struct tr_ctx *ctx, const uint32_t lvl, + uint32_t id_1, uint32_t id_2, int arg_count, ...) +{ } void WEAK trace_flush_dma_to_mbox(void) From 5ea6e5ba68b014913990412f69bb1bc79393050c Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Fri, 16 Jul 2021 09:25:23 +0000 Subject: [PATCH 6/6] trace: add _log_nodict() and enable DMA trace for Zephyr As of July 2021 we support (too) many tracing options and this duplication is unfortunately the only way I found to support them all while giving the compiler the opportunity to optimize away as many strings as possible. Supported configurations: - Systems with limited memory and zero space for full strings, must use SOF dictionary only. - Systems with enough space for all strings to be in memory. - Anything in between - Support to duplicate only important message to both the DMA and the mailbox (the default) - CONFIG_TRACEM: supports duplicating ALL messages to both the DMA and the mailbox - CONFIG_TRACEV: supports deleting verbose statements at compile time to save space - CONFIG_TRACE: support turning off all traces at compile-time - SOF dict trace de-duplication a.k.a. "adaptive filtering" - Dynamic log levels per component - Redirection to Zephyr's shared memory tracing that requires full strings. Signed-off-by: Marc Herbert --- src/include/sof/trace/trace.h | 25 ++++++++++++++++++++++++- src/trace/trace.c | 5 +++++ zephyr/include/sof/trace/trace.h | 20 +++++--------------- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/include/sof/trace/trace.h b/src/include/sof/trace/trace.h index b874fafc8b2f..155964698c56 100644 --- a/src/include/sof/trace/trace.h +++ b/src/include/sof/trace/trace.h @@ -205,7 +205,14 @@ void mtrace_event(const char *complete_packet, uint32_t length); } #ifdef CONFIG_TRACEM /* Send everything to shared memory too */ -# define MTRACE_DUPLICATION_LEVEL LOG_LEVEL_DEBUG +# ifdef __ZEPHYR__ +/* We don't use Zephyr's dictionary yet so there's not enough space for + * DEBUG messages + */ +# define MTRACE_DUPLICATION_LEVEL LOG_LEVEL_INFO +# else +# define MTRACE_DUPLICATION_LEVEL LOG_LEVEL_DEBUG +# endif #else /* copy only ERRORS */ # define MTRACE_DUPLICATION_LEVEL LOG_LEVEL_ERROR #endif /* CONFIG_TRACEM */ @@ -268,7 +275,23 @@ do { \ ); \ _log_sofdict(log_func, atomic, &log_entry, ctx, lvl, id_1, id_2, \ META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__), ##__VA_ARGS__); \ + _log_nodict(atomic, META_COUNT_VARAGS_BEFORE_COMPILE(__VA_ARGS__), \ + lvl, format, ##__VA_ARGS__); \ +} while (0) + +#ifdef __ZEPHYR__ +/* Just like XTOS, only the most urgent messages go to limited + * shared memory. + */ +#define _log_nodict(atomic, arg_count, lvl, format, ...) \ +do { \ + if ((lvl) <= MTRACE_DUPLICATION_LEVEL) \ + printk("%llu " format "\n", platform_timer_get(NULL), \ + ##__VA_ARGS__); \ } while (0) +#else +#define _log_nodict(atomic, n_args, lvl, format, ...) +#endif #endif /* CONFIG_LIBRARY */ diff --git a/src/trace/trace.c b/src/trace/trace.c index 4cdb11cd9843..f311d6021950 100644 --- a/src/trace/trace.c +++ b/src/trace/trace.c @@ -92,6 +92,7 @@ static void put_header(void *dst, const struct sof_uuid_entry *uid, } +#ifndef __ZEPHYR__ /** Ring buffer for the mailbox trace */ void mtrace_event(const char *data, uint32_t length) { @@ -110,6 +111,7 @@ void mtrace_event(const char *data, uint32_t length) dcache_writeback_region(t + trace->pos, length); trace->pos += length; } +#endif /* __ZEPHYR__ */ #if CONFIG_TRACE_FILTERING_VERBOSITY /** @@ -548,11 +550,14 @@ void _log_sofdict(log_func_t sofdict_logf, bool atomic, const void *log_entry, { va_list ap; +#ifndef __ZEPHYR__ /* for Zephyr see _log_nodict() in trace.h */ if (lvl <= MTRACE_DUPLICATION_LEVEL) { va_start(ap, arg_count); mtrace_dict_entry_vl(atomic, (uint32_t)log_entry, arg_count, ap); va_end(ap); } +#endif + va_start(ap, arg_count); sofdict_logf(atomic, log_entry, ctx, lvl, id_1, id_2, arg_count, ap); va_end(ap); diff --git a/zephyr/include/sof/trace/trace.h b/zephyr/include/sof/trace/trace.h index 7d24708c8845..64888cff22d6 100644 --- a/zephyr/include/sof/trace/trace.h +++ b/zephyr/include/sof/trace/trace.h @@ -25,10 +25,10 @@ struct timer; uint64_t platform_timer_get(struct timer *timer); /* - * Override SOF dictionary macros for now and let Zephyr take care of - * the physical log IO. + * Override SOF mtrace_printf() macro for now to support Zephyr's shared + * memory logger. Note the DMA trace can be copied to the shared memory + * too thanks to CONFIG_TRACEM. */ -#undef _log_message #undef mtrace_printf #if USE_PRINTK @@ -38,18 +38,8 @@ uint64_t platform_timer_get(struct timer *timer); printk("%llu: " format "\n", platform_timer_get(NULL), \ ##__VA_ARGS__); \ } while (0) -#define _log_message(log_func, atomic, level, comp_class, ctx, id1, id2, format, ...) \ - do { \ - if ((level) <= SOF_ZEPHYR_TRACE_LEVEL) \ - printk("%llu: " format "\n", platform_timer_get(NULL), \ - ##__VA_ARGS__); \ - } while (0) -#else /* not tested */ -#define _log_message(log_func, atomic, level, comp_class, ctx, id1, id2, format, ...) \ - do { \ - Z_LOG(level, "%u: " format, (uint32_t)platform_timer_get(NULL), \ - ##__VA_ARGS__); \ - } while (0) +#else +#error "TODO: Z_LOG()" #endif #endif /* __INCLUDE_TRACE__ */