Skip to contentSkip to conversation

use the new CQ API in the mlx5 driver

PATCH In review Christoph Hellwig 4 participants 9 messages Feb 27, 2016 – Mar 4, 2016 8 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 1456565984-28998-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org

#2 lore raw

PATCH 1/1 IB/mlx5: Convert UMR CQ to new CQ API

Simplifies the code, and makes it more fair vs other users by using a softirq for polling.

---
 drivers/infiniband/hw/mlx5/main.c    |  9 +++-----
 drivers/infiniband/hw/mlx5/mlx5_ib.h |  8 +------
 drivers/infiniband/hw/mlx5/mr.c      | 43 +++++++++++++++++-------------------
 3 files changed, 24 insertions(+), 36 deletions(-)
drivers/infiniband/hw/mlx5/main.c +3 -6
index 03c418c..d91673e 100644
@@ -1838,7 +1838,7 @@ static void destroy_umrc_res(struct mlx5_ib_dev *dev)
 		mlx5_ib_warn(dev, "mr cache cleanup failed\n");
 
 	mlx5_ib_destroy_qp(dev->umrc.qp);
-	ib_destroy_cq(dev->umrc.cq);
+	ib_free_cq(dev->umrc.cq);
 	ib_dealloc_pd(dev->umrc.pd);
 }
 
@@ -1853,7 +1853,6 @@ static int create_umr_res(struct mlx5_ib_dev *dev)
 	struct ib_pd *pd;
 	struct ib_cq *cq;
 	struct ib_qp *qp;
-	struct ib_cq_init_attr cq_attr = {};
 	int ret;
 
 	attr = kzalloc(sizeof(*attr), GFP_KERNEL);
@@ -1870,9 +1869,7 @@ static int create_umr_res(struct mlx5_ib_dev *dev)
 		goto error_0;
 	}
 
-	cq_attr.cqe = 128;
-	cq = ib_create_cq(&dev->ib_dev, mlx5_umr_cq_handler, NULL, NULL,
-			  &cq_attr);
+	cq = ib_alloc_cq(&dev->ib_dev, NULL, 128, 0, IB_POLL_SOFTIRQ);
 	if (IS_ERR(cq)) {
 		mlx5_ib_dbg(dev, "Couldn't create CQ for sync UMR QP\n");
 		ret = PTR_ERR(cq);
@@ -1945,7 +1942,7 @@ error_4:
 	mlx5_ib_destroy_qp(qp);
 
 error_3:
-	ib_destroy_cq(cq);
+	ib_free_cq(cq);
 
 error_2:
 	ib_dealloc_pd(pd);
drivers/infiniband/hw/mlx5/mlx5_ib.h +1 -7
index 2d05bb5..5d0686e 100644
@@ -428,16 +428,11 @@ struct mlx5_ib_mr {
 };
 
 struct mlx5_ib_umr_context {
+	struct ib_cqe		cqe;
 	enum ib_wc_status	status;
 	struct completion	done;
 };
 
-static inline void mlx5_ib_init_umr_context(struct mlx5_ib_umr_context *context)
-{
-	context->status = -1;
-	init_completion(&context->done);
-}
-
 struct umr_common {
 	struct ib_pd	*pd;
 	struct ib_cq	*cq;
@@ -699,7 +694,6 @@ int mlx5_ib_get_cqe_size(struct mlx5_ib_dev *dev, struct ib_cq *ibcq);
 int mlx5_mr_cache_init(struct mlx5_ib_dev *dev);
 int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev);
 int mlx5_mr_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift);
-void mlx5_umr_cq_handler(struct ib_cq *cq, void *cq_context);
 int mlx5_ib_check_mr_status(struct ib_mr *ibmr, u32 check_mask,
 			    struct ib_mr_status *mr_status);
 
drivers/infiniband/hw/mlx5/mr.c +20 -23

84 lines not on this page · raw message

Signature · 6 lines
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1456565984-28998-2-git-send-email-hch-jcswGhMUV9g@public.gmane.org

A message that is not in the archive (sent off-list or not yet received): 56D2D731.5060904-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org

Reviewed-by
#6 lore raw

Re: [PATCH] IB/mlx5: Convert UMR CQ to new CQ API

Quoted 10 lines · Sagi Grimberg
Quoted 6 lines

Simplifies the code, and makes it more fair vs other users by using a softirq for polling.

---

This effects user-space and ODP.

CC'ing Haggai

Looks good to me.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 56D3F1EA.9090800-VPRAkNaXOzVWk0Htik3J/[email protected]

author Reviewed-by Haggai Eran
#8 lore raw

Re: [PATCH] IB/mlx5: Convert UMR CQ to new CQ API

Thanks for the review Haggai. I noticed I left a stray ib_req_notify_cq in the code, which is harmless but not needed with the new API. Patch with that one line updated below.

Doug, can you picks this up for the mlx5 branch?

---

Quoted 1 line

From 0a24d6471d0d0f2d77120d502aa9b9384abecd28 Mon Sep 17 00:00:00 2001

From: Christoph Hellwig <[email protected]>
Date: Sat, 27 Feb 2016 10:37:20 +0100
Subject: IB/mlx5: Convert UMR CQ to new CQ API

Simplifies the code, and makes it more fair vs other users by using a softirq for polling.

---
 drivers/infiniband/hw/mlx5/main.c    | 10 +++------
 drivers/infiniband/hw/mlx5/mlx5_ib.h |  8 +------
 drivers/infiniband/hw/mlx5/mr.c      | 43 +++++++++++++++++-------------------
 3 files changed, 24 insertions(+), 37 deletions(-)
drivers/infiniband/hw/mlx5/main.c +3 -7
index 03c418c..97eb594 100644
@@ -1838,7 +1838,7 @@ static void destroy_umrc_res(struct mlx5_ib_dev *dev)
 		mlx5_ib_warn(dev, "mr cache cleanup failed\n");
 
 	mlx5_ib_destroy_qp(dev->umrc.qp);
-	ib_destroy_cq(dev->umrc.cq);
+	ib_free_cq(dev->umrc.cq);
 	ib_dealloc_pd(dev->umrc.pd);
 }
 
@@ -1853,7 +1853,6 @@ static int create_umr_res(struct mlx5_ib_dev *dev)
 	struct ib_pd *pd;
 	struct ib_cq *cq;
 	struct ib_qp *qp;
-	struct ib_cq_init_attr cq_attr = {};
 	int ret;
 
 	attr = kzalloc(sizeof(*attr), GFP_KERNEL);
@@ -1870,15 +1869,12 @@ static int create_umr_res(struct mlx5_ib_dev *dev)
 		goto error_0;
 	}
 
-	cq_attr.cqe = 128;
-	cq = ib_create_cq(&dev->ib_dev, mlx5_umr_cq_handler, NULL, NULL,
-			  &cq_attr);
+	cq = ib_alloc_cq(&dev->ib_dev, NULL, 128, 0, IB_POLL_SOFTIRQ);
 	if (IS_ERR(cq)) {
 		mlx5_ib_dbg(dev, "Couldn't create CQ for sync UMR QP\n");
 		ret = PTR_ERR(cq);
 		goto error_2;
 	}
-	ib_req_notify_cq(cq, IB_CQ_NEXT_COMP);
 
 	init_attr->send_cq = cq;
 	init_attr->recv_cq = cq;
@@ -1945,7 +1941,7 @@ error_4:
 	mlx5_ib_destroy_qp(qp);
 
 error_3:
-	ib_destroy_cq(cq);
+	ib_free_cq(cq);
 
 error_2:
 	ib_dealloc_pd(pd);
drivers/infiniband/hw/mlx5/mlx5_ib.h +1 -7
index 2d05bb5..5d0686e 100644
@@ -428,16 +428,11 @@ struct mlx5_ib_mr {
 };
 
 struct mlx5_ib_umr_context {
+	struct ib_cqe		cqe;
 	enum ib_wc_status	status;
 	struct completion	done;
 };
 
-static inline void mlx5_ib_init_umr_context(struct mlx5_ib_umr_context *context)
-{
-	context->status = -1;
-	init_completion(&context->done);
-}
-
 struct umr_common {
 	struct ib_pd	*pd;
 	struct ib_cq	*cq;
@@ -699,7 +694,6 @@ int mlx5_ib_get_cqe_size(struct mlx5_ib_dev *dev, struct ib_cq *ibcq);
 int mlx5_mr_cache_init(struct mlx5_ib_dev *dev);
 int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev);
 int mlx5_mr_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift);
-void mlx5_umr_cq_handler(struct ib_cq *cq, void *cq_context);
 int mlx5_ib_check_mr_status(struct ib_mr *ibmr, u32 check_mask,
 			    struct ib_mr_status *mr_status);
 
drivers/infiniband/hw/mlx5/mr.c +20 -23

84 lines not on this page · raw message

Signature · 6 lines
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

Reviewed-by
#10 lore raw

Re: [PATCH] IB/mlx5: Convert UMR CQ to new CQ API

Quoted 6 lines

Thanks for the review Haggai. I noticed I left a stray ib_req_notify_cq in the code, which is harmless but not needed with the new API. Patch with that one line updated below.

Doug, can you picks this up for the mlx5 branch?

The patch looks fine to me too,

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 56D7FE93.9020503-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org

#12 lore raw

Re: [PATCH] IB/mlx5: Convert UMR CQ to new CQ API

Quoted 10 lines · Sagi Grimberg
Quoted 6 lines

Thanks for the review Haggai. I noticed I left a stray ib_req_notify_cq in the code, which is harmless but not needed with the new API. Patch with that one line updated below.

Doug, can you picks this up for the mlx5 branch?

The patch looks fine to me too,

I took the later version of the patch, but I had to fix it up due to conflicts with both the rereg_me patchset and the mmkey cleanup patchset. Please double check this in the mlx5 branch of my github repo to make sure it's all good.

Signature · 2 lines
Doug Ledford <[email protected]>
              GPG KeyID: 0E572FDD

A message that is not in the archive (sent off-list or not yet received): [email protected]

#14 lore raw

Re: [PATCH] IB/mlx5: Convert UMR CQ to new CQ API

Quoted 4 lines · Doug Ledford

I took the later version of the patch, but I had to fix it up due to conflicts with both the rereg_me patchset and the mmkey cleanup patchset. Please double check this in the mlx5 branch of my github repo to make sure it's all good.

Looks like we'll need the one liner below to get the manually applied patch to compile, but otherwise it looks fine to me.

drivers/infiniband/hw/mlx5/mr.c +1 -1
index f1464b8..4d5bff1 100644
@@ -1201,7 +1201,7 @@ static int unreg_umr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr)
 
 	mlx5_ib_init_umr_context(&umr_context);
 
-	umrwr.wr.wr_cqe = &umr_context.cqe
+	umrwr.wr.wr_cqe = &umr_context.cqe;
 	prep_umr_unreg_wqe(dev, &umrwr.wr, mr->mmkey.key);
 
 	down(&umrc->sem);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#16 lore raw

Re: [PATCH] IB/mlx5: Convert UMR CQ to new CQ API

Quoted 16 lines · Christoph Hellwig
Quoted 4 lines · Doug Ledford

I took the later version of the patch, but I had to fix it up due to conflicts with both the rereg_me patchset and the mmkey cleanup patchset. Please double check this in the mlx5 branch of my github repo to make sure it's all good.

Looks like we'll need the one liner below to get the manually applied patch to compile, but otherwise it looks fine to me.

drivers/infiniband/hw/mlx5/mr.c +0 -0
index f1464b8..4d5bff1 100644

drivers/infiniband/hw/mlx5/mr.c static int unreg_umr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr) · line 1207

Quoted 8 lines
drivers/infiniband/hw/mlx5/mr.c +1 -1
@@ -1201,7 +1201,7 @@ static int unreg_umr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr)
 
 	mlx5_ib_init_umr_context(&umr_context);
 
-	umrwr.wr.wr_cqe = &umr_context.cqe
+	umrwr.wr.wr_cqe = &umr_context.cqe;
 	prep_umr_unreg_wqe(dev, &umrwr.wr, mr->mmkey.key);
 
 	down(&umrc->sem);

Missing a ;, fun times! ;-)

Signature · 2 lines
Doug Ledford <[email protected]>
              GPG KeyID: 0E572FDD