ALSA: pcm: Assure sync with the pending stop operation at suspend
authorTakashi Iwai <tiwai@suse.de>
Sat, 6 Feb 2021 20:36:54 +0000 (21:36 +0100)
committerTakashi Iwai <tiwai@suse.de>
Mon, 8 Feb 2021 15:00:39 +0000 (16:00 +0100)
The current PCM code calls the sync_stop at the resume action due to
the analogy to the PCM prepare call pattern.  But, it makes little
sense, as the sync should have been done rather at the suspend time,
not at the resume time.

This patch corrects the sync_stop call at suspend/resume to assure the
sync before finishing the suspend.

Fixes: 1e850beea278 ("ALSA: pcm: Add the support for sync-stop operation")
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210206203656.15959-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/pcm_native.c

index 1f5acf08cdcddbb379e875807d61f62804b8258f..cbbdb75c66ea0c882a61a647f6c878e6b5e6d820 100644 (file)
@@ -1615,6 +1615,7 @@ static int snd_pcm_do_suspend(struct snd_pcm_substream *substream,
        if (! snd_pcm_running(substream))
                return 0;
        substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND);
+       runtime->stop_operating = true;
        return 0; /* suspend unconditionally */
 }
 
@@ -1691,6 +1692,12 @@ int snd_pcm_suspend_all(struct snd_pcm *pcm)
                                return err;
                }
        }
+
+       for (stream = 0; stream < 2; stream++)
+               for (substream = pcm->streams[stream].substream;
+                    substream; substream = substream->next)
+                       snd_pcm_sync_stop(substream, false);
+
        return 0;
 }
 EXPORT_SYMBOL(snd_pcm_suspend_all);
@@ -1736,7 +1743,6 @@ static void snd_pcm_post_resume(struct snd_pcm_substream *substream,
        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, true);
 }
 
 static const struct action_ops snd_pcm_action_resume = {