trace: enable trace after it is ready

If the log tracing (e.g. tr_err()) is called before the trace itself is
available, the FW will crash and FW boot fail happen.

Enable the trace after it is ready, and don't try to perform tracing
when it is unavailable.

We have the empty version of trace_init/on(), so the extra "#ifdef" in
primary_core_init() is superfluous.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
This commit is contained in:
Keyon Jie 2021-08-13 13:45:39 +08:00 committed by Liam Girdwood
parent fed69b6a34
commit 7df367451d
3 changed files with 4 additions and 6 deletions

View File

@ -134,10 +134,8 @@ static int primary_core_init(int argc, char *argv[], struct sof *sof)
interrupt_init(sof); interrupt_init(sof);
#endif /* __ZEPHYR__ */ #endif /* __ZEPHYR__ */
#if CONFIG_TRACE
trace_point(TRACE_BOOT_SYS_TRACES); trace_point(TRACE_BOOT_SYS_TRACES);
trace_init(sof); trace_init(sof);
#endif
trace_point(TRACE_BOOT_SYS_NOTIFIER); trace_point(TRACE_BOOT_SYS_NOTIFIER);
init_system_notify(sof); init_system_notify(sof);
@ -151,6 +149,9 @@ static int primary_core_init(int argc, char *argv[], struct sof *sof)
trace_point(TRACE_BOOT_PLATFORM); trace_point(TRACE_BOOT_PLATFORM);
/* now start the trace */
trace_on();
#if CONFIG_NO_SECONDARY_CORE_ROM #if CONFIG_NO_SECONDARY_CORE_ROM
lp_sram_unpack(); lp_sram_unpack();
#endif #endif

View File

@ -200,7 +200,6 @@ int dma_trace_init_complete(struct dma_trace_data *d)
SOF_TASK_PRI_MED, trace_work, d, 0, 0); SOF_TASK_PRI_MED, trace_work, d, 0, 0);
out: out:
return ret; return ret;
} }

View File

@ -290,9 +290,8 @@ void trace_log_filtered(bool send_atomic, const void *log_entry, const struct tr
uint64_t current_ts; uint64_t current_ts;
#endif /* CONFIG_TRACE_FILTERING_ADAPTIVE */ #endif /* CONFIG_TRACE_FILTERING_ADAPTIVE */
if (!trace->enable) { if (!trace || !trace->enable)
return; return;
}
#if CONFIG_TRACE_FILTERING_VERBOSITY #if CONFIG_TRACE_FILTERING_VERBOSITY
if (!trace_filter_verbosity(lvl, ctx)) if (!trace_filter_verbosity(lvl, ctx))
@ -512,7 +511,6 @@ void trace_off(void)
void trace_init(struct sof *sof) void trace_init(struct sof *sof)
{ {
sof->trace = rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*sof->trace)); sof->trace = rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*sof->trace));
sof->trace->enable = 1;
sof->trace->pos = 0; sof->trace->pos = 0;
#if CONFIG_TRACE_FILTERING_ADAPTIVE #if CONFIG_TRACE_FILTERING_ADAPTIVE
sof->trace->user_filter_override = false; sof->trace->user_filter_override = false;