-
Notifications
You must be signed in to change notification settings - Fork 350
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
Merged
Merged
DRAM debug take 2 #9907
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| { | ||
| 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.
|
||
| 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); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We really need to put all debug logic behind a
dbg_API prefix and a Kconfig to enable and disable.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 so far we don't seem to have such a consistent convention. If you grep the source tree for
dbg_you'll see a few internal uses and a few global macros in src/include/sof/debug/debug.h which don't seem to be used anywhere any more, so they can be removed. After that a consistentdbg_*namespace could be established. FWIW other files under src/debug/ don't use it either. One of the files there uses thedebug_prefixThere 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.
Lets make it consistent starting with this file. We really have to namespace APIs better.