Roland Dreier 2fe7e6f7c9 IB/umad: Simplify and fix locking
In addition to being overly complex, the locking in user_mad.c is
broken: there were multiple reports of deadlocks and lockdep warnings.
In particular it seems that a single thread may end up trying to take
the same rwsem for reading more than once, which is explicitly
forbidden in the comments in <linux/rwsem.h>.

To solve this, we change the locking to use plain mutexes instead of
rwsems.  There is one mutex per open file, which protects the contents
of the struct ib_umad_file, including the array of agents and list of
queued packets; and there is one mutex per struct ib_umad_port, which
protects the contents, including the list of open files.  We never
hold the file mutex across calls to functions like ib_unregister_mad_agent(),
which can call back into other ib_umad code to queue a packet, and we
always hold the port mutex as long as we need to make sure that a
device is not hot-unplugged from under us.

This even makes things nicer for users of the -rt patch, since we
remove calls to downgrade_write() (which is not implemented in -rt).

Signed-off-by: Roland Dreier <rolandd@cisco.com>
2008-01-25 14:15:42 -08:00
..
2007-10-17 08:42:52 -07:00
2008-01-24 22:50:12 -08:00
2007-10-16 09:43:09 -07:00
2007-12-31 23:11:11 +00:00
2007-11-05 15:12:31 -08:00
2007-12-12 20:01:00 +01:00
2007-12-23 12:54:37 -08:00
2008-01-24 20:40:44 -08:00
2008-01-24 20:40:45 -08:00
2008-01-24 20:40:45 -08:00
2007-10-17 08:42:57 -07:00
2008-01-24 20:40:43 -08:00
2007-10-23 15:49:54 +10:00