-
Notifications
You must be signed in to change notification settings - Fork 140
ASoC: SOF: ipc4-pcm: do not report invalid delay values #5513
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
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 |
|---|---|---|
|
|
@@ -59,6 +59,8 @@ struct sof_ipc4_pcm_stream_priv { | |
| */ | ||
| #define DELAY_BOUNDARY U32_MAX | ||
|
|
||
| #define DELAY_MAX (DELAY_BOUNDARY >> 1) | ||
|
|
||
| static inline struct sof_ipc4_timestamp_info * | ||
| sof_ipc4_sps_to_time_info(struct snd_sof_pcm_stream *sps) | ||
| { | ||
|
|
@@ -1266,6 +1268,12 @@ static int sof_ipc4_pcm_pointer(struct snd_soc_component *component, | |
| else | ||
| time_info->delay = head_cnt - tail_cnt; | ||
|
|
||
| if (time_info->delay > DELAY_MAX) { | ||
|
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. when this happens it is because the dai ptr counter overtook the host pointer, which indicates incorrect start offset and a rare race when the dai / host DMA burst happens just a bit out of sync (or the pointer report) and things flop.
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. Ack @ujfalusi . I think this is just a safety-valve against trusting the FW too much. If this is hit, it's an issue we would have to go and hunt for these cases and fix them one by one, but without an error printed, these are difficult to catch. One option is to just leave this out-of-tree as a debugging patch. But if these do happen on end-user systems, letting clearly invalid delay values through will cause pretty major issues (e.g. video playback not working), so I'm leaning towards having a safety check built in. |
||
| dev_dbg_ratelimited(sdev->dev, | ||
| "inaccurate delay, host %llu dai_cnt %llu", host_cnt, dai_cnt); | ||
| time_info->delay = 0; | ||
| } | ||
|
|
||
| /* | ||
| * Convert the host byte counter to PCM pointer which wraps in buffer | ||
| * and it is in frames | ||
|
|
||
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 did consider multiple options:
... so went with BOUNDARY/2 in the end. This will primarily cover cases where the DSP pointers have gone out-of-sync (e.g. we had bugs with handling xruns and pauses in the past) and continuously report delay values close to DELAY_BOUNDARY