Lines Matching defs:uctx
193 static int ocrdma_add_mmap(struct ocrdma_ucontext *uctx, u64 phy_addr,
205 mutex_lock(&uctx->mm_list_lock);
206 list_add_tail(&mm->entry, &uctx->mm_head);
207 mutex_unlock(&uctx->mm_list_lock);
211 static void ocrdma_del_mmap(struct ocrdma_ucontext *uctx, u64 phy_addr,
216 mutex_lock(&uctx->mm_list_lock);
217 list_for_each_entry_safe(mm, tmp, &uctx->mm_head, entry) {
225 mutex_unlock(&uctx->mm_list_lock);
228 static bool ocrdma_search_mmap(struct ocrdma_ucontext *uctx, u64 phy_addr,
234 mutex_lock(&uctx->mm_list_lock);
235 list_for_each_entry(mm, &uctx->mm_head, entry) {
242 mutex_unlock(&uctx->mm_list_lock);
358 struct ocrdma_ucontext *uctx,
363 if (udata && uctx && dev->attr.max_dpp_pds) {
388 static inline int is_ucontext_pd(struct ocrdma_ucontext *uctx,
391 return (uctx->cntxt_pd == pd);
404 struct ocrdma_ucontext *uctx,
416 uctx->cntxt_pd = get_ocrdma_pd(pd);
418 status = _ocrdma_alloc_pd(dev, uctx->cntxt_pd, uctx, udata);
420 kfree(uctx->cntxt_pd);
424 uctx->cntxt_pd->uctx = uctx;
425 uctx->cntxt_pd->ibpd.device = &dev->ibdev;
430 static void ocrdma_dealloc_ucontext_pd(struct ocrdma_ucontext *uctx)
432 struct ocrdma_pd *pd = uctx->cntxt_pd;
435 if (uctx->pd_in_use) {
439 uctx->cntxt_pd = NULL;
444 static struct ocrdma_pd *ocrdma_get_ucontext_pd(struct ocrdma_ucontext *uctx)
448 mutex_lock(&uctx->mm_list_lock);
449 if (!uctx->pd_in_use) {
450 uctx->pd_in_use = true;
451 pd = uctx->cntxt_pd;
453 mutex_unlock(&uctx->mm_list_lock);
458 static void ocrdma_release_ucontext_pd(struct ocrdma_ucontext *uctx)
460 mutex_lock(&uctx->mm_list_lock);
461 uctx->pd_in_use = false;
462 mutex_unlock(&uctx->mm_list_lock);
465 int ocrdma_alloc_ucontext(struct ib_ucontext *uctx, struct ib_udata *udata)
467 struct ib_device *ibdev = uctx->device;
469 struct ocrdma_ucontext *ctx = get_ocrdma_ucontext(uctx);
523 struct ocrdma_ucontext *uctx = get_ocrdma_ucontext(ibctx);
527 ocrdma_dealloc_ucontext_pd(uctx);
529 ocrdma_del_mmap(uctx, uctx->ah_tbl.pa, uctx->ah_tbl.len);
530 dma_free_coherent(&pdev->dev, uctx->ah_tbl.len, uctx->ah_tbl.va,
531 uctx->ah_tbl.pa);
533 list_for_each_entry_safe(mm, tmp, &uctx->mm_head, entry) {
590 struct ocrdma_ucontext *uctx = rdma_udata_to_drv_context(
599 status = ocrdma_add_mmap(uctx, db_page_addr, db_page_size);
606 status = ocrdma_add_mmap(uctx, dpp_page_addr,
618 pd->uctx = uctx;
623 ocrdma_del_mmap(pd->uctx, dpp_page_addr, PAGE_SIZE);
625 ocrdma_del_mmap(pd->uctx, db_page_addr, db_page_size);
636 struct ocrdma_ucontext *uctx = rdma_udata_to_drv_context(
640 pd = ocrdma_get_ucontext_pd(uctx);
648 status = _ocrdma_alloc_pd(dev, pd, uctx, udata);
662 ocrdma_release_ucontext_pd(uctx);
673 struct ocrdma_ucontext *uctx = NULL;
676 uctx = pd->uctx;
677 if (uctx) {
681 ocrdma_del_mmap(pd->uctx, dpp_db, PAGE_SIZE);
683 ocrdma_del_mmap(pd->uctx, usr_db, dev->nic_info.db_page_size);
685 if (is_ucontext_pd(uctx, pd)) {
686 ocrdma_release_ucontext_pd(uctx);
933 struct ocrdma_ucontext *uctx = rdma_udata_to_drv_context(
947 uresp.db_page_addr = ocrdma_get_db_addr(dev, uctx->cntxt_pd->id);
956 status = ocrdma_add_mmap(uctx, uresp.db_page_addr, uresp.db_page_size);
959 status = ocrdma_add_mmap(uctx, uresp.page_addr[0], uresp.page_size);
961 ocrdma_del_mmap(uctx, uresp.db_page_addr, uresp.db_page_size);
964 cq->ucontext = uctx;
977 struct ocrdma_ucontext *uctx = rdma_udata_to_drv_context(
998 pd_id = uctx->cntxt_pd->id;
1217 status = ocrdma_add_mmap(pd->uctx, uresp.sq_page_addr[0],
1223 status = ocrdma_add_mmap(pd->uctx, uresp.rq_page_addr[0],
1230 ocrdma_del_mmap(pd->uctx, uresp.sq_page_addr[0], uresp.sq_page_size);
1715 if (!pd->uctx) {
1721 if (pd->uctx) {
1722 ocrdma_del_mmap(pd->uctx, (u64) qp->sq.pa,
1725 ocrdma_del_mmap(pd->uctx, (u64) qp->rq.pa,
1762 status = ocrdma_add_mmap(srq->pd->uctx, uresp.rq_page_addr[0],
1867 if (srq->pd->uctx)
1868 ocrdma_del_mmap(srq->pd->uctx, (u64) srq->rq.pa,