From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Cc: Mark Brown <broonie@kernel.org>,
Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Subject: [PATCH v2 2/2] ALSA: pcm: Forcibly stop at disconnect callback
Date: Wed, 11 Oct 2017 12:16:18 +0200 [thread overview]
Message-ID: <20171011101618.8736-3-tiwai@suse.de> (raw)
In-Reply-To: <20171011101618.8736-1-tiwai@suse.de>
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>
---
sound/core/pcm.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index 7eadb7fd8074..054e47ad23ed 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -1152,6 +1152,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);
--
2.14.2
next prev parent reply other threads:[~2017-10-11 10:16 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-11 10:16 [PATCH v2 0/2] Add snd_card_disconnect_sync() helper Takashi Iwai
2017-10-11 10:16 ` [PATCH v2 1/2] ALSA: add snd_card_disconnect_sync() Takashi Iwai
2017-10-11 11:22 ` Takashi Sakamoto
2017-10-11 12:19 ` Takashi Iwai
2017-10-11 13:13 ` Takashi Iwai
2017-10-11 10:16 ` Takashi Iwai [this message]
2017-10-13 7:39 ` [PATCH v2 0/2] Add snd_card_disconnect_sync() helper Kuninori Morimoto
2017-10-13 7:44 ` Takashi Iwai
2017-10-13 9:11 ` Kuninori Morimoto
2017-10-13 9:43 ` Takashi Iwai
2017-10-13 17:11 ` Mark Brown
2017-10-16 2:26 ` Kuninori Morimoto
2017-10-16 15:37 ` Takashi Iwai
2017-10-17 0:59 ` Kuninori Morimoto
2017-10-17 10:37 ` Takashi Iwai
2017-10-17 20:05 ` Mark Brown
2017-10-18 2:08 ` Kuninori Morimoto
2017-10-18 6:10 ` Takashi Iwai
2017-10-18 7:13 ` Kuninori Morimoto
2017-10-17 14:25 ` Takashi Sakamoto
2017-10-17 14:34 ` Takashi Iwai
2017-10-17 15:16 ` Takashi Sakamoto
2017-10-17 16:09 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171011101618.8736-3-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=kuninori.morimoto.gx@renesas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox