diff options
author | Takashi Iwai <tiwai@suse.de> | 2016-02-17 14:30:26 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2016-02-18 11:27:52 +0100 |
commit | 67ec1072b053c15564e6090ab30127895dc77a89 (patch) | |
tree | c5595e0762602ea68bd0761c0055f555f0c4f275 /Makefile | |
parent | 13d5e5d4725c64ec06040d636832e78453f477b7 (diff) |
ALSA: pcm: Fix rwsem deadlock for non-atomic PCM streamsound-4.5-rc5
A non-atomic PCM stream may take snd_pcm_link_rwsem rw semaphore twice
in the same code path, e.g. one in snd_pcm_action_nonatomic() and
another in snd_pcm_stream_lock(). Usually this is OK, but when a
write lock is issued between these two read locks, the problem
happens: the write lock is blocked due to the first reade lock, and
the second read lock is also blocked by the write lock. This
eventually deadlocks.
The reason is the way rwsem manages waiters; it's queued like FIFO, so
even if the writer itself doesn't take the lock yet, it blocks all the
waiters (including reads) queued after it.
As a workaround, in this patch, we replace the standard down_write()
with an spinning loop. This is far from optimal, but it's good
enough, as the spinning time is supposed to be relatively short for
normal PCM operations, and the code paths requiring the write lock
aren't called so often.
Reported-by: Vinod Koul <vinod.koul@intel.com>
Tested-by: Ramesh Babu <ramesh.babu@intel.com>
Cc: <stable@vger.kernel.org> # v3.18+
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'Makefile')
0 files changed, 0 insertions, 0 deletions