Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
[pandora-kernel.git] / drivers / infiniband / hw / mthca / mthca_provider.h
index 6676a78..9a5bece 100644 (file)
@@ -136,14 +136,15 @@ struct mthca_ah {
  * We have one global lock that protects dev->cq/qp_table.  Each
  * struct mthca_cq/qp also has its own lock.  An individual qp lock
  * may be taken inside of an individual cq lock.  Both cqs attached to
- * a qp may be locked, with the send cq locked first.  No other
- * nesting should be done.
+ * a qp may be locked, with the cq with the lower cqn locked first.
+ * No other nesting should be done.
  *
- * Each struct mthca_cq/qp also has an atomic_t ref count.  The
- * pointer from the cq/qp_table to the struct counts as one reference.
- * This reference also is good for access through the consumer API, so
- * modifying the CQ/QP etc doesn't need to take another reference.
- * Access because of a completion being polled does need a reference.
+ * Each struct mthca_cq/qp also has an ref count, protected by the
+ * corresponding table lock.  The pointer from the cq/qp_table to the
+ * struct counts as one reference.  This reference also is good for
+ * access through the consumer API, so modifying the CQ/QP etc doesn't
+ * need to take another reference.  Access to a QP because of a
+ * completion being polled does not need a reference either.
  *
  * Finally, each struct mthca_cq/qp has a wait_queue_head_t for the
  * destroy function to sleep on.
@@ -159,8 +160,9 @@ struct mthca_ah {
  * - decrement ref count; if zero, wake up waiters
  *
  * To destroy a CQ/QP, we can do the following:
- * - lock cq/qp_table, remove pointer, unlock cq/qp_table lock
- * - decrement ref count
+ * - lock cq/qp_table
+ * - remove pointer and decrement ref count
+ * - unlock cq/qp_table lock
  * - wait_event until ref count is zero
  *
  * It is the consumer's responsibilty to make sure that no QP
@@ -197,7 +199,7 @@ struct mthca_cq_resize {
 struct mthca_cq {
        struct ib_cq            ibcq;
        spinlock_t              lock;
-       atomic_t                refcount;
+       int                     refcount;
        int                     cqn;
        u32                     cons_index;
        struct mthca_cq_buf     buf;
@@ -212,12 +214,13 @@ struct mthca_cq {
        int                     arm_sn;
 
        wait_queue_head_t       wait;
+       struct mutex            mutex;
 };
 
 struct mthca_srq {
        struct ib_srq           ibsrq;
        spinlock_t              lock;
-       atomic_t                refcount;
+       int                     refcount;
        int                     srqn;
        int                     max;
        int                     max_gs;
@@ -235,6 +238,7 @@ struct mthca_srq {
        struct mthca_mr         mr;
 
        wait_queue_head_t       wait;
+       struct mutex            mutex;
 };
 
 struct mthca_wq {
@@ -254,7 +258,7 @@ struct mthca_wq {
 
 struct mthca_qp {
        struct ib_qp           ibqp;
-       atomic_t               refcount;
+       int                    refcount;
        u32                    qpn;
        int                    is_direct;
        u8                     port; /* for SQP and memfree use only */
@@ -276,6 +280,7 @@ struct mthca_qp {
        union mthca_buf        queue;
 
        wait_queue_head_t      wait;
+       struct mutex           mutex;
 };
 
 struct mthca_sqp {