[ofw][mlx4] SRQ attached QP issue

Alex Estrin alex.estrin at qlogic.com
Fri Sep 26 15:20:21 PDT 2008


Hello,

This patch seem fixed the create-QP-attached-to-SRQ issue.
I didn't verify though, if code allowes send queue zero size. Included
check anyway.
Please review.

Thanks,
Alex.

Index: mlx4/kernel/bus/ib/qp.c
===================================================================
--- mlx4/kernel/bus/ib/qp.c	(revision 1622)
+++ mlx4/kernel/bus/ib/qp.c	(working copy)
@@ -411,14 +411,20 @@
 		err = mlx4_buf_write_mtt(dev->dev, &qp->mtt, &qp->buf);
 		if (err)
 			goto err_mtt;
-
-		qp->sq.wrid  = kmalloc(qp->sq.wqe_cnt * sizeof (u64),
GFP_KERNEL);
-		qp->rq.wrid  = kmalloc(qp->rq.wqe_cnt * sizeof (u64),
GFP_KERNEL);
-
-		if (!qp->sq.wrid || !qp->rq.wrid) {
-			err = -ENOMEM;
-			goto err_wrid;
+		if (qp->sq.wqe_cnt) {
+			qp->sq.wrid  = kmalloc(qp->sq.wqe_cnt * sizeof
(u64), GFP_KERNEL);
+			if (!qp->sq.wrid) {
+				err = -ENOMEM;
+				goto err_wrid;
+			}
 		}
+		if (qp->rq.wqe_cnt) {
+			qp->rq.wrid  = kmalloc(qp->rq.wqe_cnt * sizeof
(u64), GFP_KERNEL);
+			if (!qp->rq.wrid) {
+				err = -ENOMEM;
+				goto err_wrid;
+			}
+		}
 	}
 
 	if (!sqpn)
@@ -452,8 +458,10 @@
 			mlx4_ib_db_unmap_user(to_mucontext(pd->p_uctx),
 					      &qp->db);
 	} else {
-		kfree(qp->sq.wrid);
-		kfree(qp->rq.wrid);
+		if (qp->sq.wrid)
+			kfree(qp->sq.wrid);
+		if (qp->rq.wrid)
+			kfree(qp->rq.wrid);
 	}
 
 err_mtt:



> Hello,
> 
> It seem there is a controversy exist in mlx4 driver that 
> won't allow to create QP if it was attached to SRQ.
> 
> At first it doesn't allow to set any recv queue size (which is fine)
> 
> mlx4\kernel\bus\ib\qp.c@ line 219:
> 		if (cap->max_recv_wr)
> 			return -EINVAL;
> 
> 		qp->rq.wqe_cnt = qp->rq.max_gs = 0;
> 
> But then there is assertion for zero size memory request in 'kmalloc':
> mlx4\kernel\bus\ib\qp.c @ line 416:
> 
> 		qp->rq.wrid  = kmalloc(qp->rq.wqe_cnt * sizeof 
> (u64), GFP_KERNEL);
> 		
> mlx4\kernel\inc\l2w_memory.h @ line 81:
> 
> 		static inline void * kmalloc( SIZE_T bsize, 
> gfp_t gfp_mask)
> 		{
> 			void *ptr;
> 			ASSERT( KeGetCurrentIrql() <= DISPATCH_LEVEL);
> 			ASSERT(bsize);
> 		.....
> 
> I believe it was added for a reason.
> Please let me know if I missed anything.
> 
> Thanks,
> Alex.
> 
> 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mlx4_create_qp.patch
Type: application/octet-stream
Size: 1180 bytes
Desc: mlx4_create_qp.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20080926/91f4405f/attachment.obj>


More information about the ofw mailing list