Skip to content

Commit 7211814

Browse files
ujfalusibroonie
authored andcommitted
ASoC: SOF: ipc4-pcm: Do not reset the ChainDMA if it has not been allocated
The ChainDMA operation differs from normal pipelines that it is only created when the stream started, in fact a PCM using ChainDMA has no pipelines, modules. To reset a ChainDMA, it needs to be first allocated in firmware. When PulseAudio/PipeWire starts, they will probe the PCMs by opening them, check hw_params and then close the PCM without starting audio. Unconditionally resetting the ChainDMA can result the following error: ipc tx : 0xe040000|0x0: GLB_CHAIN_DMA ipc tx reply: 0x2e000007|0x0: GLB_CHAIN_DMA FW reported error: 7 - Unsupported operation requested ipc error for msg 0xe040000|0x0 sof_pcm_stream_free: pcm_ops hw_free failed -22 Add a new chain_dma_allocated flag to sof_ipc4_pcm_stream_priv to store the ChainDMA allocation state and use this flag to skip sending the reset if the ChainDMA is not allocated. Signed-off-by: Peter Ujfalusi <[email protected]> Reviewed-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Ranjani Sridharan <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 551af32 commit 7211814

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

sound/soc/sof/ipc4-pcm.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ struct sof_ipc4_timestamp_info {
4040
/**
4141
* struct sof_ipc4_pcm_stream_priv - IPC4 specific private data
4242
* @time_info: pointer to time info struct if it is supported, otherwise NULL
43+
* @chain_dma_allocated: indicates the ChainDMA allocation state
4344
*/
4445
struct sof_ipc4_pcm_stream_priv {
4546
struct sof_ipc4_timestamp_info *time_info;
47+
48+
bool chain_dma_allocated;
4649
};
4750

4851
static inline struct sof_ipc4_timestamp_info *
@@ -269,14 +272,17 @@ sof_ipc4_update_pipeline_state(struct snd_sof_dev *sdev, int state, int cmd,
269272
*/
270273

271274
static int sof_ipc4_chain_dma_trigger(struct snd_sof_dev *sdev,
272-
int direction,
275+
struct snd_sof_pcm *spcm, int direction,
273276
struct snd_sof_pcm_stream_pipeline_list *pipeline_list,
274277
int state, int cmd)
275278
{
276279
struct sof_ipc4_fw_data *ipc4_data = sdev->private;
280+
struct sof_ipc4_pcm_stream_priv *stream_priv;
277281
bool allocate, enable, set_fifo_size;
278282
struct sof_ipc4_msg msg = {{ 0 }};
279-
int i;
283+
int ret, i;
284+
285+
stream_priv = spcm->stream[direction].private;
280286

281287
switch (state) {
282288
case SOF_IPC4_PIPE_RUNNING: /* Allocate and start chained dma */
@@ -297,6 +303,11 @@ static int sof_ipc4_chain_dma_trigger(struct snd_sof_dev *sdev,
297303
set_fifo_size = false;
298304
break;
299305
case SOF_IPC4_PIPE_RESET: /* Disable and free chained DMA. */
306+
307+
/* ChainDMA can only be reset if it has been allocated */
308+
if (!stream_priv->chain_dma_allocated)
309+
return 0;
310+
300311
allocate = false;
301312
enable = false;
302313
set_fifo_size = false;
@@ -354,7 +365,12 @@ static int sof_ipc4_chain_dma_trigger(struct snd_sof_dev *sdev,
354365
if (enable)
355366
msg.primary |= SOF_IPC4_GLB_CHAIN_DMA_ENABLE_MASK;
356367

357-
return sof_ipc_tx_message_no_reply(sdev->ipc, &msg, 0);
368+
ret = sof_ipc_tx_message_no_reply(sdev->ipc, &msg, 0);
369+
/* Update the ChainDMA allocation state */
370+
if (!ret)
371+
stream_priv->chain_dma_allocated = allocate;
372+
373+
return ret;
358374
}
359375

360376
static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
@@ -394,7 +410,7 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
394410
* trigger function that handles the rest for the substream.
395411
*/
396412
if (pipeline->use_chain_dma)
397-
return sof_ipc4_chain_dma_trigger(sdev, substream->stream,
413+
return sof_ipc4_chain_dma_trigger(sdev, spcm, substream->stream,
398414
pipeline_list, state, cmd);
399415

400416
/* allocate memory for the pipeline data */

0 commit comments

Comments
 (0)