-
Notifications
You must be signed in to change notification settings - Fork 349
DRAM debug take 2 #9907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DRAM debug take 2 #9907
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
| // | ||
| // Copyright(c) 2025 Intel Corporation. | ||
|
|
||
| #include <rtos/kernel.h> | ||
| #include <rtos/symbol.h> | ||
| #include <zephyr/logging/log.h> | ||
| #include <zephyr/sys/__assert.h> | ||
|
|
||
| LOG_MODULE_REGISTER(dram_debug, CONFIG_SOF_LOG_LEVEL); | ||
|
|
||
| static struct k_spinlock hot_path_lock; | ||
| static unsigned int hot_path_depth; | ||
| static const char *cold_path_fn; | ||
| static bool hot_path_confirmed; | ||
|
|
||
| void mem_cold_path_enter(const char *fn) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We really need to put all debug logic behind a
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lgirdwood so far we don't seem to have such a consistent convention. If you grep the source tree for
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets make it consistent starting with this file. We really have to namespace APIs better. |
||
| { | ||
| k_spinlock_key_t key = k_spin_lock(&hot_path_lock); | ||
|
|
||
| cold_path_fn = fn; | ||
|
|
||
| k_spin_unlock(&hot_path_lock, key); | ||
| } | ||
| EXPORT_SYMBOL(mem_cold_path_enter); | ||
|
|
||
| void mem_hot_path_start_watching(void) | ||
| { | ||
| k_spinlock_key_t key = k_spin_lock(&hot_path_lock); | ||
|
|
||
| if (!hot_path_depth++) { | ||
jsarha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| cold_path_fn = NULL; | ||
| hot_path_confirmed = false; | ||
| } | ||
|
|
||
| k_spin_unlock(&hot_path_lock, key); | ||
| } | ||
|
|
||
| void mem_hot_path_confirm(void) | ||
| { | ||
| k_spinlock_key_t key = k_spin_lock(&hot_path_lock); | ||
|
|
||
| hot_path_confirmed = true; | ||
|
|
||
| k_spin_unlock(&hot_path_lock, key); | ||
| } | ||
|
|
||
| void mem_hot_path_stop_watching(void) | ||
| { | ||
| bool underrun, error; | ||
| k_spinlock_key_t key = k_spin_lock(&hot_path_lock); | ||
|
|
||
| if (hot_path_depth) { | ||
| underrun = false; | ||
| hot_path_depth--; | ||
| error = hot_path_confirmed && cold_path_fn; | ||
| } else { | ||
| error = underrun = true; | ||
| } | ||
|
|
||
| k_spin_unlock(&hot_path_lock, key); | ||
|
|
||
| if (underrun) | ||
| LOG_ERR("Hot path depth underrun!"); | ||
| else | ||
| __ASSERT(!error, "Cold function %s() has run while on hot path!", cold_path_fn); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| # Common to Zephyr and XTOS | ||
| add_local_sources(sof | ||
| gdb.c | ||
| ringbuffer.c | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -477,6 +477,15 @@ int ipc4_pipeline_trigger(struct ipc_comp_dev *ppl_icd, uint32_t cmd, bool *dela | |
| return IPC4_INVALID_REQUEST; | ||
| } | ||
|
|
||
| /* | ||
| * We're handling a pipeline-trigger event, this means that we're in a | ||
| * performance-critical context. Set a marker, so that if any cold code, | ||
| * calling assert_can_be_cold() is called on this flow between the | ||
| * mem_hot_path_start_watching() - mem_hot_path_stop_watching() | ||
| * brackets, the latter will generate an error / trigger a panic. | ||
| */ | ||
| mem_hot_path_confirm(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be an excellent place to add a comment why this is considered a hot-path. |
||
|
|
||
| /* trigger the component */ | ||
| ret = pipeline_trigger(host->cd->pipeline, host->cd, cmd); | ||
| if (ret < 0) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @kv2019i has improved this check now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could stay just with assert_can_be_cold to not overcomplicate dram things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lgirdwood don't think so, we plan to do this globally but I don't think this has been changed yet, I still see this in "main"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abonislawski that part doesn't change. That's remains the only check that we add to
__coldfunctions. But inside that function it now performs 2 checks: (1) for LL-context, and (2) for any "critical path" violations