-
Notifications
You must be signed in to change notification settings - Fork 300
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
dai: fix xrun handling #7044
dai: fix xrun handling #7044
Conversation
830837f
to
dcb70d1
Compare
dcb70d1
to
8c2e99f
Compare
dw dma driver also reports -EPIPE when it detect xrun (https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/dma/dma_dw_common.c#L804). Shouldn't we call dai_report_xrun for this driver? In my opinion, in default case should be a general status read error handling, not xrun handling. |
Similar PR: #6965 |
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.
Some comments inline, added @juimonen to review.
src/audio/dai-zephyr.c
Outdated
comp_warn(dev, "dai_copy(): dma_get_status() overrun occurred, ret = %u", | ||
ret); | ||
break; | ||
default: | ||
dai_report_xrun(dev, 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.
Hmm, something is still off here. It doesn't make sense to not call "dai_report_xrun()" when "-EPIPE" is returned.
I was looking at the old non-Zephyr driver sof/src/drivers/intel/hda/hda-dma.c:hda_dma_data_size() is checking for overrun/underrun exactly the same way as the new Zephyr driver (checking DGCS_BUR and DGCS_BOR).
And in dai-lecy.c:dai_copy(), the logic is similar. dma_get_data_size_legacy() is called and if xrun is detected, an error is reported.
And with this stack, tests are passing. So I think we need to understand why the difference 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.
@kv2019i IIRC calling dai_report_xrun(dev, 0);
would cause the XRUN handler on SOF Linux driver to run (and stop/restart the stream) ? Should this not be something to enable/disable (default) at runtime ?
@makarup @softwarecki I think I now understand why we have native dai-zephyr.c. If I run test to a non-connected HDMI PCM node, with non-native HD-DMA driver I get:
With native Zephyr driver I get:
So in both cases the xrun is observed (makes sense as display side is not connected in this case), but in non-native case the pipeline is not stopped. Took a while but then a realized hda_dma_link_check_xrun() in the old src/drivers/intel/hda/hda-dma.c I traced this back to this old commit from 2020:
The Linux stack is still depending on this behaviour (the Linux audio servers open all the PCM nodes and for the HDMI nodes, the expectation is that PCM streaming can be started without an error even if no display is connected at the time). So I think we need to modify xrun handling so that for the HDA link, we just log a warning, but do not stop the pipeline. Other xrun handling should be as before. |
@kv2019i @softwarecki I see that in legacy it was only warning for hda but error for dw_dma. Maybe in cases different than standard xrun resulting from delay it should be reported as an error. What do you think ? |
@makarukp Ack, I can confirm that. With non-native DW-DMA driver, xruns are reported and will stop the pipe. So this special handling is only for the HD-DMA link DMA. Now for Linux, we do need to keep the special handling, and the move of drivers to Zephyr does pose a new challenge how to maintain. Hmm, maybe we put the xrun-raises-an-error logic behind a Kconfig option and otherwise just emit a warning to FW log...? |
8c2e99f
to
3f2bbe8
Compare
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.
Just some minor comments
src/audio/dai-zephyr.c
Outdated
/* DMA status can return -EPIPE and current status content if xrun occurs */ | ||
if (ret == -EPIPE) | ||
#if XRUN_RAISES_AN_ERROR | ||
dai_report_xrun(dev, 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.
and this will eventually call the IPC3/4 version of the notification in subsequent PRs.
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.
no action needed here, btw, just making an observation.
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.
It would be good to enclose the contents of if in {}. We have several levels of if that depends on #if. It's easy to make a mistake.
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.
Hmm. @makarukp @softwarecki @lgirdwood I wonder if we should start by just making the xrun handling here emit warnings and not call dai_report_xrun() yet. That would allow to unblock Zephyr upstream updated.
The CONFIG_NOTIFY_HOST_ON_XRUN is very misleading as no notifies are sent to host in current code. What dai_report_xrun() is to escalate the problem to pipeline level, which will try to restart the pipeline. There is also another layer of conditional logic after dai_report_xrun(). E.g. "NO_XRUN_RECOVERY" option in src/audio/pipeline/pipeline-xrun.c at the pipeline level.
So seems more time is needed to sort out how we introduce the IPC4 notification mechanisms (which are new) and how we tackle the problem that HDA link xruns happen in common use-cases and in the past we have ignored them.
We still have xrun logic at the pipeline level driven by buffering status, so it's not like we are disabling xrun handling completely.
7c26530
to
2f9e198
Compare
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 propose we simplify even further and just emit warnings and do not call dai_xrun_report() yet. There seems to be more opens (see inline).
src/audio/dai-zephyr.c
Outdated
/* DMA status can return -EPIPE and current status content if xrun occurs */ | ||
if (ret == -EPIPE) | ||
#if XRUN_RAISES_AN_ERROR | ||
dai_report_xrun(dev, 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.
Hmm. @makarukp @softwarecki @lgirdwood I wonder if we should start by just making the xrun handling here emit warnings and not call dai_report_xrun() yet. That would allow to unblock Zephyr upstream updated.
The CONFIG_NOTIFY_HOST_ON_XRUN is very misleading as no notifies are sent to host in current code. What dai_report_xrun() is to escalate the problem to pipeline level, which will try to restart the pipeline. There is also another layer of conditional logic after dai_report_xrun(). E.g. "NO_XRUN_RECOVERY" option in src/audio/pipeline/pipeline-xrun.c at the pipeline level.
So seems more time is needed to sort out how we introduce the IPC4 notification mechanisms (which are new) and how we tackle the problem that HDA link xruns happen in common use-cases and in the past we have ignored them.
We still have xrun logic at the pipeline level driven by buffering status, so it's not like we are disabling xrun handling completely.
Fine by me. |
src/audio/dai-zephyr.c
Outdated
"ret = %u", ret); | ||
else | ||
comp_warn(dev, "dai_copy(): dma_get_status() overrun occurred, " | ||
"ret = %u", ret); |
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 you need braces here. GCC used to complain about constructs like
if (a)
if (b)
do_x();
else
do_y();
because of the potential ambiguity of the else
(this ain't no python). This probably wasn't compiled with CONFIG_NOTIFY_HOST_ON_XRUN
disabled
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 with the fix now, but if you are refreshing, a few style comments to the Kconfig option to make it more understandable.
src/audio/Kconfig
Outdated
help | ||
Select for handling DMA xruns and reporting them as errors. | ||
Otherwise, only warnings are emitted. | ||
|
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 won't block on this, but if we have the Kconfig, I'd do:
- put it at the end of audio/Kconfig after WRAP_ACTUAL_POSITION (now it's in middle of SRC related options)
- name it DAI_REPORT_XRUNS
- description: "Report DAI overrun/underruns to pipeline"
This would better reflect what this does.
|
27b1f4c
to
ade5593
Compare
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.
@makarukp You have unrelated rimage changes in the updated commit.
Otherwise looks good to go, thanks!
ade5593
to
2a2c213
Compare
@makarukp can you check the CI. Thanks ! |
2a2c213
to
c9722df
Compare
c9722df
to
0ab49b0
Compare
comment addressed. Since I personally haven't followed closely the decision to remove xrun reporting completely in that case, I won't explicitly approve, but just remove my request for change
@makarukp can you check CI, thanks ! |
@wszypelt This one seems to have hit unexpected errors as well. |
0ab49b0
to
1de9083
Compare
dai copy should continue with flow if status returns xrun warning Signed-off-by: Piotr Makaruk <piotr.makaruk@intel.com>
1de9083
to
485bd6d
Compare
dai copy shuld continue flow if status return xrun warning
Signed-off-by: Piotr Makaruk piotr.makaruk@intel.com