diff options
| -rw-r--r-- | drivers/infiniband/hw/cxgb3/iwch_mem.c | 21 | ||||
| -rw-r--r-- | drivers/infiniband/hw/cxgb3/iwch_provider.c | 50 |
2 files changed, 49 insertions, 22 deletions
diff --git a/drivers/infiniband/hw/cxgb3/iwch_mem.c b/drivers/infiniband/hw/cxgb3/iwch_mem.c index ec49a5cbdeb..e1ec65ebb01 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_mem.c +++ b/drivers/infiniband/hw/cxgb3/iwch_mem.c | |||
| @@ -39,7 +39,7 @@ | |||
| 39 | #include "iwch.h" | 39 | #include "iwch.h" |
| 40 | #include "iwch_provider.h" | 40 | #include "iwch_provider.h" |
| 41 | 41 | ||
| 42 | static void iwch_finish_mem_reg(struct iwch_mr *mhp, u32 stag) | 42 | static int iwch_finish_mem_reg(struct iwch_mr *mhp, u32 stag) |
| 43 | { | 43 | { |
| 44 | u32 mmid; | 44 | u32 mmid; |
| 45 | 45 | ||
| @@ -47,14 +47,15 @@ static void iwch_finish_mem_reg(struct iwch_mr *mhp, u32 stag) | |||
| 47 | mhp->attr.stag = stag; | 47 | mhp->attr.stag = stag; |
| 48 | mmid = stag >> 8; | 48 | mmid = stag >> 8; |
| 49 | mhp->ibmr.rkey = mhp->ibmr.lkey = stag; | 49 | mhp->ibmr.rkey = mhp->ibmr.lkey = stag; |
| 50 | insert_handle(mhp->rhp, &mhp->rhp->mmidr, mhp, mmid); | ||
| 51 | PDBG("%s mmid 0x%x mhp %p\n", __func__, mmid, mhp); | 50 | PDBG("%s mmid 0x%x mhp %p\n", __func__, mmid, mhp); |
| 51 | return insert_handle(mhp->rhp, &mhp->rhp->mmidr, mhp, mmid); | ||
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | int iwch_register_mem(struct iwch_dev *rhp, struct iwch_pd *php, | 54 | int iwch_register_mem(struct iwch_dev *rhp, struct iwch_pd *php, |
| 55 | struct iwch_mr *mhp, int shift) | 55 | struct iwch_mr *mhp, int shift) |
| 56 | { | 56 | { |
| 57 | u32 stag; | 57 | u32 stag; |
| 58 | int ret; | ||
| 58 | 59 | ||
| 59 | if (cxio_register_phys_mem(&rhp->rdev, | 60 | if (cxio_register_phys_mem(&rhp->rdev, |
| 60 | &stag, mhp->attr.pdid, | 61 | &stag, mhp->attr.pdid, |
| @@ -66,9 +67,11 @@ int iwch_register_mem(struct iwch_dev *rhp, struct iwch_pd *php, | |||
| 66 | mhp->attr.pbl_size, mhp->attr.pbl_addr)) | 67 | mhp->attr.pbl_size, mhp->attr.pbl_addr)) |
| 67 | return -ENOMEM; | 68 | return -ENOMEM; |
| 68 | 69 | ||
| 69 | iwch_finish_mem_reg(mhp, stag); | 70 | ret = iwch_finish_mem_reg(mhp, stag); |
| 70 | 71 | if (ret) | |
| 71 | return 0; | 72 | cxio_dereg_mem(&rhp->rdev, mhp->attr.stag, mhp->attr.pbl_size, |
| 73 | mhp->attr.pbl_addr); | ||
| 74 | return ret; | ||
| 72 | } | 75 | } |
| 73 | 76 | ||
| 74 | int iwch_reregister_mem(struct iwch_dev *rhp, struct iwch_pd *php, | 77 | int iwch_reregister_mem(struct iwch_dev *rhp, struct iwch_pd *php, |
| @@ -77,6 +80,7 @@ int iwch_reregister_mem(struct iwch_dev *rhp, struct iwch_pd *php, | |||
| 77 | int npages) | 80 | int npages) |
| 78 | { | 81 | { |
| 79 | u32 stag; | 82 | u32 stag; |
| 83 | int ret; | ||
| 80 | 84 | ||
| 81 | /* We could support this... */ | 85 | /* We could support this... */ |
| 82 | if (npages > mhp->attr.pbl_size) | 86 | if (npages > mhp->attr.pbl_size) |
| @@ -93,9 +97,12 @@ int iwch_reregister_mem(struct iwch_dev *rhp, struct iwch_pd *php, | |||
| 93 | mhp->attr.pbl_size, mhp->attr.pbl_addr)) | 97 | mhp->attr.pbl_size, mhp->attr.pbl_addr)) |
| 94 | return -ENOMEM; | 98 | return -ENOMEM; |
| 95 | 99 | ||
| 96 | iwch_finish_mem_reg(mhp, stag); | 100 | ret = iwch_finish_mem_reg(mhp, stag); |
| 101 | if (ret) | ||
| 102 | cxio_dereg_mem(&rhp->rdev, mhp->attr.stag, mhp->attr.pbl_size, | ||
| 103 | mhp->attr.pbl_addr); | ||
| 97 | 104 | ||
| 98 | return 0; | 105 | return ret; |
| 99 | } | 106 | } |
| 100 | 107 | ||
| 101 | int iwch_alloc_pbl(struct iwch_mr *mhp, int npages) | 108 | int iwch_alloc_pbl(struct iwch_mr *mhp, int npages) |
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c index 72aa57cdf69..6895523779d 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_provider.c +++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c | |||
| @@ -195,7 +195,11 @@ static struct ib_cq *iwch_create_cq(struct ib_device *ibdev, int entries, int ve | |||
| 195 | spin_lock_init(&chp->lock); | 195 | spin_lock_init(&chp->lock); |
| 196 | atomic_set(&chp->refcnt, 1); | 196 | atomic_set(&chp->refcnt, 1); |
| 197 | init_waitqueue_head(&chp->wait); | 197 | init_waitqueue_head(&chp->wait); |
| 198 | insert_handle(rhp, &rhp->cqidr, chp, chp->cq.cqid); | 198 | if (insert_handle(rhp, &rhp->cqidr, chp, chp->cq.cqid)) { |
| 199 | cxio_destroy_cq(&chp->rhp->rdev, &chp->cq); | ||
| 200 | kfree(chp); | ||
| 201 | return ERR_PTR(-ENOMEM); | ||
| 202 | } | ||
| 199 | 203 | ||
| 200 | if (ucontext) { | 204 | if (ucontext) { |
| 201 | struct iwch_mm_entry *mm; | 205 | struct iwch_mm_entry *mm; |
| @@ -750,7 +754,11 @@ static struct ib_mw *iwch_alloc_mw(struct ib_pd *pd) | |||
| 750 | mhp->attr.stag = stag; | 754 | mhp->attr.stag = stag; |
| 751 | mmid = (stag) >> 8; | 755 | mmid = (stag) >> 8; |
| 752 | mhp->ibmw.rkey = stag; | 756 | mhp->ibmw.rkey = stag; |
| 753 | insert_handle(rhp, &rhp->mmidr, mhp, mmid); | 757 | if (insert_handle(rhp, &rhp->mmidr, mhp, mmid)) { |
| 758 | cxio_deallocate_window(&rhp->rdev, mhp->attr.stag); | ||
| 759 | kfree(mhp); | ||
| 760 | return ERR_PTR(-ENOMEM); | ||
| 761 | } | ||
| 754 | PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag); | 762 | PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag); |
| 755 | return &(mhp->ibmw); | 763 | return &(mhp->ibmw); |
| 756 | } | 764 | } |
| @@ -778,37 +786,43 @@ static struct ib_mr *iwch_alloc_fast_reg_mr(struct ib_pd *pd, int pbl_depth) | |||
| 778 | struct iwch_mr *mhp; | 786 | struct iwch_mr *mhp; |
| 779 | u32 mmid; | 787 | u32 mmid; |
| 780 | u32 stag = 0; | 788 | u32 stag = 0; |
| 781 | int ret; | 789 | int ret = 0; |
| 782 | 790 | ||
| 783 | php = to_iwch_pd(pd); | 791 | php = to_iwch_pd(pd); |
| 784 | rhp = php->rhp; | 792 | rhp = php->rhp; |
| 785 | mhp = kzalloc(sizeof(*mhp), GFP_KERNEL); | 793 | mhp = kzalloc(sizeof(*mhp), GFP_KERNEL); |
| 786 | if (!mhp) | 794 | if (!mhp) |
| 787 | return ERR_PTR(-ENOMEM); | 795 | goto err; |
| 788 | 796 | ||
| 789 | mhp->rhp = rhp; | 797 | mhp->rhp = rhp; |
| 790 | ret = iwch_alloc_pbl(mhp, pbl_depth); | 798 | ret = iwch_alloc_pbl(mhp, pbl_depth); |
| 791 | if (ret) { | 799 | if (ret) |
| 792 | kfree(mhp); | 800 | goto err1; |
| 793 | return ERR_PTR(ret); | ||
| 794 | } | ||
| 795 | mhp->attr.pbl_size = pbl_depth; | 801 | mhp->attr.pbl_size = pbl_depth; |
| 796 | ret = cxio_allocate_stag(&rhp->rdev, &stag, php->pdid, | 802 | ret = cxio_allocate_stag(&rhp->rdev, &stag, php->pdid, |
| 797 | mhp->attr.pbl_size, mhp->attr.pbl_addr); | 803 | mhp->attr.pbl_size, mhp->attr.pbl_addr); |
| 798 | if (ret) { | 804 | if (ret) |
| 799 | iwch_free_pbl(mhp); | 805 | goto err2; |
| 800 | kfree(mhp); | ||
| 801 | return ERR_PTR(ret); | ||
| 802 | } | ||
| 803 | mhp->attr.pdid = php->pdid; | 806 | mhp->attr.pdid = php->pdid; |
| 804 | mhp->attr.type = TPT_NON_SHARED_MR; | 807 | mhp->attr.type = TPT_NON_SHARED_MR; |
| 805 | mhp->attr.stag = stag; | 808 | mhp->attr.stag = stag; |
| 806 | mhp->attr.state = 1; | 809 | mhp->attr.state = 1; |
| 807 | mmid = (stag) >> 8; | 810 | mmid = (stag) >> 8; |
| 808 | mhp->ibmr.rkey = mhp->ibmr.lkey = stag; | 811 | mhp->ibmr.rkey = mhp->ibmr.lkey = stag; |
| 809 | insert_handle(rhp, &rhp->mmidr, mhp, mmid); | 812 | if (insert_handle(rhp, &rhp->mmidr, mhp, mmid)) |
| 813 | goto err3; | ||
| 814 | |||
| 810 | PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag); | 815 | PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag); |
| 811 | return &(mhp->ibmr); | 816 | return &(mhp->ibmr); |
| 817 | err3: | ||
| 818 | cxio_dereg_mem(&rhp->rdev, stag, mhp->attr.pbl_size, | ||
| 819 | mhp->attr.pbl_addr); | ||
| 820 | err2: | ||
| 821 | iwch_free_pbl(mhp); | ||
| 822 | err1: | ||
| 823 | kfree(mhp); | ||
| 824 | err: | ||
| 825 | return ERR_PTR(ret); | ||
| 812 | } | 826 | } |
| 813 | 827 | ||
| 814 | static struct ib_fast_reg_page_list *iwch_alloc_fastreg_pbl( | 828 | static struct ib_fast_reg_page_list *iwch_alloc_fastreg_pbl( |
| @@ -961,7 +975,13 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd, | |||
| 961 | spin_lock_init(&qhp->lock); | 975 | spin_lock_init(&qhp->lock); |
| 962 | init_waitqueue_head(&qhp->wait); | 976 | init_waitqueue_head(&qhp->wait); |
| 963 | atomic_set(&qhp->refcnt, 1); | 977 | atomic_set(&qhp->refcnt, 1); |
| 964 | insert_handle(rhp, &rhp->qpidr, qhp, qhp->wq.qpid); | 978 | |
| 979 | if (insert_handle(rhp, &rhp->qpidr, qhp, qhp->wq.qpid)) { | ||
| 980 | cxio_destroy_qp(&rhp->rdev, &qhp->wq, | ||
| 981 | ucontext ? &ucontext->uctx : &rhp->rdev.uctx); | ||
| 982 | kfree(qhp); | ||
| 983 | return ERR_PTR(-ENOMEM); | ||
| 984 | } | ||
| 965 | 985 | ||
| 966 | if (udata) { | 986 | if (udata) { |
| 967 | 987 | ||
