Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: David Hu <dhu@x6u.co>
Cc: Tatyana Nikolova <tatyana.e.nikolova@intel.com>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	jmoroni@google.com, eagleshaw@google.com,
	David Hu <xuehaohu@google.com>
Subject: Re: [PATCH rdma-next 4/5] RDMA/irdma: Support UMEM attribute for CQ creation
Date: Mon, 12 Oct 2026 17:17:25 +0300	[thread overview]
Message-ID: <20261012141725.GG219304@unreal> (raw)
In-Reply-To: <20261011011022.1445352-5-dhu@x6u.co>

On Sun, Oct 11, 2026 at 01:10:21AM +0000, David Hu wrote:
> From: David Hu <xuehaohu@google.com>
> 
> Support the standard 1-step queue buffer creation
> model for CQ by `UVERBS_ATTR_CREATE_CQ_BUF_UMEM`,
> `IRDMA_IB_ATTR_CREATE_CQ_SHADOW_BUF_UMEM` via
> `ib_umem_get_attr()`.
> 
> Set up hardware pble directly from the pinned CQ and
> shadow umems via `irdma_setup_q_pbl_from_umem()`.
> 
> Proper umem and pble cleanup are added into existing
> `irdma_cq_free_rsrc()` upon CQ destruction.
> 
> We maintain backward compatibility for
> legacy 2-step registration if UMEM attributes are
> not provided.
> 
> Signed-off-by: David Hu <xuehaohu@google.com>
> ---
>  drivers/infiniband/hw/irdma/verbs.c | 110 +++++++++++++++++++++++-----
>  1 file changed, 93 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/irdma/verbs.c b/drivers/infiniband/hw/irdma/verbs.c
> index ab25445f3828..e4a02a6b2a11 100644
> --- a/drivers/infiniband/hw/irdma/verbs.c
> +++ b/drivers/infiniband/hw/irdma/verbs.c
> @@ -2028,13 +2028,24 @@ static void irdma_cq_free_rsrc(struct irdma_pci_f *rf, struct irdma_cq *iwcq)
>  		if (iwcq->iwpbl) {
>  			iwmr = iwcq->iwpbl->iwmr;
>  
> -			refcount_dec(&iwmr->user_ring_refs);
> +			if (iwmr && refcount_dec_and_test(&iwmr->user_ring_refs)) {
> +				ib_umem_release(iwmr->region);
> +				if (iwcq->iwpbl->pbl_allocated)
> +					irdma_free_pble(rf->pble_rsrc, &iwcq->iwpbl->pble_alloc);
> +				kfree(iwmr);
> +			}
>  		}
>  
>  		if (iwcq->iwpbl_shadow) {
>  			iwmr = iwcq->iwpbl_shadow->iwmr;
>  
> -			refcount_dec(&iwmr->user_ring_refs);
> +			if (iwmr && refcount_dec_and_test(&iwmr->user_ring_refs)) {
> +				ib_umem_release(iwmr->region);
> +				if (iwcq->iwpbl_shadow->pbl_allocated)
> +					irdma_free_pble(rf->pble_rsrc,
> +							&iwcq->iwpbl_shadow->pble_alloc);
> +				kfree(iwmr);
> +			}
>  		}
>  	}
>  
> @@ -2708,29 +2719,94 @@ static int irdma_create_cq(struct ib_cq *ibcq,
>  		if (err_code)
>  			goto cq_free_rsrc;
>  
> -		spin_lock_irqsave(&ucontext->cq_reg_mem_list_lock, flags);
> -		iwcq->iwpbl = irdma_get_pbl((unsigned long)req.user_cq_buf,
> -					    &ucontext->cq_reg_mem_list);
> -		spin_unlock_irqrestore(&ucontext->cq_reg_mem_list_lock, flags);
> -		if (!iwcq->iwpbl) {
> -			err_code = -EPROTO;
> -			goto cq_free_rsrc;
> -		}
> +		if (attrs && uverbs_attr_is_valid(attrs, UVERBS_ATTR_CREATE_CQ_BUF_UMEM)) {

While making this change, it’s a good opportunity to split
irdma_create_cq() into kernel and user paths.

Also, please keep commit-message lines around 75–80 characters. There’s no
need to wrap them at 50 characters.

Thanks

  parent reply	other threads:[~2026-10-12 14:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-11  1:10 [PATCH rdma-next 0/5] RDMA/irdma: Add support for ioctl David Hu
2026-10-11  1:10 ` [PATCH rdma-next 1/5] RDMA/irdma: Plumb uverbs_attr_bundle for QP, SRQ David Hu
2026-10-11  1:18   ` sashiko-bot
2026-10-11  1:10 ` [PATCH rdma-next 2/5] RDMA/irdma: Register irdma UVERBS ioctl namespace David Hu
2026-10-11  1:20   ` sashiko-bot
2026-10-11  1:10 ` [PATCH rdma-next 3/5] RDMA/irdma: Support UMEM attribute for QP creation David Hu
2026-10-11  1:22   ` sashiko-bot
2026-10-11  1:10 ` [PATCH rdma-next 4/5] RDMA/irdma: Support UMEM attribute for CQ creation David Hu
2026-10-11  1:27   ` sashiko-bot
2026-10-12 14:17   ` Leon Romanovsky [this message]
2026-10-12 21:15     ` David Hu
2026-10-11  1:10 ` [PATCH rdma-next 5/5] RDMA/irdma: Support UMEM attribute for SRQ creation David Hu
2026-10-11  1:22   ` sashiko-bot

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=20261012141725.GG219304@unreal \
    --to=leon@kernel.org \
    --cc=dhu@x6u.co \
    --cc=eagleshaw@google.com \
    --cc=jgg@ziepe.ca \
    --cc=jmoroni@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=tatyana.e.nikolova@intel.com \
    --cc=xuehaohu@google.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