Lines Matching refs:uctx
191 static int ocrdma_add_mmap(struct ocrdma_ucontext *uctx, u64 phy_addr,
203 mutex_lock(&uctx->mm_list_lock);
204 list_add_tail(&mm->entry, &uctx->mm_head);
205 mutex_unlock(&uctx->mm_list_lock);
209 static void ocrdma_del_mmap(struct ocrdma_ucontext *uctx, u64 phy_addr,
214 mutex_lock(&uctx->mm_list_lock);
215 list_for_each_entry_safe(mm, tmp, &uctx->mm_head, entry) {
223 mutex_unlock(&uctx->mm_list_lock);
226 static bool ocrdma_search_mmap(struct ocrdma_ucontext *uctx, u64 phy_addr,
232 mutex_lock(&uctx->mm_list_lock);
233 list_for_each_entry(mm, &uctx->mm_head, entry) {
240 mutex_unlock(&uctx->mm_list_lock);
356 struct ocrdma_ucontext *uctx,
361 if (udata && uctx && dev->attr.max_dpp_pds) {
386 static inline int is_ucontext_pd(struct ocrdma_ucontext *uctx,
389 return (uctx->cntxt_pd == pd);
402 struct ocrdma_ucontext *uctx,
414 uctx->cntxt_pd = get_ocrdma_pd(pd);
416 status = _ocrdma_alloc_pd(dev, uctx->cntxt_pd, uctx, udata);
418 kfree(uctx->cntxt_pd);
422 uctx->cntxt_pd->uctx = uctx;
423 uctx->cntxt_pd->ibpd.device = &dev->ibdev;
428 static void ocrdma_dealloc_ucontext_pd(struct ocrdma_ucontext *uctx)
430 struct ocrdma_pd *pd = uctx->cntxt_pd;
433 if (uctx->pd_in_use) {
437 uctx->cntxt_pd = NULL;
442 static struct ocrdma_pd *ocrdma_get_ucontext_pd(struct ocrdma_ucontext *uctx)
446 mutex_lock(&uctx->mm_list_lock);
447 if (!uctx->pd_in_use) {
448 uctx->pd_in_use = true;
449 pd = uctx->cntxt_pd;
451 mutex_unlock(&uctx->mm_list_lock);
456 static void ocrdma_release_ucontext_pd(struct ocrdma_ucontext *uctx)
458 mutex_lock(&uctx->mm_list_lock);
459 uctx->pd_in_use = false;
460 mutex_unlock(&uctx->mm_list_lock);
463 int ocrdma_alloc_ucontext(struct ib_ucontext *uctx, struct ib_udata *udata)
465 struct ib_device *ibdev = uctx->device;
467 struct ocrdma_ucontext *ctx = get_ocrdma_ucontext(uctx);
521 struct ocrdma_ucontext *uctx = get_ocrdma_ucontext(ibctx);
525 ocrdma_dealloc_ucontext_pd(uctx);
527 ocrdma_del_mmap(uctx, uctx->ah_tbl.pa, uctx->ah_tbl.len);
528 dma_free_coherent(&pdev->dev, uctx->ah_tbl.len, uctx->ah_tbl.va,
529 uctx->ah_tbl.pa);
531 list_for_each_entry_safe(mm, tmp, &uctx->mm_head, entry) {
588 struct ocrdma_ucontext *uctx = rdma_udata_to_drv_context(
597 status = ocrdma_add_mmap(uctx, db_page_addr, db_page_size);
604 status = ocrdma_add_mmap(uctx, dpp_page_addr,
616 pd->uctx = uctx;
621 ocrdma_del_mmap(pd->uctx, dpp_page_addr, PAGE_SIZE);
623 ocrdma_del_mmap(pd->uctx, db_page_addr, db_page_size);
634 struct ocrdma_ucontext *uctx = rdma_udata_to_drv_context(
638 pd = ocrdma_get_ucontext_pd(uctx);
646 status = _ocrdma_alloc_pd(dev, pd, uctx, udata);
660 ocrdma_release_ucontext_pd(uctx);
671 struct ocrdma_ucontext *uctx = NULL;
674 uctx = pd->uctx;
675 if (uctx) {
679 ocrdma_del_mmap(pd->uctx, dpp_db, PAGE_SIZE);
681 ocrdma_del_mmap(pd->uctx, usr_db, dev->nic_info.db_page_size);
683 if (is_ucontext_pd(uctx, pd)) {
684 ocrdma_release_ucontext_pd(uctx);
927 struct ocrdma_ucontext *uctx = rdma_udata_to_drv_context(
941 uresp.db_page_addr = ocrdma_get_db_addr(dev, uctx->cntxt_pd->id);
950 status = ocrdma_add_mmap(uctx, uresp.db_page_addr, uresp.db_page_size);
953 status = ocrdma_add_mmap(uctx, uresp.page_addr[0], uresp.page_size);
955 ocrdma_del_mmap(uctx, uresp.db_page_addr, uresp.db_page_size);
958 cq->ucontext = uctx;
970 struct ocrdma_ucontext *uctx = rdma_udata_to_drv_context(
991 pd_id = uctx->cntxt_pd->id;
1210 status = ocrdma_add_mmap(pd->uctx, uresp.sq_page_addr[0],
1216 status = ocrdma_add_mmap(pd->uctx, uresp.rq_page_addr[0],
1223 ocrdma_del_mmap(pd->uctx, uresp.sq_page_addr[0], uresp.sq_page_size);
1710 if (!pd->uctx) {
1716 if (pd->uctx) {
1717 ocrdma_del_mmap(pd->uctx, (u64) qp->sq.pa,
1720 ocrdma_del_mmap(pd->uctx, (u64) qp->rq.pa,
1758 status = ocrdma_add_mmap(srq->pd->uctx, uresp.rq_page_addr[0],
1862 if (srq->pd->uctx)
1863 ocrdma_del_mmap(srq->pd->uctx, (u64) srq->rq.pa,