IB/mad: Fix lock-lock-timer deadlock in RMPP code
authorRoland Dreier <rdreier@cisco.com>
Wed, 23 Sep 2009 18:10:15 +0000 (11:10 -0700)
committerRoland Dreier <rolandd@cisco.com>
Wed, 23 Sep 2009 18:10:15 +0000 (11:10 -0700)
commit0e442afd92fcdde2cc63b6f25556b8934e42b7d2
tree49b2f52ee849e7888473eb228f1abe3c27ed9434
parent86d710146fb9975f04c505ec78caa43d227c1018
IB/mad: Fix lock-lock-timer deadlock in RMPP code

Holding agent->lock across cancel_delayed_work() (which does
del_timer_sync()) in ib_cancel_rmpp_recvs() leads to lockdep reports of
possible lock-timer deadlocks if a consumer ever does something that
connects agent->lock to a lock taken in IRQ context (cf
http://marc.info/?l=linux-rdma&m=125243699026045).

Fix this by changing the list items to a new state "CANCELING" while
holding the lock, and then canceling the delayed work without holding
the lock.  If the delayed work runs after the lock is dropped, it will
see the state is CANCELING and return immediately, so the list will
stay stable while we traverse it with the lock not held.

Reviewed-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/core/mad_rmpp.c