> Subject: RE: [PATCHv2 1/1] RDMA/irdma: Add support for dmabuf pin memory > regions > [......] > > + > > + switch (req.reg_type) { > > + case IRDMA_MEMREG_TYPE_QP: > > + total = req.sq_pages + req.rq_pages + shadow_pgcnt; > > + if (total > iwmr->page_cnt) { > > + err = -EINVAL; > > + goto error; > > + } > > + total = req.sq_pages + req.rq_pages; > > + use_pbles = (total > 2); > > + err = irdma_handle_q_mem(iwdev, &req, iwpbl, use_pbles); > > + if (err) > > + goto error; > > + > > + ucontext = rdma_udata_to_drv_context(udata, struct > > irdma_ucontext, > > + ibucontext); > > + spin_lock_irqsave(&ucontext->qp_reg_mem_list_lock, flags); > > + list_add_tail(&iwpbl->list, &ucontext->qp_reg_mem_list); > > + iwpbl->on_list = true; > > + spin_unlock_irqrestore(&ucontext->qp_reg_mem_list_lock, flags); > > + break; > > + case IRDMA_MEMREG_TYPE_CQ: > > + if (iwdev->rf->sc_dev.hw_attrs.uk_attrs.feature_flags & > > IRDMA_FEATURE_CQ_RESIZE) > > + shadow_pgcnt = 0; > > + total = req.cq_pages + shadow_pgcnt; > > + if (total > iwmr->page_cnt) { > > + err = -EINVAL; > > + goto error; > > + } > > + > > + use_pbles = (req.cq_pages > 1); > > + err = irdma_handle_q_mem(iwdev, &req, iwpbl, use_pbles); > > + if (err) > > + goto error; > > + > > + ucontext = rdma_udata_to_drv_context(udata, struct > > irdma_ucontext, > > + ibucontext); > > + spin_lock_irqsave(&ucontext->cq_reg_mem_list_lock, flags); > > + list_add_tail(&iwpbl->list, &ucontext->cq_reg_mem_list); > > + iwpbl->on_list = true; > > + spin_unlock_irqrestore(&ucontext->cq_reg_mem_list_lock, flags); > > + break; > > I don't think we want to do this for user QP, CQ pinned memory. In fact, it will just > be dead-code. > > The irdma provider implementation of the ibv_reg_dmabuf_mr will just default to > IRDMA_MEMREG_TYPE_MEM type similar to how irdma_ureg_mr is implemented. > > https://github.com/linux-rdma/rdma- > core/blob/master/providers/irdma/uverbs.c#L128 > > It should simplify this function a lot. > > Actually I don't see a need even to use the irdma_mem_reg_req ABI struct to pass any info from user-space like reg_type. Shiraz