linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guoqing Jiang <guoqing.jiang@linux.dev>
To: bmt@zurich.ibm.com, jgg@ziepe.ca, leon@kernel.org
Cc: linux-rdma@vger.kernel.org
Subject: [PATCH V2 18/20] RDMA/siw: Only check attrs->cap.max_send_wr in siw_create_qp
Date: Fri, 13 Oct 2023 10:00:51 +0800	[thread overview]
Message-ID: <20231013020053.2120-19-guoqing.jiang@linux.dev> (raw)
In-Reply-To: <20231013020053.2120-1-guoqing.jiang@linux.dev>

We can just check max_send_wr here given both max_send_wr and
max_recv_wr are defined as u32 type, and we also need to ensure
num_sqe (derived from max_send_wr) shouldn't be zero.

Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
---
 drivers/infiniband/sw/siw/siw_verbs.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/infiniband/sw/siw/siw_verbs.c b/drivers/infiniband/sw/siw/siw_verbs.c
index dcd69fc01176..ef149ed98946 100644
--- a/drivers/infiniband/sw/siw/siw_verbs.c
+++ b/drivers/infiniband/sw/siw/siw_verbs.c
@@ -333,11 +333,10 @@ int siw_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attrs,
 		goto err_atomic;
 	}
 	/*
-	 * NOTE: we allow for zero element SQ and RQ WQE's SGL's
-	 * but not for a QP unable to hold any WQE (SQ + RQ)
+	 * NOTE: we don't allow for a QP unable to hold any SQ WQE
 	 */
-	if (attrs->cap.max_send_wr + attrs->cap.max_recv_wr == 0) {
-		siw_dbg(base_dev, "QP must have send or receive queue\n");
+	if (attrs->cap.max_send_wr == 0) {
+		siw_dbg(base_dev, "QP must have send queue\n");
 		rv = -EINVAL;
 		goto err_atomic;
 	}
@@ -357,21 +356,14 @@ int siw_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attrs,
 	if (rv)
 		goto err_atomic;
 
-	num_sqe = attrs->cap.max_send_wr;
-	num_rqe = attrs->cap.max_recv_wr;
 
 	/* All queue indices are derived from modulo operations
 	 * on a free running 'get' (consumer) and 'put' (producer)
 	 * unsigned counter. Having queue sizes at power of two
 	 * avoids handling counter wrap around.
 	 */
-	if (num_sqe)
-		num_sqe = roundup_pow_of_two(num_sqe);
-	else {
-		/* Zero sized SQ is not supported */
-		rv = -EINVAL;
-		goto err_out_xa;
-	}
+	num_sqe = roundup_pow_of_two(attrs->cap.max_send_wr);
+	num_rqe = attrs->cap.max_recv_wr;
 	if (num_rqe)
 		num_rqe = roundup_pow_of_two(num_rqe);
 
-- 
2.35.3


  parent reply	other threads:[~2023-10-13  2:01 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-13  2:00 [PATCH V2 00/20] Cleanup for siw Guoqing Jiang
2023-10-13  2:00 ` [PATCH V2 01/20] RDMA/siw: Introduce siw_get_page Guoqing Jiang
2023-10-13  2:00 ` [PATCH V2 02/20] RDMA/siw: Introduce siw_srx_update_skb Guoqing Jiang
2023-10-13  2:00 ` [PATCH V2 03/20] RDMA/siw: Use iov.iov_len in kernel_sendmsg Guoqing Jiang
2023-10-13  2:00 ` [PATCH V2 04/20] RDMA/siw: Remove goto lable in siw_mmap Guoqing Jiang
2023-10-13  2:00 ` [PATCH V2 05/20] RDMA/siw: Remove rcu from siw_qp Guoqing Jiang
2023-10-13  2:00 ` [PATCH V2 06/20] RDMA/siw: No need to check term_info.valid before call siw_send_terminate Guoqing Jiang
2023-10-13  2:00 ` [PATCH V2 07/20] RDMA/siw: Also goto out_sem_up if pin_user_pages returns 0 Guoqing Jiang
2023-10-13  2:00 ` [PATCH V2 08/20] RDMA/siw: Factor out siw_generic_rx helper Guoqing Jiang
2023-10-13  2:00 ` [PATCH V2 09/20] RDMA/siw: Introduce SIW_STAG_MAX_INDEX Guoqing Jiang
2023-10-13  2:00 ` [PATCH V2 10/20] RDMA/siw: Add one parameter to siw_destroy_cpulist Guoqing Jiang
2023-10-13  2:00 ` [PATCH V2 11/20] RDMA/siw: Introduce siw_cep_set_free_and_put Guoqing Jiang
2023-10-13  2:00 ` [PATCH V2 12/20] RDMA/siw: Introduce siw_free_cm_id Guoqing Jiang
2023-10-13  2:00 ` [PATCH V2 13/20] RDMA/siw: Simplify siw_qp_id2obj Guoqing Jiang
2023-10-13  2:00 ` [PATCH V2 14/20] RDMA/siw: Simplify siw_mem_id2obj Guoqing Jiang
2023-10-13  2:00 ` [PATCH V2 15/20] RDMA/siw: Cleanup siw_accept Guoqing Jiang
2023-10-13  2:00 ` [PATCH V2 16/20] RDMA/siw: Remove siw_sk_assign_cm_upcalls Guoqing Jiang
2023-10-13  2:00 ` [PATCH V2 17/20] RDMA/siw: Fix typo Guoqing Jiang
2023-10-25 13:22   ` Bernard Metzler
2023-10-13  2:00 ` Guoqing Jiang [this message]
2023-10-25 13:27   ` [PATCH V2 18/20] RDMA/siw: Only check attrs->cap.max_send_wr in siw_create_qp Bernard Metzler
2023-10-26  6:55     ` Guoqing Jiang
2023-10-26 14:00       ` Bernard Metzler
2023-10-13  2:00 ` [PATCH V2 19/20] RDMA/siw: Introduce siw_destroy_cep_sock Guoqing Jiang
2023-10-25 13:28   ` Bernard Metzler
2023-10-13  2:00 ` [PATCH V2 20/20] RDMA/siw: Update comments for siw_qp_sq_process Guoqing Jiang
2023-10-25 13:29   ` Bernard Metzler
2023-10-24 14:09 ` [PATCH V2 00/20] Cleanup for siw Leon Romanovsky
2023-10-24 17:22   ` Bernard Metzler
2023-10-24 18:19     ` Leon Romanovsky
2023-10-25 13:37 ` Bernard Metzler
2023-10-26  7:02   ` Guoqing Jiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231013020053.2120-19-guoqing.jiang@linux.dev \
    --to=guoqing.jiang@linux.dev \
    --cc=bmt@zurich.ibm.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).