forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 142
ASoC: SOF: ipc4-mtrace: resync host_read_ptr on debugfs open #5690
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
Open
majunkier
wants to merge
2
commits into
thesofproject:topic/sof-dev
Choose a base branch
from
majunkier:check_sof_logger
base: topic/sof-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
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
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.
The commit message also needs update.
But something is not quite right in the description. The dsp_write_ptr is updated for the NOTIFY_LOG_BUFFER_STATUS in sof_ipc4_mtrace_update_pos(), it is done regardless if reader is active or not, but if there is one active then it is woken up to read out the data.
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.
you right i will fix msg
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.
out of curiosity, can you debug this a bit further?
read the write and read ptr from the slot and then compare it with the ptr value tracked in core_data and if they differ print them out.
Something is not adding up here.
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.
ok, i added debug (added as a part of this PR temporary), which reveal other issue:
output catch
core0 ptr mismatch: slot r/w 0xffffffff/0xfffffffc vs cached r/w 0x0/0xfffffffcslot_read_ptr = 0xffffffffuninitialized SRAMslot_write_ptr = 0xfffffffcsynchronizedcached host_read_ptr = 0x0kernel memoryIn sof_ipc4_mtrace_dfs_open() kernel initializes core_data->host_read_ptr = 0 in local memory but never write value to SRAM, first SRAM write is in sof_ipc4_mtrace_dfs_read() after consuming data.
so problem looks like desync kernel and dsp.
kernel core_data->host_read_ptr = 0
SRAM slot[offset+0] = 0xffffffff
DSP reads from SRAM slot_read_ptr = 0xffffffff
DSP calculates free_space = (0xffffffff - 0xfffffffc - 1) = 2 bytes
DSP thinks buffer is full so posibility of dropped logs
possible solution : Write cached 0x0 value to SRAM in sof_ipc4_mtrace_dfs_open()
@ujfalusi could you take a look if i understand it correctly ?
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.
looks like the fw is not initializing the slot at init, so both host_ptr and dsp_ptr is 0xffffffff and it is using these in mtrace_out [1]
As I recall when the mtrace feature was added, the fw did a reset of the ptrs on init.
[1] https://github.com/zephyrproject-rtos/zephyr/blob/main/subsys/logging/backends/log_backend_adsp_mtrace.c#L107
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.
@majunkier, @kv2019i, this diff in zephyr makes for a huge difference with unpatched kernel mtrace code!
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.
like this on fw boot on TGL with mtrace-reader open:
and when mtrace-reader started way after the DSP boot:
I think the fix is in zephyr...
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.
zephyrproject-rtos/zephyr#105357