From: Bernard Metzler <bernard.metzler@linux.dev>
To: Leon Romanovsky <leon@kernel.org>, Jason Gunthorpe <jgg@ziepe.ca>,
Selvin Xavier <selvin.xavier@broadcom.com>,
Kalesh AP <kalesh-anakkur.purayil@broadcom.com>,
Potnuri Bharat Teja <bharat@chelsio.com>,
Michael Margolin <mrgolin@amazon.com>,
Gal Pressman <gal.pressman@linux.dev>,
Yossi Leybovich <sleybo@amazon.com>,
Cheng Xu <chengyou@linux.alibaba.com>,
Kai Shen <kaishen@linux.alibaba.com>,
Chengchang Tang <tangchengchang@huawei.com>,
Junxian Huang <huangjunxian6@hisilicon.com>,
Abhijit Gangurde <abhijit.gangurde@amd.com>,
Allen Hubbe <allen.hubbe@amd.com>,
Krzysztof Czurylo <krzysztof.czurylo@intel.com>,
Tatyana Nikolova <tatyana.e.nikolova@intel.com>,
Long Li <longli@microsoft.com>,
Konstantin Taranov <kotaranov@microsoft.com>,
Yishai Hadas <yishaih@nvidia.com>,
Michal Kalderon <mkalderon@marvell.com>,
Bryan Tan <bryan-bt.tan@broadcom.com>,
Vishnu Dasa <vishnu.dasa@broadcom.com>,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>,
Christian Benvenuti <benve@cisco.com>,
Nelson Escobar <neescoba@cisco.com>,
Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>,
Zhu Yanjun <zyjzyj2000@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org,
linux-hyperv@vger.kernel.org
Subject: Re: [PATCH rdma-next 28/50] RDMA/siw: Split user and kernel CQ creation paths
Date: Fri, 13 Feb 2026 17:56:32 +0100 [thread overview]
Message-ID: <054452b7-7e08-4f8c-8010-e1b69c4b3997@linux.dev> (raw)
In-Reply-To: <20260213-refactor-umem-v1-28-f3be85847922@nvidia.com>
On 13.02.2026 11:58, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
>
> Separate the CQ creation logic into distinct kernel and user flows.
>
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> ---
> drivers/infiniband/sw/siw/siw_main.c | 1 +
> drivers/infiniband/sw/siw/siw_verbs.c | 111 +++++++++++++++++++++++-----------
> drivers/infiniband/sw/siw/siw_verbs.h | 2 +
> 3 files changed, 80 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/infiniband/sw/siw/siw_main.c b/drivers/infiniband/sw/siw/siw_main.c
> index 5168307229a9..75dcf3578eac 100644
> --- a/drivers/infiniband/sw/siw/siw_main.c
> +++ b/drivers/infiniband/sw/siw/siw_main.c
> @@ -232,6 +232,7 @@ static const struct ib_device_ops siw_device_ops = {
> .alloc_pd = siw_alloc_pd,
> .alloc_ucontext = siw_alloc_ucontext,
> .create_cq = siw_create_cq,
> + .create_user_cq = siw_create_user_cq,
> .create_qp = siw_create_qp,
> .create_srq = siw_create_srq,
> .dealloc_driver = siw_device_cleanup,
> diff --git a/drivers/infiniband/sw/siw/siw_verbs.c b/drivers/infiniband/sw/siw/siw_verbs.c
> index efa2f097b582..92b25b389b69 100644
> --- a/drivers/infiniband/sw/siw/siw_verbs.c
> +++ b/drivers/infiniband/sw/siw/siw_verbs.c
> @@ -1139,15 +1139,15 @@ int siw_destroy_cq(struct ib_cq *base_cq, struct ib_udata *udata)
> * @attrs: uverbs bundle
> */
>
> -int siw_create_cq(struct ib_cq *base_cq, const struct ib_cq_init_attr *attr,
> - struct uverbs_attr_bundle *attrs)
> +int siw_create_user_cq(struct ib_cq *base_cq, const struct ib_cq_init_attr *attr,
> + struct uverbs_attr_bundle *attrs)
> {
> struct ib_udata *udata = &attrs->driver_udata;
> struct siw_device *sdev = to_siw_dev(base_cq->device);
> struct siw_cq *cq = to_siw_cq(base_cq);
> int rv, size = attr->cqe;
>
> - if (attr->flags)
> + if (attr->flags || base_cq->umem)
> return -EOPNOTSUPP;
>
> if (atomic_inc_return(&sdev->num_cq) > SIW_MAX_CQ) {
> @@ -1155,7 +1155,7 @@ int siw_create_cq(struct ib_cq *base_cq, const struct ib_cq_init_attr *attr,
> rv = -ENOMEM;
> goto err_out;
> }
> - if (size < 1 || size > sdev->attrs.max_cqe) {
> + if (attr->cqe > sdev->attrs.max_cqe) {
> siw_dbg(base_cq->device, "CQ size error: %d\n", size);
> rv = -EINVAL;
> goto err_out;
> @@ -1164,13 +1164,8 @@ int siw_create_cq(struct ib_cq *base_cq, const struct ib_cq_init_attr *attr,
> cq->base_cq.cqe = size;
> cq->num_cqe = size;
>
> - if (udata)
> - cq->queue = vmalloc_user(size * sizeof(struct siw_cqe) +
> - sizeof(struct siw_cq_ctrl));
> - else
> - cq->queue = vzalloc(size * sizeof(struct siw_cqe) +
> - sizeof(struct siw_cq_ctrl));
> -
> + cq->queue = vmalloc_user(size * sizeof(struct siw_cqe) +
> + sizeof(struct siw_cq_ctrl));
> if (cq->queue == NULL) {
> rv = -ENOMEM;
> goto err_out;
> @@ -1182,33 +1177,32 @@ int siw_create_cq(struct ib_cq *base_cq, const struct ib_cq_init_attr *attr,
>
> cq->notify = (struct siw_cq_ctrl *)&cq->queue[size];
>
> - if (udata) {
> - struct siw_uresp_create_cq uresp = {};
> - struct siw_ucontext *ctx =
> - rdma_udata_to_drv_context(udata, struct siw_ucontext,
> - base_ucontext);
> - size_t length = size * sizeof(struct siw_cqe) +
> - sizeof(struct siw_cq_ctrl);
> + struct siw_uresp_create_cq uresp = {};
> + struct siw_ucontext *ctx =
> + rdma_udata_to_drv_context(udata, struct siw_ucontext,
> + base_ucontext);
> + size_t length = size * sizeof(struct siw_cqe) +
> + sizeof(struct siw_cq_ctrl);
>
> - cq->cq_entry =
> - siw_mmap_entry_insert(ctx, cq->queue,
> - length, &uresp.cq_key);
> - if (!cq->cq_entry) {
> - rv = -ENOMEM;
> - goto err_out;
> - }
> + cq->cq_entry =
> + siw_mmap_entry_insert(ctx, cq->queue,
> + length, &uresp.cq_key);
> + if (!cq->cq_entry) {
> + rv = -ENOMEM;
> + goto err_out;
> + }
>
> - uresp.cq_id = cq->id;
> - uresp.num_cqe = size;
> + uresp.cq_id = cq->id;
> + uresp.num_cqe = size;
>
> - if (udata->outlen < sizeof(uresp)) {
> - rv = -EINVAL;
> - goto err_out;
> - }
> - rv = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
> - if (rv)
> - goto err_out;
> + if (udata->outlen < sizeof(uresp)) {
> + rv = -EINVAL;
> + goto err_out;
> }
> + rv = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
> + if (rv)
> + goto err_out;
> +
> return 0;
>
> err_out:
> @@ -1227,6 +1221,55 @@ int siw_create_cq(struct ib_cq *base_cq, const struct ib_cq_init_attr *attr,
> return rv;
> }
>
> +int siw_create_cq(struct ib_cq *base_cq, const struct ib_cq_init_attr *attr,
> + struct uverbs_attr_bundle *attrs)
> +{
> + struct siw_device *sdev = to_siw_dev(base_cq->device);
> + struct siw_cq *cq = to_siw_cq(base_cq);
> + int rv, size = attr->cqe;
> +
> + if (attr->flags)
> + return -EOPNOTSUPP;
> +
> + if (atomic_inc_return(&sdev->num_cq) > SIW_MAX_CQ) {
> + siw_dbg(base_cq->device, "too many CQ's\n");
> + rv = -ENOMEM;
> + goto err_out;
> + }
> + if (size < 1 || size > sdev->attrs.max_cqe) {
isn't there now also a check for zero sized CQ in
__ib_alloc_cq(), which obsoletes that < 1 check?
Everything looks right otherwise.
Thanks,
Bernard.
> + siw_dbg(base_cq->device, "CQ size error: %d\n", size);
> + rv = -EINVAL;
> + goto err_out;
> + }
> + size = roundup_pow_of_two(size);
> + cq->base_cq.cqe = size;
> + cq->num_cqe = size;
> +
> + cq->queue = vzalloc(size * sizeof(struct siw_cqe) +
> + sizeof(struct siw_cq_ctrl));
> + if (cq->queue == NULL) {
> + rv = -ENOMEM;
> + goto err_out;
> + }
> + get_random_bytes(&cq->id, 4);
> + siw_dbg(base_cq->device, "new CQ [%u]\n", cq->id);
> +
> + spin_lock_init(&cq->lock);
> +
> + cq->notify = (struct siw_cq_ctrl *)&cq->queue[size];
> +
> + return 0;
> +
> +err_out:
> + siw_dbg(base_cq->device, "CQ creation failed: %d", rv);
> +
> + if (cq->queue)
> + vfree(cq->queue);
> + atomic_dec(&sdev->num_cq);
> +
> + return rv;
> +}
> +
> /*
> * siw_poll_cq()
> *
> diff --git a/drivers/infiniband/sw/siw/siw_verbs.h b/drivers/infiniband/sw/siw/siw_verbs.h
> index e9f4463aecdc..527c356b55af 100644
> --- a/drivers/infiniband/sw/siw/siw_verbs.h
> +++ b/drivers/infiniband/sw/siw/siw_verbs.h
> @@ -44,6 +44,8 @@ int siw_query_device(struct ib_device *base_dev, struct ib_device_attr *attr,
> struct ib_udata *udata);
> int siw_create_cq(struct ib_cq *base_cq, const struct ib_cq_init_attr *attr,
> struct uverbs_attr_bundle *attrs);
> +int siw_create_user_cq(struct ib_cq *base_cq, const struct ib_cq_init_attr *attr,
> + struct uverbs_attr_bundle *attrs);
> int siw_query_port(struct ib_device *base_dev, u32 port,
> struct ib_port_attr *attr);
> int siw_query_gid(struct ib_device *base_dev, u32 port, int idx,
>
next prev parent reply other threads:[~2026-02-13 16:56 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-13 10:57 [PATCH rdma-next 00/50] RDMA: Ensure CQ UMEMs are managed by ib_core Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 01/50] RDMA: Move DMA block iterator logic into dedicated files Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 02/50] RDMA/umem: Allow including ib_umem header from any location Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 03/50] RDMA/umem: Remove unnecessary includes and defines from ib_umem header Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 04/50] RDMA/core: Promote UMEM to a core component Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 05/50] RDMA/core: Manage CQ umem in core code Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 06/50] RDMA/efa: Rely on CPU address in create‑QP Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 07/50] RDMA/core: Prepare create CQ path for API unification Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 08/50] RDMA/core: Reject zero CQE count Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 09/50] RDMA/efa: Remove check for " Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 10/50] RDMA/mlx5: Save 4 bytes in CQ structure Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 11/50] RDMA/mlx5: Provide a modern CQ creation interface Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 12/50] RDMA/mlx4: Inline mlx4_ib_get_cq_umem into callers Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 13/50] RDMA/mlx4: Introduce a modern CQ creation interface Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 14/50] RDMA/mlx4: Remove unused create_flags field from CQ structure Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 15/50] RDMA/bnxt_re: Convert to modern CQ interface Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 16/50] RDMA/cxgb4: Separate kernel and user CQ creation paths Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 17/50] RDMA/mthca: Split user and kernel " Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 18/50] RDMA/erdma: Separate " Leon Romanovsky
2026-02-24 5:51 ` Cheng Xu
2026-02-24 10:57 ` Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 19/50] RDMA/ionic: Split " Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 20/50] RDMA/qedr: Convert to modern CQ interface Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 21/50] RDMA/vmw_pvrdma: Provide a modern CQ creation interface Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 22/50] RDMA/ocrdma: Split user and kernel CQ creation paths Leon Romanovsky
2026-02-13 10:57 ` [PATCH rdma-next 23/50] RDMA/irdma: " Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 24/50] RDMA/usnic: Provide a modern CQ creation interface Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 25/50] RDMA/mana: " Leon Romanovsky
2026-02-24 22:30 ` [EXTERNAL] " Long Li
2026-02-25 8:24 ` Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 26/50] RDMA/erdma: Separate user and kernel CQ creation paths Leon Romanovsky
2026-02-24 2:20 ` Cheng Xu
2026-02-24 10:46 ` Leon Romanovsky
2026-02-26 6:17 ` Junxian Huang
2026-02-26 6:54 ` Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 27/50] RDMA/rdmavt: Split " Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 28/50] RDMA/siw: " Leon Romanovsky
2026-02-13 16:56 ` Bernard Metzler [this message]
2026-02-13 21:17 ` Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 29/50] RDMA/rxe: " Leon Romanovsky
2026-02-13 23:22 ` yanjun.zhu
2026-02-15 7:06 ` Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 30/50] RDMA/core: Remove legacy CQ creation fallback path Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 31/50] RDMA/core: Remove unused ib_resize_cq() implementation Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 32/50] RDMA: Clarify that CQ resize is a user‑space verb Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 33/50] RDMA/bnxt_re: Drop support for resizing kernel CQs Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 34/50] RDMA/irdma: Remove resize support for " Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 35/50] RDMA/mlx4: Remove support for kernel CQ resize Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 36/50] RDMA/mlx5: Remove support for resizing kernel CQs Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 37/50] RDMA/mthca: Remove resize support for " Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 38/50] RDMA/rdmavt: " Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 39/50] RDMA/rxe: Remove unused kernel‑side CQ resize support Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 40/50] RDMA: Properly propagate the number of CQEs as unsigned int Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 41/50] RDMA/core: Generalize CQ resize locking Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 42/50] RDMA/bnxt_re: Complete CQ resize in a single step Leon Romanovsky
2026-02-16 3:59 ` Selvin Xavier
2026-02-16 8:07 ` Leon Romanovsky
2026-02-17 5:02 ` Selvin Xavier
2026-02-17 7:56 ` Leon Romanovsky
2026-02-17 10:52 ` Selvin Xavier
2026-02-19 8:02 ` Selvin Xavier
2026-02-24 8:15 ` Selvin Xavier
2026-02-24 10:59 ` Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 43/50] RDMA/bnxt_re: Rely on common resize‑CQ locking Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 44/50] RDMA/bnxt_re: Reduce CQ memory footprint Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 45/50] RDMA/mlx4: Use generic resize-CQ lock Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 46/50] RDMA/mlx4: Use on‑stack variables instead of storing them in the CQ object Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 47/50] RDMA/mlx5: Use generic resize-CQ lock Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 48/50] RDMA/mlx5: Select resize‑CQ callback based on device capabilities Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 49/50] RDMA/mlx5: Reduce CQ memory footprint Leon Romanovsky
2026-02-13 10:58 ` [PATCH rdma-next 50/50] RDMA/mthca: Use generic resize-CQ lock Leon Romanovsky
2026-02-25 13:51 ` (subset) [PATCH rdma-next 00/50] RDMA: Ensure CQ UMEMs are managed by ib_core Leon Romanovsky
2026-02-25 13:53 ` Leon Romanovsky
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=054452b7-7e08-4f8c-8010-e1b69c4b3997@linux.dev \
--to=bernard.metzler@linux.dev \
--cc=abhijit.gangurde@amd.com \
--cc=allen.hubbe@amd.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=benve@cisco.com \
--cc=bharat@chelsio.com \
--cc=bryan-bt.tan@broadcom.com \
--cc=chengyou@linux.alibaba.com \
--cc=dennis.dalessandro@cornelisnetworks.com \
--cc=gal.pressman@linux.dev \
--cc=huangjunxian6@hisilicon.com \
--cc=jgg@ziepe.ca \
--cc=kaishen@linux.alibaba.com \
--cc=kalesh-anakkur.purayil@broadcom.com \
--cc=kotaranov@microsoft.com \
--cc=krzysztof.czurylo@intel.com \
--cc=leon@kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=mkalderon@marvell.com \
--cc=mrgolin@amazon.com \
--cc=neescoba@cisco.com \
--cc=selvin.xavier@broadcom.com \
--cc=sleybo@amazon.com \
--cc=tangchengchang@huawei.com \
--cc=tatyana.e.nikolova@intel.com \
--cc=vishnu.dasa@broadcom.com \
--cc=yishaih@nvidia.com \
--cc=zyjzyj2000@gmail.com \
/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