Repository navigation
Fixes for xrun recovery and Soundwire node_id - #4829
Conversation
|
CI is not happy with this yet. |
@ujfalusi no it was a different issue that broke all PRs. It was fixed |
|
SOFCI TEST |
| snd_sof_pcm_platform_trigger(sdev, substream, cmd); | ||
| if (pcm_ops && pcm_ops->platform_stop_during_hw_free && | ||
| cmd == SNDRV_PCM_TRIGGER_STOP) | ||
| spcm->stream_stopped[substream->stream] = true; |
There was a problem hiding this comment.
a comment would really help here..
we set the stream_stopped flag to true when we have not stopped the stream?
There was a problem hiding this comment.
as far as ALSA is concerned the stream is stopped. The pipeline may not be stopped yet but thats different and thats what we need to handle when stream_stopped is set
There was a problem hiding this comment.
@ranj063, sure, as far as ALSA concerned the stream is stopped, but we are flagging a stream as stopped when we are not stopping it and we don't mark the stream as stopped when we did stopped it.
The flag is more like an indication that if a prepare is coming after this trigger (instead of close and free) we need to stop the stream and start it again - to really stop it as it should have been.
But why we cannot just stop it here?
There was a problem hiding this comment.
stopping pipelines here would be in theory the right thing to do but in order to keep the changes less invasive, we decided to keep the existing sequence. We can revisit this later if this needs to change
| if (spcm->prepared[substream->stream]) | ||
| return 0; | ||
| if (spcm->prepared[substream->stream]) { | ||
| if (!spcm->stream_stopped[substream->stream]) |
There was a problem hiding this comment.
can you re-use the pcm_ops->platform_stop_during_hw_free for the same result here?
I think the prepare is not called between SNDRV_PCM_TRIGGER_PAUSE_PUSH and SNDRV_PCM_TRIGGER_PAUSE_RELEASE, so if we are here when the spcm->prepared flag is true then we know that the stream needs to be freed.
Or rename the flag to be easier to relate to it's meaning?
There was a problem hiding this comment.
no @ujfalusi thats not true. In the regular start case also, the stream will be prepared and nothing needs to be done in that case. We can't really reuse platform_stop_during_hw_free either. We really need to know if the stream was stopped when the prepare gets called.
There was a problem hiding this comment.
in a regular case the prepared flag would not be set (I'm mostly sure about this as we need to run the rest of the function), no?
There was a problem hiding this comment.
no it will be set in the hw_params callback in the regular case as well
Yes, the xrun fixes will break SDW, so they need to go together |
| snd_sof_pcm_platform_trigger(sdev, substream, cmd); | ||
| if (pcm_ops && pcm_ops->platform_stop_during_hw_free && | ||
| cmd == SNDRV_PCM_TRIGGER_STOP) | ||
| spcm->stream_stopped[substream->stream] = true; |
There was a problem hiding this comment.
@ranj063, sure, as far as ALSA concerned the stream is stopped, but we are flagging a stream as stopped when we are not stopping it and we don't mark the stream as stopped when we did stopped it.
The flag is more like an indication that if a prepare is coming after this trigger (instead of close and free) we need to stop the stream and start it again - to really stop it as it should have been.
But why we cannot just stop it here?
| struct list_head list; /* list in sdev pcm list */ | ||
| struct snd_pcm_hw_params params[2]; | ||
| bool prepared[2]; /* PCM_PARAMS set successfully */ | ||
| bool stream_stopped[2]; /* only used if (!pcm_ops->platform_stop_during_hw_free) */ |
There was a problem hiding this comment.
based on the code it is only used if (pcm_ops->platform_stop_during_hw_free)
There was a problem hiding this comment.
Can we rename this flag to stream_restart_needed or trigger_stop_pending or something else?
We really set this flag when we don't stop the stream and we use it as an indication that the stream was not stopped to stop it in prepare (when hw_params() is skipped).
| if (spcm->prepared[substream->stream]) | ||
| return 0; | ||
| if (spcm->prepared[substream->stream]) { | ||
| if (!spcm->stream_stopped[substream->stream]) |
There was a problem hiding this comment.
in a regular case the prepared flag would not be set (I'm mostly sure about this as we need to run the rest of the function), no?
| default: | ||
| spcm->stream_stopped[substream->stream] = false; | ||
| break; | ||
| } |
There was a problem hiding this comment.
Just unconditionally clear the flag?
There was a problem hiding this comment.
or handle the flag in one place:
/*
* The stream is not stopped in case of platform_stop_during_hw_free == true
* During consequent prepare callback it will be needed to be stopped before
* starting the stream again (part of xrun handling)
*/
if (cmd == SNDRV_PCM_TRIGGER_STOP && pcm_ops &&
pcm_ops->platform_stop_during_hw_free)
spcm->trigger_stop_pending[substream->stream] = true;
else
spcm->trigger_stop_pending[substream->stream] = false;
but after the second switch() section?
| struct list_head list; /* list in sdev pcm list */ | ||
| struct snd_pcm_hw_params params[2]; | ||
| bool prepared[2]; /* PCM_PARAMS set successfully */ | ||
| bool stream_stopped[2]; /* only used if (!pcm_ops->platform_stop_during_hw_free) */ |
There was a problem hiding this comment.
Can we rename this flag to stream_restart_needed or trigger_stop_pending or something else?
We really set this flag when we don't stop the stream and we use it as an indication that the stream was not stopped to stop it in prepare (when hw_params() is skipped).
b5587ba to
df4a7a5
Compare
Add the intel_free_stream() callback to deal with the change in IPC that requires additional steps to be done to clear the gateway node_id. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
To allow using widget_to_sdev() in other files, move it as static inline in shared header file. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
When an xrun happens, the BE DAI hw_params doesn't get invoked before the stream restarts with a prepare. In this case, clearing the node ID when the DAI widget is freed and unprepared will result in an error when it is re-initialized. In order to avoid this, move the code to clear the node ID to the BE DAI hw_free op to keep it balanced with the BE DAI hw_params. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
…d logs For some reason the existing code stops on the first error, which potentially leaves the DMA and widgets in a weird state. Change to free-up all resources even in case of errors. Also add a more consistent error handling and logs, with the first error code returned to the caller. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
The same sequence is used twice, use common helper. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Add a state variable to keep track of delayed stops, in case pcm_ops->platform_stop_during_hw_free is set. This patch should be iso-functionality, possibly removing no-op cases. The main purpose of this new state variable is to prepare a follow-up patch to reset all PCM and DMAs in case of stop/prepare xrun sequences. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
With the delayed stops, the xrun handling is problematic: the applications expects everything to be reset but the firmware and DMA are still in a PAUSED state. This patch makes sure the prepare while pending_stop is set is special-cased. Co-developed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
The node_id for multi-gateway ALH DAI's get overwritten with the group_id during the DAI copier's ipc_prepare op. So, save the ALH dai_index during the BE DAI hw_params in the dai_index field of struct ipc4_copier and use that to set the device ID in the configuration blob. This will avoid errors during copier init after an xrun. Note that the dai_index is typically set in topology for DMIC/SSP, but it's not used for ALH. Reclaiming this dai_index field to store the node_id does not generate a conflict with topology-defined values. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
|
@ranj063 let's merge this after CI results. Not sure we can upstream this in the current kernel cycle though, we are now at -rc7 |
|
results look ok, merging |
Replacement for #4816