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

Tang, Changqing changquing.tang at hp.com
Wed Oct 10 09:22:44 PDT 2007



Can give a few more words about lockless SRQ ?  Thanks

--CQ 

> -----Original Message-----
> From: general-bounces at lists.openfabrics.org 
> [mailto:general-bounces at lists.openfabrics.org] On Behalf Of Eli Cohen
> Sent: Wednesday, October 10, 2007 10:56 AM
> To: Roland Dreier
> Cc: openfabrics
> Subject: [ofa-general] [PATCH 2/3]: IB/mthca: allow lockless SRQ
> 
> 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_pro
> vider.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;
> 
> _______________________________________________
> general mailing list
> general at lists.openfabrics.org
> http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general
> 
> To unsubscribe, please visit 
> http://openib.org/mailman/listinfo/openib-general
> 



More information about the general mailing list