All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/5] Reduce RDMA RW API SGE limit
@ 2016-07-21 20:02 Bart Van Assche
       [not found] ` <75fc8647-16a6-5a89-400f-f5f418a8d6eb-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Bart Van Assche @ 2016-07-21 20:02 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Christoph Hellwig, Sagi Grimberg, Steve Wise, Parav Pandit,
	Laurence Oberman, Nicholas A. Bellinger,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

Hello Doug,

The five patches in this series modify the RDMA RW API slightly. This is 
needed to avoid that the SRP and iSER target drivers submit RDMA 
requests with an SGE list that exceeds the queue pair limits. The 
ib_srpt changes in this series have been tested but the ib_isert changes 
not yet.

The changes compared to v3 of this patch series are:
* Split the single QP SGE limit into separate READ and WRITE SGE limits.
* Added a comment in ib_srpt.h that explains where the SGE limit comes
   from.

Changes compared to v2:
* For RDMA READs, limit SGE back to dev->attrs.max_sge_rd for iWARP.

Changes compared to v1:
* max_send_sge is now stored in struct ib_qp. This greatly simplifies
    this patch series.
* An unneeded initialization that I had added to rdma_rw_init_one_mr()
    has been left out again.
* Corrected "Fixes" tag in the patch description where needed.

The individual patches in this series are:

0001-IB-core-Make-rdma_rw_ctx_init-initialize-all-used-fi.patch
0002-IB-core-RDMA-RW-API-Do-not-exceed-QP-SGE-send-limit.patch
0003-IB-srpt-Limit-the-number-of-SG-elements-per-work-req.patch
0004-IB-srpt-Simplify-srpt_queue_response.patch
0005-IB-isert-Remove-an-unused-member-variable.patch

Thanks,

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v4 1/5] IB/core: Make rdma_rw_ctx_init() initialize all used fields
       [not found] ` <75fc8647-16a6-5a89-400f-f5f418a8d6eb-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
@ 2016-07-21 20:03   ` Bart Van Assche
  2016-07-21 20:03   ` [PATCH v4 2/5] IB/core, RDMA RW API: Do not exceed QP SGE send limit Bart Van Assche
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Bart Van Assche @ 2016-07-21 20:03 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Christoph Hellwig, Sagi Grimberg, Steve Wise, Parav Pandit,
	Laurence Oberman, Nicholas A. Bellinger,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

Some but not all callers of rdma_rw_ctx_init() zero-initialize
struct rdma_rw_ctx. Hence make rdma_rw_ctx_init() initialize all
work request fields that will be read by ib_post_send().

Fixes: a060b5629ab0 ("IB/core: generic RDMA READ/WRITE API")
Signed-off-by: Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
Reviewed-by: Sagi Grimberg <sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
Reviewed-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
Tested-by: Steve Wise <swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
Tested-by: Laurence Oberman <loberman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Parav Pandit <pandit.parav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Nicholas Bellinger <nab-IzHhD5pYlfBP7FQvKIMDCQ@public.gmane.org>
Cc: <stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org> #v4.7+
---
 drivers/infiniband/core/rw.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/core/rw.c b/drivers/infiniband/core/rw.c
index 1eb9b12..1ad2baa 100644
--- a/drivers/infiniband/core/rw.c
+++ b/drivers/infiniband/core/rw.c
@@ -71,6 +71,7 @@ static inline u32 rdma_rw_fr_page_list_len(struct ib_device *dev)
 	return min_t(u32, dev->attrs.max_fast_reg_page_list_len, 256);
 }
 
+/* Caller must have zero-initialized *reg. */
 static int rdma_rw_init_one_mr(struct ib_qp *qp, u8 port_num,
 		struct rdma_rw_reg_ctx *reg, struct scatterlist *sg,
 		u32 sg_cnt, u32 offset)
@@ -114,6 +115,7 @@ static int rdma_rw_init_mr_wrs(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
 		u8 port_num, struct scatterlist *sg, u32 sg_cnt, u32 offset,
 		u64 remote_addr, u32 rkey, enum dma_data_direction dir)
 {
+	struct rdma_rw_reg_ctx *prev = NULL;
 	u32 pages_per_mr = rdma_rw_fr_page_list_len(qp->pd->device);
 	int i, j, ret = 0, count = 0;
 
@@ -125,7 +127,6 @@ static int rdma_rw_init_mr_wrs(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
 	}
 
 	for (i = 0; i < ctx->nr_ops; i++) {
-		struct rdma_rw_reg_ctx *prev = i ? &ctx->reg[i - 1] : NULL;
 		struct rdma_rw_reg_ctx *reg = &ctx->reg[i];
 		u32 nents = min(sg_cnt, pages_per_mr);
 
@@ -162,9 +163,13 @@ static int rdma_rw_init_mr_wrs(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
 		sg_cnt -= nents;
 		for (j = 0; j < nents; j++)
 			sg = sg_next(sg);
+		prev = reg;
 		offset = 0;
 	}
 
+	if (prev)
+		prev->wr.wr.next = NULL;
+
 	ctx->type = RDMA_RW_MR;
 	return count;
 
@@ -205,11 +210,10 @@ static int rdma_rw_init_map_wrs(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
 			rdma_wr->wr.opcode = IB_WR_RDMA_READ;
 		rdma_wr->remote_addr = remote_addr + total_len;
 		rdma_wr->rkey = rkey;
+		rdma_wr->wr.num_sge = nr_sge;
 		rdma_wr->wr.sg_list = sge;
 
 		for (j = 0; j < nr_sge; j++, sg = sg_next(sg)) {
-			rdma_wr->wr.num_sge++;
-
 			sge->addr = ib_sg_dma_address(dev, sg) + offset;
 			sge->length = ib_sg_dma_len(dev, sg) - offset;
 			sge->lkey = qp->pd->local_dma_lkey;
@@ -220,8 +224,8 @@ static int rdma_rw_init_map_wrs(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
 			offset = 0;
 		}
 
-		if (i + 1 < ctx->nr_ops)
-			rdma_wr->wr.next = &ctx->map.wrs[i + 1].wr;
+		rdma_wr->wr.next = i + 1 < ctx->nr_ops ?
+			&ctx->map.wrs[i + 1].wr : NULL;
 	}
 
 	ctx->type = RDMA_RW_MULTI_WR;
-- 
2.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v4 2/5] IB/core, RDMA RW API: Do not exceed QP SGE send limit
       [not found] ` <75fc8647-16a6-5a89-400f-f5f418a8d6eb-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
  2016-07-21 20:03   ` [PATCH v4 1/5] IB/core: Make rdma_rw_ctx_init() initialize all used fields Bart Van Assche
@ 2016-07-21 20:03   ` Bart Van Assche
       [not found]     ` <c71ece34-36e2-86da-5032-2fc946ff0073-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
  2016-07-21 20:03   ` [PATCH v4 3/5] IB/srpt: Limit the number of SG elements per work request Bart Van Assche
                     ` (3 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Bart Van Assche @ 2016-07-21 20:03 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Christoph Hellwig, Sagi Grimberg, Steve Wise, Parav Pandit,
	Laurence Oberman, Nicholas A. Bellinger,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

Compute the SGE limit for RDMA READ and WRITE requests in
ib_create_qp(). Use that limit in the RDMA RW API implementation.

Signed-off-by: Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
Cc: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
Cc: Sagi Grimberg <sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
Cc: Steve Wise <swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
Cc: Parav Pandit <pandit.parav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Nicholas Bellinger <nab-IzHhD5pYlfBP7FQvKIMDCQ@public.gmane.org>
Cc: Laurence Oberman <loberman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: <stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org> #v4.7+
---
 drivers/infiniband/core/rw.c    | 10 ++--------
 drivers/infiniband/core/verbs.c |  9 +++++++++
 include/rdma/ib_verbs.h         |  6 ++++++
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/infiniband/core/rw.c b/drivers/infiniband/core/rw.c
index 1ad2baa..dbfd854 100644
--- a/drivers/infiniband/core/rw.c
+++ b/drivers/infiniband/core/rw.c
@@ -58,13 +58,6 @@ static inline bool rdma_rw_io_needs_mr(struct ib_device *dev, u8 port_num,
 	return false;
 }
 
-static inline u32 rdma_rw_max_sge(struct ib_device *dev,
-		enum dma_data_direction dir)
-{
-	return dir == DMA_TO_DEVICE ?
-		dev->attrs.max_sge : dev->attrs.max_sge_rd;
-}
-
 static inline u32 rdma_rw_fr_page_list_len(struct ib_device *dev)
 {
 	/* arbitrary limit to avoid allocating gigantic resources */
@@ -186,7 +179,8 @@ static int rdma_rw_init_map_wrs(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
 		u64 remote_addr, u32 rkey, enum dma_data_direction dir)
 {
 	struct ib_device *dev = qp->pd->device;
-	u32 max_sge = rdma_rw_max_sge(dev, dir);
+	u32 max_sge = dir == DMA_TO_DEVICE ? qp->max_write_sge :
+		      qp->max_read_sge;
 	struct ib_sge *sge;
 	u32 total_len = 0, i, j;
 
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 6298f54..e39a0b5 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -814,6 +814,15 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd,
 		}
 	}
 
+	/*
+	 * Note: all hw drivers guarantee that max_send_sge is lower than
+	 * the device RDMA WRITE SGE limit but not all hw drivers ensure that
+	 * max_send_sge <= max_sge_rd.
+	 */
+	qp->max_write_sge = qp_init_attr->cap.max_send_sge;
+	qp->max_read_sge = min_t(u32, qp_init_attr->cap.max_send_sge,
+				 device->attrs.max_sge_rd);
+
 	return qp;
 }
 EXPORT_SYMBOL(ib_create_qp);
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 7e440d4..e694f02 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1428,6 +1428,10 @@ struct ib_srq {
 	} ext;
 };
 
+/*
+ * @max_write_sge: Maximum SGE elements per RDMA WRITE request.
+ * @max_read_sge:  Maximum SGE elements per RDMA READ request.
+ */
 struct ib_qp {
 	struct ib_device       *device;
 	struct ib_pd	       *pd;
@@ -1449,6 +1453,8 @@ struct ib_qp {
 	void                  (*event_handler)(struct ib_event *, void *);
 	void		       *qp_context;
 	u32			qp_num;
+	u32			max_write_sge;
+	u32			max_read_sge;
 	enum ib_qp_type		qp_type;
 };
 
-- 
2.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v4 3/5] IB/srpt: Limit the number of SG elements per work request
       [not found] ` <75fc8647-16a6-5a89-400f-f5f418a8d6eb-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
  2016-07-21 20:03   ` [PATCH v4 1/5] IB/core: Make rdma_rw_ctx_init() initialize all used fields Bart Van Assche
  2016-07-21 20:03   ` [PATCH v4 2/5] IB/core, RDMA RW API: Do not exceed QP SGE send limit Bart Van Assche
@ 2016-07-21 20:03   ` Bart Van Assche
       [not found]     ` <446e3039-ec25-89d8-2583-5e60dd2bfc88-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
  2016-07-21 20:04   ` [PATCH v4 4/5] IB/srpt: Simplify srpt_queue_response() Bart Van Assche
                     ` (2 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Bart Van Assche @ 2016-07-21 20:03 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Christoph Hellwig, Sagi Grimberg, Steve Wise, Parav Pandit,
	Laurence Oberman, Nicholas A. Bellinger,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

Limit the number of SG elements per work request to what the HCA
and the queue pair support.

Fixes: 34693573fde0 ("IB/srpt: Reduce QP buffer size")
Reported-by: Parav Pandit <pandit.parav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
Cc: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
Cc: Sagi Grimberg <sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
Cc: Steve Wise <swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
Cc: Parav Pandit <pandit.parav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Nicholas Bellinger <nab-IzHhD5pYlfBP7FQvKIMDCQ@public.gmane.org>
Cc: Laurence Oberman <loberman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: <stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org> #v4.7+
---
 drivers/infiniband/ulp/srpt/ib_srpt.c | 3 ++-
 drivers/infiniband/ulp/srpt/ib_srpt.h | 6 +++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 4a41556..9a3b954 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -1601,6 +1601,7 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch)
 	struct ib_qp_init_attr *qp_init;
 	struct srpt_port *sport = ch->sport;
 	struct srpt_device *sdev = sport->sdev;
+	const struct ib_device_attr *attrs = &sdev->device->attrs;
 	u32 srp_sq_size = sport->port_attrib.srp_sq_size;
 	int ret;
 
@@ -1638,7 +1639,7 @@ retry:
 	 */
 	qp_init->cap.max_send_wr = srp_sq_size / 2;
 	qp_init->cap.max_rdma_ctxs = srp_sq_size / 2;
-	qp_init->cap.max_send_sge = SRPT_DEF_SG_PER_WQE;
+	qp_init->cap.max_send_sge = min(attrs->max_sge, SRPT_MAX_SG_PER_WQE);
 	qp_init->port_num = ch->sport->port;
 
 	ch->qp = ib_create_qp(sdev->pd, qp_init);
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.h b/drivers/infiniband/ulp/srpt/ib_srpt.h
index 3890304..5818787 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.h
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.h
@@ -106,7 +106,11 @@ enum {
 	SRP_LOGIN_RSP_MULTICHAN_MAINTAINED = 0x2,
 
 	SRPT_DEF_SG_TABLESIZE = 128,
-	SRPT_DEF_SG_PER_WQE = 16,
+	/*
+	 * An experimentally determined value that avoids that QP creation
+	 * fails due to "swiotlb buffer is full" on systems using the swiotlb.
+	 */
+	SRPT_MAX_SG_PER_WQE = 16,
 
 	MIN_SRPT_SQ_SIZE = 16,
 	DEF_SRPT_SQ_SIZE = 4096,
-- 
2.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v4 4/5] IB/srpt: Simplify srpt_queue_response()
       [not found] ` <75fc8647-16a6-5a89-400f-f5f418a8d6eb-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
                     ` (2 preceding siblings ...)
  2016-07-21 20:03   ` [PATCH v4 3/5] IB/srpt: Limit the number of SG elements per work request Bart Van Assche
@ 2016-07-21 20:04   ` Bart Van Assche
  2016-07-21 20:04   ` [PATCH v4 5/5] IB/isert: Remove an unused member variable Bart Van Assche
  2016-08-02 16:05   ` [PATCH v4 0/5] Reduce RDMA RW API SGE limit Doug Ledford
  5 siblings, 0 replies; 12+ messages in thread
From: Bart Van Assche @ 2016-07-21 20:04 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Christoph Hellwig, Sagi Grimberg, Steve Wise, Parav Pandit,
	Laurence Oberman, Nicholas A. Bellinger,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

Initialize first_wr to &send_wr. This allows to remove a ternary
operator and an else branch. This patch does not change the behavior
of srpt_queue_response().

Signed-off-by: Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
Reviewed-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
Reviewed-by: Sagi Grimberg <sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
Tested-by: Steve Wise <swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
Tested-by: Laurence Oberman <loberman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Parav Pandit <pandit.parav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Nicholas Bellinger <nab-IzHhD5pYlfBP7FQvKIMDCQ@public.gmane.org>
---
 drivers/infiniband/ulp/srpt/ib_srpt.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 9a3b954..dfa23b0 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -2262,7 +2262,7 @@ static void srpt_queue_response(struct se_cmd *cmd)
 		container_of(cmd, struct srpt_send_ioctx, cmd);
 	struct srpt_rdma_ch *ch = ioctx->ch;
 	struct srpt_device *sdev = ch->sport->sdev;
-	struct ib_send_wr send_wr, *first_wr = NULL, *bad_wr;
+	struct ib_send_wr send_wr, *first_wr = &send_wr, *bad_wr;
 	struct ib_sge sge;
 	enum srpt_command_state state;
 	unsigned long flags;
@@ -2303,11 +2303,8 @@ static void srpt_queue_response(struct se_cmd *cmd)
 			struct srpt_rw_ctx *ctx = &ioctx->rw_ctxs[i];
 
 			first_wr = rdma_rw_ctx_wrs(&ctx->rw, ch->qp,
-					ch->sport->port, NULL,
-					first_wr ? first_wr : &send_wr);
+					ch->sport->port, NULL, first_wr);
 		}
-	} else {
-		first_wr = &send_wr;
 	}
 
 	if (state != SRPT_STATE_MGMT)
-- 
2.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v4 5/5] IB/isert: Remove an unused member variable
       [not found] ` <75fc8647-16a6-5a89-400f-f5f418a8d6eb-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
                     ` (3 preceding siblings ...)
  2016-07-21 20:04   ` [PATCH v4 4/5] IB/srpt: Simplify srpt_queue_response() Bart Van Assche
@ 2016-07-21 20:04   ` Bart Van Assche
  2016-08-02 16:05   ` [PATCH v4 0/5] Reduce RDMA RW API SGE limit Doug Ledford
  5 siblings, 0 replies; 12+ messages in thread
From: Bart Van Assche @ 2016-07-21 20:04 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Christoph Hellwig, Sagi Grimberg, Steve Wise, Parav Pandit,
	Laurence Oberman, Nicholas A. Bellinger,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

Signed-off-by: Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
Reviewed-by: Sagi Grimberg <sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
Reviewed-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
Tested-by: Steve Wise <swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
Tested-by: Laurence Oberman <loberman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Parav Pandit <pandit.parav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Nicholas Bellinger <nab-IzHhD5pYlfBP7FQvKIMDCQ@public.gmane.org>
---
 drivers/infiniband/ulp/isert/ib_isert.c | 2 --
 drivers/infiniband/ulp/isert/ib_isert.h | 1 -
 2 files changed, 3 deletions(-)

diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index a990c04..ba6be06 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -137,8 +137,6 @@ isert_create_qp(struct isert_conn *isert_conn,
 	attr.cap.max_recv_wr = ISERT_QP_MAX_RECV_DTOS + 1;
 	attr.cap.max_rdma_ctxs = ISCSI_DEF_XMIT_CMDS_MAX;
 	attr.cap.max_send_sge = device->ib_device->attrs.max_sge;
-	isert_conn->max_sge = min(device->ib_device->attrs.max_sge,
-				  device->ib_device->attrs.max_sge_rd);
 	attr.cap.max_recv_sge = 1;
 	attr.sq_sig_type = IB_SIGNAL_REQ_WR;
 	attr.qp_type = IB_QPT_RC;
diff --git a/drivers/infiniband/ulp/isert/ib_isert.h b/drivers/infiniband/ulp/isert/ib_isert.h
index e512ba9..fc791ef 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.h
+++ b/drivers/infiniband/ulp/isert/ib_isert.h
@@ -138,7 +138,6 @@ struct isert_conn {
 	u32			responder_resources;
 	u32			initiator_depth;
 	bool			pi_support;
-	u32			max_sge;
 	struct iser_rx_desc	*login_req_buf;
 	char			*login_rsp_buf;
 	u64			login_req_dma;
-- 
2.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v4 2/5] IB/core, RDMA RW API: Do not exceed QP SGE send limit
       [not found]     ` <c71ece34-36e2-86da-5032-2fc946ff0073-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
@ 2016-07-27 12:42       ` Leon Romanovsky
       [not found]         ` <20160727124217.GJ4628-2ukJVAZIZ/Y@public.gmane.org>
  2016-08-01 10:56       ` Christoph Hellwig
  1 sibling, 1 reply; 12+ messages in thread
From: Leon Romanovsky @ 2016-07-27 12:42 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Doug Ledford, Christoph Hellwig, Sagi Grimberg, Steve Wise,
	Parav Pandit, Laurence Oberman, Nicholas A. Bellinger,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 2135 bytes --]

On Thu, Jul 21, 2016 at 01:03:30PM -0700, Bart Van Assche wrote:
> Compute the SGE limit for RDMA READ and WRITE requests in
> ib_create_qp(). Use that limit in the RDMA RW API implementation.
> 
> Signed-off-by: Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
> Cc: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
> Cc: Sagi Grimberg <sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
> Cc: Steve Wise <swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
> Cc: Parav Pandit <pandit.parav-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Cc: Nicholas Bellinger <nab-IzHhD5pYlfBP7FQvKIMDCQ@public.gmane.org>
> Cc: Laurence Oberman <loberman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> Cc: <stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org> #v4.7+
> ---
>  drivers/infiniband/core/rw.c    | 10 ++--------
>  drivers/infiniband/core/verbs.c |  9 +++++++++
>  include/rdma/ib_verbs.h         |  6 ++++++
>  3 files changed, 17 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/infiniband/core/rw.c b/drivers/infiniband/core/rw.c
> index 1ad2baa..dbfd854 100644
> --- a/drivers/infiniband/core/rw.c
> +++ b/drivers/infiniband/core/rw.c
> @@ -58,13 +58,6 @@ static inline bool rdma_rw_io_needs_mr(struct ib_device *dev, u8 port_num,
>  	return false;
>  }
>  
> -static inline u32 rdma_rw_max_sge(struct ib_device *dev,
> -		enum dma_data_direction dir)
> -{
> -	return dir == DMA_TO_DEVICE ?
> -		dev->attrs.max_sge : dev->attrs.max_sge_rd;
> -}
> -
>  static inline u32 rdma_rw_fr_page_list_len(struct ib_device *dev)
>  {
>  	/* arbitrary limit to avoid allocating gigantic resources */
> @@ -186,7 +179,8 @@ static int rdma_rw_init_map_wrs(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
>  		u64 remote_addr, u32 rkey, enum dma_data_direction dir)
>  {
>  	struct ib_device *dev = qp->pd->device;
> -	u32 max_sge = rdma_rw_max_sge(dev, dir);
> +	u32 max_sge = dir == DMA_TO_DEVICE ? qp->max_write_sge :
> +		      qp->max_read_sge;

Bart,
I'm sure that I missed something.

Can "dir" be DMA_BIDIRECTIONAL?
If yes, mxa_sge will be min(max_write_sge, max_read_sge).

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v4 2/5] IB/core, RDMA RW API: Do not exceed QP SGE send limit
       [not found]         ` <20160727124217.GJ4628-2ukJVAZIZ/Y@public.gmane.org>
@ 2016-07-27 15:24           ` Bart Van Assche
       [not found]             ` <8604bcdc-3ab4-28df-0eff-b1c0b6865c71-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Bart Van Assche @ 2016-07-27 15:24 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Doug Ledford, Christoph Hellwig, Sagi Grimberg, Steve Wise,
	Parav Pandit, Laurence Oberman, Nicholas A. Bellinger,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

On 07/27/2016 05:42 AM, Leon Romanovsky wrote:
> On Thu, Jul 21, 2016 at 01:03:30PM -0700, Bart Van Assche wrote:
>>  static inline u32 rdma_rw_fr_page_list_len(struct ib_device *dev)
>>  {
>>  	/* arbitrary limit to avoid allocating gigantic resources */
>> @@ -186,7 +179,8 @@ static int rdma_rw_init_map_wrs(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
>>  		u64 remote_addr, u32 rkey, enum dma_data_direction dir)
>>  {
>>  	struct ib_device *dev = qp->pd->device;
>> -	u32 max_sge = rdma_rw_max_sge(dev, dir);
>> +	u32 max_sge = dir == DMA_TO_DEVICE ? qp->max_write_sge :
>> +		      qp->max_read_sge;
>
> Bart,
> I'm sure that I missed something.
>
> Can "dir" be DMA_BIDIRECTIONAL?
> If yes, mxa_sge will be min(max_write_sge, max_read_sge).

Hello Leon,

The RDMA R/W API is intended for target drivers. None of the upstream 
target drivers (ib_isert, ib_srpt, nvmet) that use the RDMA R/W API 
support bidi commands today. And even if such support would be added, 
these target drivers should perform RDMA READs and WRITEs in two phases. 
So I do not expect that "dir" will ever be equal to DMA_BIDIRECTIONAL in 
the above code.

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v4 2/5] IB/core, RDMA RW API: Do not exceed QP SGE send limit
       [not found]             ` <8604bcdc-3ab4-28df-0eff-b1c0b6865c71-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
@ 2016-07-27 16:23               ` Leon Romanovsky
  0 siblings, 0 replies; 12+ messages in thread
From: Leon Romanovsky @ 2016-07-27 16:23 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Doug Ledford, Christoph Hellwig, Sagi Grimberg, Steve Wise,
	Parav Pandit, Laurence Oberman, Nicholas A. Bellinger,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 1521 bytes --]

On Wed, Jul 27, 2016 at 08:24:32AM -0700, Bart Van Assche wrote:
> On 07/27/2016 05:42 AM, Leon Romanovsky wrote:
> >On Thu, Jul 21, 2016 at 01:03:30PM -0700, Bart Van Assche wrote:
> >> static inline u32 rdma_rw_fr_page_list_len(struct ib_device *dev)
> >> {
> >> 	/* arbitrary limit to avoid allocating gigantic resources */
> >>@@ -186,7 +179,8 @@ static int rdma_rw_init_map_wrs(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
> >> 		u64 remote_addr, u32 rkey, enum dma_data_direction dir)
> >> {
> >> 	struct ib_device *dev = qp->pd->device;
> >>-	u32 max_sge = rdma_rw_max_sge(dev, dir);
> >>+	u32 max_sge = dir == DMA_TO_DEVICE ? qp->max_write_sge :
> >>+		      qp->max_read_sge;
> >
> >Bart,
> >I'm sure that I missed something.
> >
> >Can "dir" be DMA_BIDIRECTIONAL?
> >If yes, mxa_sge will be min(max_write_sge, max_read_sge).
> 
> Hello Leon,
> 
> The RDMA R/W API is intended for target drivers. None of the upstream target
> drivers (ib_isert, ib_srpt, nvmet) that use the RDMA R/W API support bidi
> commands today. And even if such support would be added, these target
> drivers should perform RDMA READs and WRITEs in two phases. So I do not
> expect that "dir" will ever be equal to DMA_BIDIRECTIONAL in the above code.
> 
> Bart.

Thanks Bart.

> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v4 2/5] IB/core, RDMA RW API: Do not exceed QP SGE send limit
       [not found]     ` <c71ece34-36e2-86da-5032-2fc946ff0073-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
  2016-07-27 12:42       ` Leon Romanovsky
@ 2016-08-01 10:56       ` Christoph Hellwig
  1 sibling, 0 replies; 12+ messages in thread
From: Christoph Hellwig @ 2016-08-01 10:56 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Doug Ledford, Christoph Hellwig, Sagi Grimberg, Steve Wise,
	Parav Pandit, Laurence Oberman, Nicholas A. Bellinger,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

Looks fine, thanks a lot Bart!

Reviewed-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v4 3/5] IB/srpt: Limit the number of SG elements per work request
       [not found]     ` <446e3039-ec25-89d8-2583-5e60dd2bfc88-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
@ 2016-08-01 10:57       ` Christoph Hellwig
  0 siblings, 0 replies; 12+ messages in thread
From: Christoph Hellwig @ 2016-08-01 10:57 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Doug Ledford, Christoph Hellwig, Sagi Grimberg, Steve Wise,
	Parav Pandit, Laurence Oberman, Nicholas A. Bellinger,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

On Thu, Jul 21, 2016 at 01:03:47PM -0700, Bart Van Assche wrote:
> Limit the number of SG elements per work request to what the HCA
> and the queue pair support.

Looks fine,

Reviewed-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v4 0/5] Reduce RDMA RW API SGE limit
       [not found] ` <75fc8647-16a6-5a89-400f-f5f418a8d6eb-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
                     ` (4 preceding siblings ...)
  2016-07-21 20:04   ` [PATCH v4 5/5] IB/isert: Remove an unused member variable Bart Van Assche
@ 2016-08-02 16:05   ` Doug Ledford
  5 siblings, 0 replies; 12+ messages in thread
From: Doug Ledford @ 2016-08-02 16:05 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Christoph Hellwig, Sagi Grimberg, Steve Wise, Parav Pandit,
	Laurence Oberman, Nicholas A. Bellinger,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 1545 bytes --]

On Thu, 2016-07-21 at 13:02 -0700, Bart Van Assche wrote:
> Hello Doug,
> 
> The five patches in this series modify the RDMA RW API slightly. This
> is 
> needed to avoid that the SRP and iSER target drivers submit RDMA 
> requests with an SGE list that exceeds the queue pair limits. The 
> ib_srpt changes in this series have been tested but the ib_isert
> changes 
> not yet.
> 
> The changes compared to v3 of this patch series are:
> * Split the single QP SGE limit into separate READ and WRITE SGE
> limits.
> * Added a comment in ib_srpt.h that explains where the SGE limit
> comes
>    from.
> 
> Changes compared to v2:
> * For RDMA READs, limit SGE back to dev->attrs.max_sge_rd for iWARP.
> 
> Changes compared to v1:
> * max_send_sge is now stored in struct ib_qp. This greatly simplifies
>     this patch series.
> * An unneeded initialization that I had added to
> rdma_rw_init_one_mr()
>     has been left out again.
> * Corrected "Fixes" tag in the patch description where needed.
> 
> The individual patches in this series are:
> 
> 0001-IB-core-Make-rdma_rw_ctx_init-initialize-all-used-fi.patch
> 0002-IB-core-RDMA-RW-API-Do-not-exceed-QP-SGE-send-limit.patch
> 0003-IB-srpt-Limit-the-number-of-SG-elements-per-work-req.patch
> 0004-IB-srpt-Simplify-srpt_queue_response.patch
> 0005-IB-isert-Remove-an-unused-member-variable.patch
> 

Thanks Bart, series applied.

-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
              GPG KeyID: 0E572FDD

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-08-02 16:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-21 20:02 [PATCH v4 0/5] Reduce RDMA RW API SGE limit Bart Van Assche
     [not found] ` <75fc8647-16a6-5a89-400f-f5f418a8d6eb-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2016-07-21 20:03   ` [PATCH v4 1/5] IB/core: Make rdma_rw_ctx_init() initialize all used fields Bart Van Assche
2016-07-21 20:03   ` [PATCH v4 2/5] IB/core, RDMA RW API: Do not exceed QP SGE send limit Bart Van Assche
     [not found]     ` <c71ece34-36e2-86da-5032-2fc946ff0073-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2016-07-27 12:42       ` Leon Romanovsky
     [not found]         ` <20160727124217.GJ4628-2ukJVAZIZ/Y@public.gmane.org>
2016-07-27 15:24           ` Bart Van Assche
     [not found]             ` <8604bcdc-3ab4-28df-0eff-b1c0b6865c71-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2016-07-27 16:23               ` Leon Romanovsky
2016-08-01 10:56       ` Christoph Hellwig
2016-07-21 20:03   ` [PATCH v4 3/5] IB/srpt: Limit the number of SG elements per work request Bart Van Assche
     [not found]     ` <446e3039-ec25-89d8-2583-5e60dd2bfc88-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2016-08-01 10:57       ` Christoph Hellwig
2016-07-21 20:04   ` [PATCH v4 4/5] IB/srpt: Simplify srpt_queue_response() Bart Van Assche
2016-07-21 20:04   ` [PATCH v4 5/5] IB/isert: Remove an unused member variable Bart Van Assche
2016-08-02 16:05   ` [PATCH v4 0/5] Reduce RDMA RW API SGE limit Doug Ledford

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.