Re: [PATCH rdma-next 4/5] RDMA/irdma: Support UMEM attribute for CQ creation
From: Leon Romanovsky
Date: Mon Oct 12 2026 - 11:33:01 EST
On Sun, Oct 11, 2026 at 01:10:21AM +0000, David Hu wrote:
> From: David Hu <xuehaohu@xxxxxxxxxx>
>
> 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@xxxxxxxxxx>
> ---
> 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