Skip to content

Commit f2c13f5

Browse files
marc-hblgirdwood
authored andcommitted
Revert "trace: enable trace after it is ready"
This reverts commit 7df3674. This restores the ability to use CONFIG_TRACEM (copy everything to mailbox) without crashing, in other words it fixes #4699 This also fixes the other DSP panic #4676 and removes the need for logical changes in #4678, which can be reverted too. commit 7df3674 ("trace: enable trace after it is ready") was meant to fix a crash when tr_xxx() was used early. However I've used very early tracing for months and it never caused any crash (see #4334) I tried adding a tr_err() statement immediately after trace_init(sof) in primary_core_init() and it works just fine. primary_core_init() runs extremely early so I don't think it's too demanding not to use an tr_XXX() before the trace even exists. The reverted commits confused initializing and enabling. Reproduction #4683 did not seem to demonstrate anything obvious, there's not even a link to a failed test run. I don't understand how playing with spin locks is relevant to this. Later, reproduction #4759 finally demonstrated the real issue: through DEBUG_TRACE_PTR(), some tr_XXX() can indeed be called (in very unusal debug circumstances specific to the original author) before the trace is initialized. The previous commit in this series fixes that by simply guarding it with if(trace_get()) -------- I am _not_ pretending that these reverts make the tracing code bug-free and perfect again, absolutely not and very far from it. I'm merely saying that: - The first reverted commit caused at least two regressions: #4676 and #4699 - These two commits added yet another variable (time) in an already complex situation with an already existing combinatorial "explosion": compile-time Kconfigs, run-time settings, platform-specific bugs (#4333, #4573, ...), various races, mbox + DMA, different DMA engines, Zephyr vs XTOS, etc. - Last but not least, we don't want to invest in making the exist trace implementation better. We want to switch to the Zephyr implementation instead So let's go back to a previous known good state, I mean _relatively_ good and stay there if we can. Signed-off-by: Marc Herbert <marc.herbert@intel.com>
1 parent 3ff1dc0 commit f2c13f5

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/init/init.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,10 @@ static int primary_core_init(int argc, char *argv[], struct sof *sof)
134134
interrupt_init(sof);
135135
#endif /* __ZEPHYR__ */
136136

137+
#if CONFIG_TRACE
137138
trace_point(TRACE_BOOT_SYS_TRACES);
138139
trace_init(sof);
140+
#endif
139141

140142
trace_point(TRACE_BOOT_SYS_NOTIFIER);
141143
init_system_notify(sof);
@@ -149,9 +151,6 @@ static int primary_core_init(int argc, char *argv[], struct sof *sof)
149151

150152
trace_point(TRACE_BOOT_PLATFORM);
151153

152-
/* now start the trace */
153-
trace_on();
154-
155154
#if CONFIG_NO_SECONDARY_CORE_ROM
156155
lp_sram_unpack();
157156
#endif

src/trace/dma-trace.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ int dma_trace_init_complete(struct dma_trace_data *d)
200200
SOF_TASK_PRI_MED, trace_work, d, 0, 0);
201201

202202
out:
203+
203204
return ret;
204205
}
205206

src/trace/trace.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,9 @@ void trace_log_filtered(bool send_atomic, const void *log_entry, const struct tr
289289
uint64_t current_ts;
290290
#endif /* CONFIG_TRACE_FILTERING_ADAPTIVE */
291291

292-
if (!trace || !trace->enable)
292+
if (!trace->enable) {
293293
return;
294+
}
294295

295296
#if CONFIG_TRACE_FILTERING_VERBOSITY
296297
if (!trace_filter_verbosity(lvl, ctx))
@@ -510,6 +511,7 @@ void trace_off(void)
510511
void trace_init(struct sof *sof)
511512
{
512513
sof->trace = rzalloc(SOF_MEM_ZONE_SYS_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*sof->trace));
514+
sof->trace->enable = 1;
513515
sof->trace->pos = 0;
514516
#if CONFIG_TRACE_FILTERING_ADAPTIVE
515517
sof->trace->user_filter_override = false;

0 commit comments

Comments
 (0)