Skip to content

[RFC] ASoC: SOF: add XRUN info delivering to ALSA - #479

Closed
keyonjie wants to merge 2 commits into
thesofproject:topic/sof-devfrom
keyonjie:pr-tmp
Closed

keyonjie wants to merge 2 commits into
thesofproject:topic/sof-devfrom
keyonjie:pr-tmp

Conversation

@keyonjie

Copy link
Copy Markdown

If we get XRUN IPC from firmware, let's deliver it to ALSA and ALSA
may be able to trigger stop->prepare->start later.

Signed-off-by: Keyon Jie yang.jie@linux.intel.com

@plbossart plbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't fully understand the intent of this patch, see comments below.

Comment thread sound/soc/sof/pcm.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this is done here, before pcm_pointer callback? Shouldn't this be done once all the information is reported, i.e. below line 350 (with the return removed).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have only one return value(position) with .pointer() callback, I aimed to report/return SNDRV_PCM_POS_XRUN once XRUN happened, which will let ALSA trigger stop->prepare->start later.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, I was talking about the second part of the code below

	/* return Xrun to ALSA for further handling */
	if (spcm->stream[substream->stream].posn.xrun_size) {
		/* only report once for each XRUN IPC */
		spcm->stream[substream->stream].posn.xrun_size = 0;
		return SNDRV_PCM_POS_XRUN;
	}

	/* if have dsp ops pointer callback, use that directly */
	if (sdev->ops->pcm_pointer)
		return sdev->ops->pcm_pointer(sdev, substream);

You return before calling pcm_pointer, is this desired/intentional or a bug?

Comment thread sound/soc/sof/ipc.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I get what the meaning of this Kconfig is now, if we don't actually stop? Why wouldn't the Xrun info be passed in ALL cases?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know your point here, Pierre. I planed to change the Kconfig in the coming PR(e.g. from CONFIG_SND_SOC_SOF_DEBUG_XRUN_STOP to CONFIG_SND_SOC_SOF_DEBUG_XRUN_REPORT).

So my intention here is:

  1. if SOF_DEBUG_XRUN_REPORT is unselected (by default), we don't report this Xrun reported from FW to ALSA, just report the normal position info. If the Xrun is not recovered successfully by FW itself, this Xrun will be accumulated and then ALSA will find actually Xrun and trigger stop->prepare->start at that time.
  2. if SOF_DEBUG_XRUN_REPORT is selected, we will trust Xrun reported from FW(we think/align on that FW report this to us and request driver to do something on that) to ALSA immediately, and ALSA will start triggering stop->prepare->start soon. According to when FW will report XRUN, it is implemented in and controlled by FW side totally.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't get any of the explanations. I thought we agreed that the firmware does not try to be smart and does not try to recover on its own?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are not aligned on that yet, the smart recovery inside FW are still running on today's SOF FW.

@keyonjie

Copy link
Copy Markdown
Author

@plbossart PR updated with Kconfig item naming changed.

If we get XRUN IPC from firmware, let's deliver it to ALSA and ALSA
may be able to trigger stop->prepare->start later.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
We are not really stop PCM on XRUN event, but we can select to report
XRUN event from FW to ALSA, and let ALSA possible to trigger
stop->prepare->start earlier, here change the kconfig item naming from
CONFIG_SND_SOC_SOF_DEBUG_XRUN_STOP to
CONFIG_SND_SOC_SOF_DEBUG_XRUN_REPORT to reflect the real XRUN handling.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>

@plbossart plbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this patch is not aligned with my understanding of how the firmware and drivers should behave. I don't see the point of deferring the reaction on an x-run.

Comment thread sound/soc/sof/pcm.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, I was talking about the second part of the code below

	/* return Xrun to ALSA for further handling */
	if (spcm->stream[substream->stream].posn.xrun_size) {
		/* only report once for each XRUN IPC */
		spcm->stream[substream->stream].posn.xrun_size = 0;
		return SNDRV_PCM_POS_XRUN;
	}

	/* if have dsp ops pointer callback, use that directly */
	if (sdev->ops->pcm_pointer)
		return sdev->ops->pcm_pointer(sdev, substream);

You return before calling pcm_pointer, is this desired/intentional or a bug?

Comment thread sound/soc/sof/ipc.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't get any of the explanations. I thought we agreed that the firmware does not try to be smart and does not try to recover on its own?

Comment thread sound/soc/sof/Kconfig
If we don't report this XRUN event, ALSA will still observe XRUN
later when .pointer() callback has no update for some time, usually
that may lead to later and lower frequecy ALSA XRUN response.
Say Y if you are debugging SOF FW pipeline XRUNs handling.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also don't get the intent here. Why just not always stop on an underrun? What are we trying to do with the deferred report?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the the snd_pcm_stop_xrun() don't really stop the pipeline thoroughly for us, so the config item CONFIG_SND_SOC_SOF_DEBUG_XRUN_STOP here looks confusing.

What I am doing here is try to remove that and add a new config item for Xrun report.

@keyonjie keyonjie changed the title ASoC: SOF: add XRUN info delivering to ALSA [RFC] ASoC: SOF: add XRUN info delivering to ALSA Dec 29, 2018
@keyonjie

Copy link
Copy Markdown
Author

@plbossart sorry, please hold on merging this, I might need more experiment on it before finalize it, and we need finalize the FW behavior before that also.

@mengdonglin mengdonglin added P1 Blocker bugs or important features upstream blocker Mandatory for upstream enhancement New feature or request and removed P1 Blocker bugs or important features enhancement New feature or request labels Jan 7, 2019
@keyonjie

keyonjie commented Jan 11, 2019 •

Copy link
Copy Markdown
Author

I have figured out fixes for driver recover FW initiated Xrun issue and verified they work fine.
Most fixes are come from FW side, driver side might need only IPC ABI bump, so closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

upstream blocker Mandatory for upstream

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants