Commit b51abed8 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: pcm: Call snd_pcm_unlink() conditionally at closing

Currently the PCM core calls snd_pcm_unlink() always unconditionally
at closing a stream.  However, since snd_pcm_unlink() invokes the
global rwsem down, the lock can be easily contended.  More badly, when
a thread runs in a high priority RT-FIFO, it may stall at spinning.

Basically the call of snd_pcm_unlink() is required only for the linked
streams that are already rare occasion.  For normal use cases, this
code path is fairly superfluous.

As an optimization (and also as a workaround for the RT problem
above in normal situations without linked streams), this patch adds a
check before calling snd_pcm_unlink() and calls it only when needed.
Reported-by: default avatarChanho Min <chanho.min@lge.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 8159a6a4
...@@ -2369,6 +2369,7 @@ int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) ...@@ -2369,6 +2369,7 @@ int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream)
static void pcm_release_private(struct snd_pcm_substream *substream) static void pcm_release_private(struct snd_pcm_substream *substream)
{ {
if (snd_pcm_stream_linked(substream))
snd_pcm_unlink(substream); snd_pcm_unlink(substream);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment