[ofa-general] [PATCH 2/3]: IB/mthca: allow lockless SRQ

Eli Cohen eli at mellanox.co.il
Wed Oct 10 08:55:42 PDT 2007


Add support to mthca for lockless SRQ

Signed-off-by: Eli Cohen <eli at mellanox.co.il>

---

Index: ofa_kernel-1.2.5/drivers/infiniband/hw/mthca/mthca_srq.c
===================================================================
--- ofa_kernel-1.2.5.orig/drivers/infiniband/hw/mthca/mthca_srq.c	2007-10-10 15:18:40.000000000 +0200
+++ ofa_kernel-1.2.5/drivers/infiniband/hw/mthca/mthca_srq.c	2007-10-10 15:24:05.000000000 +0200
@@ -394,6 +394,9 @@ int mthca_modify_srq(struct ib_srq *ibsr
 			return -EINVAL;
 	}
 
+	if (attr_mask & IB_SRQ_LOCKNESS)
+		srq->use_lock = !!attr->use_lock;
+
 	return 0;
 }
 
@@ -473,7 +476,8 @@ void mthca_free_srq_wqe(struct mthca_srq
 
 	ind = wqe_addr >> srq->wqe_shift;
 
-	spin_lock(&srq->lock);
+	if (srq->use_lock)
+		spin_lock(&srq->lock);
 
 	if (likely(srq->first_free >= 0))
 		*wqe_to_link(get_wqe(srq, srq->last_free)) = ind;
@@ -483,7 +487,8 @@ void mthca_free_srq_wqe(struct mthca_srq
 	*wqe_to_link(get_wqe(srq, ind)) = -1;
 	srq->last_free = ind;
 
-	spin_unlock(&srq->lock);
+	if (srq->use_lock)
+		spin_unlock(&srq->lock);
 }
 
 int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
@@ -502,7 +507,8 @@ int mthca_tavor_post_srq_recv(struct ib_
 	void *wqe;
 	void *prev_wqe;
 
-	spin_lock_irqsave(&srq->lock, flags);
+	if (srq->use_lock)
+		spin_lock_irqsave(&srq->lock, flags);
 
 	first_ind = srq->first_free;
 
@@ -609,7 +615,9 @@ int mthca_tavor_post_srq_recv(struct ib_
 	 */
 	mmiowb();
 
-	spin_unlock_irqrestore(&srq->lock, flags);
+	if (srq->use_lock)
+		spin_unlock_irqrestore(&srq->lock, flags);
+
 	return err;
 }
 
@@ -626,7 +634,8 @@ int mthca_arbel_post_srq_recv(struct ib_
 	int i;
 	void *wqe;
 
-	spin_lock_irqsave(&srq->lock, flags);
+	if (srq->use_lock)
+		spin_lock_irqsave(&srq->lock, flags);
 
 	for (nreq = 0; wr; ++nreq, wr = wr->next) {
 		ind = srq->first_free;
@@ -692,7 +701,9 @@ int mthca_arbel_post_srq_recv(struct ib_
 		*srq->db = cpu_to_be32(srq->counter);
 	}
 
-	spin_unlock_irqrestore(&srq->lock, flags);
+	if (srq->use_lock)
+		spin_unlock_irqrestore(&srq->lock, flags);
+
 	return err;
 }
 
Index: ofa_kernel-1.2.5/drivers/infiniband/hw/mthca/mthca_provider.h
===================================================================
--- ofa_kernel-1.2.5.orig/drivers/infiniband/hw/mthca/mthca_provider.h	2007-10-10 15:10:22.000000000 +0200
+++ ofa_kernel-1.2.5/drivers/infiniband/hw/mthca/mthca_provider.h	2007-10-10 15:24:05.000000000 +0200
@@ -222,6 +222,7 @@ struct mthca_cq {
 struct mthca_srq {
 	struct ib_srq		ibsrq;
 	spinlock_t		lock;
+	int			use_lock;
 	int			refcount;
 	int			srqn;
 	int			max;




More information about the general mailing list