dev_dbg(component->dev, "pcm: trigger stream %d dir %d cmd %d\n",
                spcm->pcm.pcm_id, substream->stream, cmd);
 
+       spcm->pending_stop[substream->stream] = false;
+
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
                ipc_first = true;
                /* invoke platform trigger to stop DMA even if pcm_ops isn't set or if it failed */
                if (!pcm_ops || !pcm_ops->platform_stop_during_hw_free)
                        snd_sof_pcm_platform_trigger(sdev, substream, cmd);
+
+               /*
+                * set the pending_stop flag to indicate that pipeline stop has been delayed.
+                * This will be used later to stop the pipelines during prepare when recovering
+                * from xruns.
+                */
+               if (pcm_ops && pcm_ops->platform_stop_during_hw_free &&
+                   cmd == SNDRV_PCM_TRIGGER_STOP)
+                       spcm->pending_stop[substream->stream] = true;
                break;
        default:
                break;
 
        struct list_head list;  /* list in sdev pcm list */
        struct snd_pcm_hw_params params[2];
        bool prepared[2]; /* PCM_PARAMS set successfully */
+       bool pending_stop[2]; /* only used if (!pcm_ops->platform_stop_during_hw_free) */
 };
 
 struct snd_sof_led_control {