]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commit
hid: atvr: Fix deadlock race condition in timer
authorXia Yang <xiay@nvidia.com>
Thu, 22 Jan 2015 02:31:54 +0000 (18:31 -0800)
committerXia Yang <xiay@nvidia.com>
Thu, 19 Mar 2015 22:46:46 +0000 (15:46 -0700)
commita626300a6491ff104e12fcd6b045c805f4563193
tree1f973f39d3a389c6915b28185a9902fe1bd5d678
parent4ac2086431695fc8f21e78a33891f60e2c8c8fa4
hid: atvr: Fix deadlock race condition in timer

The timer callback could call snd_pcm_period_elapsed()
which need snd_pcm_stream_lock_irqsave() on the substream,
while a snd_pcm_suspend() who already holds the same lock
eventually comes to snd_atvr_timer_stop() and wait the timer
to finish in del_timer_sync(), forming a deadlock.

We could temporarily give up the lock before del_timer_sync()
and relock afterwards.  However, that might break the original
purpose of the lock.  Thus we just do try_do_del_timer() instead,
which do not block.

As for timer consistency, we ensure previous timer is finished
in snd_atvr_timer_start() instead where the lock concerned is
not held.

Bug 1599000

Change-Id: I04f60a58b263791a97ab33f49a2f24aa03af5d5c
Signed-off-by: Xia Yang <xiay@nvidia.com>
Reviewed-on: http://git-master/r/674612
(cherry picked from commit 7bbe3c502d815e7022a1166aa1177a913c56b887)
Reviewed-on: http://git-master/r/680246
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
drivers/hid/hid-atv-jarvis.c