diff options
author | Takashi Iwai <tiwai@suse.de> | 2017-10-11 11:42:00 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2017-10-18 08:05:46 +0200 |
commit | 6ca73de7ebc5dac358551633e0c69ab6b5007baa (patch) | |
tree | 4e8b68dbeec41bd449750b60c25bb66486c17c96 /sound/core | |
parent | 8b645e4a40dd490b9426670fffe9bb9e2878c3fd (diff) | |
download | blackbird-obmc-linux-6ca73de7ebc5dac358551633e0c69ab6b5007baa.tar.gz blackbird-obmc-linux-6ca73de7ebc5dac358551633e0c69ab6b5007baa.zip |
ALSA: pcm: Forcibly stop at disconnect callback
So far we assumed that each driver implements the hotplug PCM handling
properly, e.g. dealing with the pending PCM stream at disconnect
callback. But most codes don't care, and it eventually leaves the PCM
stream inconsistent state when an abrupt disconnection like sysfs
unbind happens.
This patch is simple but a big-hammer solution: invoke snd_pcm_stop()
at the common PCM disconnect callback always when the stream is
running.
Tested-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r-- | sound/core/pcm.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 1b073ed0b1f9..9070f277f8db 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -1154,6 +1154,10 @@ static int snd_pcm_dev_disconnect(struct snd_device *device) for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) { snd_pcm_stream_lock_irq(substream); if (substream->runtime) { + if (snd_pcm_running(substream)) + snd_pcm_stop(substream, + SNDRV_PCM_STATE_DISCONNECTED); + /* to be sure, set the state unconditionally */ substream->runtime->status->state = SNDRV_PCM_STATE_DISCONNECTED; wake_up(&substream->runtime->sleep); wake_up(&substream->runtime->tsleep); |