aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/sound/core
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2019-01-22 14:29:51 +0100
committerTakashi Iwai <tiwai@suse.de>2019-01-23 07:40:49 +0100
commitecb41f0f44cadfa90ef9acff3ffe95563274ec1c (patch)
treed896614a038efbd52b1fc5f965d9547bd860c3a4 /sound/core
parentALSA: pcm: More fine-grained PCM link locking (diff)
downloadwireguard-linux-ecb41f0f44cadfa90ef9acff3ffe95563274ec1c.tar.xz
wireguard-linux-ecb41f0f44cadfa90ef9acff3ffe95563274ec1c.zip
ALSA: pcm: Remove down_write() hack for snd_pcm_link_rwsem
Remove the hackish down_write_nonfifo() that was introduced as a workaround of rwsem deadlock. It used to be a problem for non-atomic PCM streams that take the rwsem for the locking and hit the high lock contention. Since the current PCM locking refactoring, we'll no longer hit it as the hot code-paths don't take global locks. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/pcm_native.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index cbde23fc67a9..f450083eb073 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -87,18 +87,6 @@ static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream);
static DECLARE_RWSEM(snd_pcm_link_rwsem);
-/* Writer in rwsem may block readers even during its waiting in queue,
- * and this may lead to a deadlock when the code path takes read sem
- * twice (e.g. one in snd_pcm_action_nonatomic() and another in
- * snd_pcm_stream_lock()). As a (suboptimal) workaround, let writer to
- * sleep until all the readers are completed without blocking by writer.
- */
-static inline void down_write_nonfifo(struct rw_semaphore *lock)
-{
- while (!down_write_trylock(lock))
- msleep(1);
-}
-
void snd_pcm_group_init(struct snd_pcm_group *group)
{
spin_lock_init(&group->lock);
@@ -2052,7 +2040,7 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd)
}
snd_pcm_group_init(group);
- down_write_nonfifo(&snd_pcm_link_rwsem);
+ down_write(&snd_pcm_link_rwsem);
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN ||
substream->runtime->status->state != substream1->runtime->status->state ||
substream->pcm->nonatomic != substream1->pcm->nonatomic) {
@@ -2100,7 +2088,7 @@ static int snd_pcm_unlink(struct snd_pcm_substream *substream)
bool do_free = false;
int res = 0;
- down_write_nonfifo(&snd_pcm_link_rwsem);
+ down_write(&snd_pcm_link_rwsem);
if (!snd_pcm_stream_linked(substream)) {
res = -EALREADY;