int (*hw_free)(struct snd_pcm_substream *substream);
        int (*prepare)(struct snd_pcm_substream *substream);
        int (*trigger)(struct snd_pcm_substream *substream, int cmd);
+       int (*sync_stop)(struct snd_pcm_substream *substream);
        snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *substream);
        int (*get_time_info)(struct snd_pcm_substream *substream,
                        struct timespec *system_ts, struct timespec *audio_ts,
        wait_queue_head_t sleep;        /* poll sleep */
        wait_queue_head_t tsleep;       /* transfer sleep */
        struct fasync_struct *fasync;
+       bool stop_operating;            /* sync_stop will be called */
 
        /* -- private section -- */
        void *private_data;
 
 #endif
 }
 
+static void snd_pcm_sync_stop(struct snd_pcm_substream *substream)
+{
+       if (substream->runtime->stop_operating) {
+               substream->runtime->stop_operating = false;
+               if (substream->ops->sync_stop)
+                       substream->ops->sync_stop(substream);
+       }
+}
+
 /**
  * snd_pcm_hw_param_choose - choose a configuration defined by @params
  * @pcm: PCM instance
                if (atomic_read(&substream->mmap_count))
                        return -EBADFD;
 
+       snd_pcm_sync_stop(substream);
+
        params->rmask = ~0U;
        err = snd_pcm_hw_refine(substream, params);
        if (err < 0)
        snd_pcm_stream_unlock_irq(substream);
        if (atomic_read(&substream->mmap_count))
                return -EBADFD;
+       snd_pcm_sync_stop(substream);
        if (substream->ops->hw_free)
                result = substream->ops->hw_free(substream);
        if (substream->managed_buffer_alloc)
                runtime->status->state = state;
                snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSTOP);
        }
+       runtime->stop_operating = true;
        wake_up(&runtime->sleep);
        wake_up(&runtime->tsleep);
 }
        snd_pcm_trigger_tstamp(substream);
        runtime->status->state = runtime->status->suspended_state;
        snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MRESUME);
+       snd_pcm_sync_stop(substream);
 }
 
 static const struct action_ops snd_pcm_action_resume = {
 static int snd_pcm_do_prepare(struct snd_pcm_substream *substream, int state)
 {
        int err;
+       snd_pcm_sync_stop(substream);
        err = substream->ops->prepare(substream);
        if (err < 0)
                return err;