Lines Matching refs:cq
655 struct mthca_cq *cq; in mthca_create_cq() local
682 cq = kmalloc(sizeof *cq, GFP_KERNEL); in mthca_create_cq()
683 if (!cq) { in mthca_create_cq()
689 cq->buf.mr.ibmr.lkey = ucmd.lkey; in mthca_create_cq()
690 cq->set_ci_db_index = ucmd.set_db_index; in mthca_create_cq()
691 cq->arm_db_index = ucmd.arm_db_index; in mthca_create_cq()
700 cq); in mthca_create_cq()
704 if (context && ib_copy_to_udata(udata, &cq->cqn, sizeof (__u32))) { in mthca_create_cq()
705 mthca_free_cq(to_mdev(ibdev), cq); in mthca_create_cq()
710 cq->resize_buf = NULL; in mthca_create_cq()
712 return &cq->ibcq; in mthca_create_cq()
715 kfree(cq); in mthca_create_cq()
730 static int mthca_alloc_resize_buf(struct mthca_dev *dev, struct mthca_cq *cq, in mthca_alloc_resize_buf() argument
735 spin_lock_irq(&cq->lock); in mthca_alloc_resize_buf()
736 if (cq->resize_buf) { in mthca_alloc_resize_buf()
741 cq->resize_buf = kmalloc(sizeof *cq->resize_buf, GFP_ATOMIC); in mthca_alloc_resize_buf()
742 if (!cq->resize_buf) { in mthca_alloc_resize_buf()
747 cq->resize_buf->state = CQ_RESIZE_ALLOC; in mthca_alloc_resize_buf()
752 spin_unlock_irq(&cq->lock); in mthca_alloc_resize_buf()
757 ret = mthca_alloc_cq_buf(dev, &cq->resize_buf->buf, entries); in mthca_alloc_resize_buf()
759 spin_lock_irq(&cq->lock); in mthca_alloc_resize_buf()
760 kfree(cq->resize_buf); in mthca_alloc_resize_buf()
761 cq->resize_buf = NULL; in mthca_alloc_resize_buf()
762 spin_unlock_irq(&cq->lock); in mthca_alloc_resize_buf()
766 cq->resize_buf->cqe = entries - 1; in mthca_alloc_resize_buf()
768 spin_lock_irq(&cq->lock); in mthca_alloc_resize_buf()
769 cq->resize_buf->state = CQ_RESIZE_READY; in mthca_alloc_resize_buf()
770 spin_unlock_irq(&cq->lock); in mthca_alloc_resize_buf()
778 struct mthca_cq *cq = to_mcq(ibcq); in mthca_resize_cq() local
786 mutex_lock(&cq->mutex); in mthca_resize_cq()
794 if (cq->is_kernel) { in mthca_resize_cq()
795 ret = mthca_alloc_resize_buf(dev, cq, entries); in mthca_resize_cq()
798 lkey = cq->resize_buf->buf.mr.ibmr.lkey; in mthca_resize_cq()
807 ret = mthca_RESIZE_CQ(dev, cq->cqn, lkey, ilog2(entries)); in mthca_resize_cq()
810 if (cq->resize_buf) { in mthca_resize_cq()
811 mthca_free_cq_buf(dev, &cq->resize_buf->buf, in mthca_resize_cq()
812 cq->resize_buf->cqe); in mthca_resize_cq()
813 kfree(cq->resize_buf); in mthca_resize_cq()
814 spin_lock_irq(&cq->lock); in mthca_resize_cq()
815 cq->resize_buf = NULL; in mthca_resize_cq()
816 spin_unlock_irq(&cq->lock); in mthca_resize_cq()
821 if (cq->is_kernel) { in mthca_resize_cq()
825 spin_lock_irq(&cq->lock); in mthca_resize_cq()
826 if (cq->resize_buf->state == CQ_RESIZE_READY) { in mthca_resize_cq()
827 mthca_cq_resize_copy_cqes(cq); in mthca_resize_cq()
828 tbuf = cq->buf; in mthca_resize_cq()
829 tcqe = cq->ibcq.cqe; in mthca_resize_cq()
830 cq->buf = cq->resize_buf->buf; in mthca_resize_cq()
831 cq->ibcq.cqe = cq->resize_buf->cqe; in mthca_resize_cq()
833 tbuf = cq->resize_buf->buf; in mthca_resize_cq()
834 tcqe = cq->resize_buf->cqe; in mthca_resize_cq()
837 kfree(cq->resize_buf); in mthca_resize_cq()
838 cq->resize_buf = NULL; in mthca_resize_cq()
839 spin_unlock_irq(&cq->lock); in mthca_resize_cq()
846 mutex_unlock(&cq->mutex); in mthca_resize_cq()
851 static int mthca_destroy_cq(struct ib_cq *cq) in mthca_destroy_cq() argument
853 if (cq->uobject) { in mthca_destroy_cq()
854 mthca_unmap_user_db(to_mdev(cq->device), in mthca_destroy_cq()
855 &to_mucontext(cq->uobject->context)->uar, in mthca_destroy_cq()
856 to_mucontext(cq->uobject->context)->db_tab, in mthca_destroy_cq()
857 to_mcq(cq)->arm_db_index); in mthca_destroy_cq()
858 mthca_unmap_user_db(to_mdev(cq->device), in mthca_destroy_cq()
859 &to_mucontext(cq->uobject->context)->uar, in mthca_destroy_cq()
860 to_mucontext(cq->uobject->context)->db_tab, in mthca_destroy_cq()
861 to_mcq(cq)->set_ci_db_index); in mthca_destroy_cq()
863 mthca_free_cq(to_mdev(cq->device), to_mcq(cq)); in mthca_destroy_cq()
864 kfree(cq); in mthca_destroy_cq()