History

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma

Pull more rdma fixes from Doug Ledford: "As per my previous pull request, there were two drivers that each had a rather large number of legitimate fixes still to be sent. As it turned out, I also missed a reasonably large set of fixes from one person across the stack that are all important fixes. All in all, the bnxt_re, i40iw, and Dan Carpenter are 3/4 to 2/3rds of this pull request. There were some other random fixes that I didn't send in the last pull request that I added to this one. This catches the rdma stack up to the fixes from up to about the beginning of this week. Any more fixes I'll wait and batch up later in the -rc cycle. This will give us a good base to start with for basing a for-next branch on -rc2. Summary: - i40iw fixes - bnxt_re fixes - Dan Carpenter bugfixes across stack - ten more random fixes, no more than two from any one person" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma: (37 commits) RDMA/core: Initialize port_num in qp_attr RDMA/uverbs: Fix the check for port number IB/cma: Fix reference count leak when no ipv4 addresses are set RDMA/iser: don't send an rkey if all data is written as immadiate-data rxe: fix broken receive queue draining RDMA/qedr: Prevent memory overrun in verbs' user responses iw_cxgb4: don't use WR keys/addrs for 0 byte reads IB/mlx4: Fix CM REQ retries in paravirt mode IB/rdmavt: Setting of QP timeout can overflow jiffies computation IB/core: Fix sparse warnings RDMA/bnxt_re: Fix the value reported for local ack delay RDMA/bnxt_re: Report MISSED_EVENTS in req_notify_cq RDMA/bnxt_re: Fix return value of poll routine RDMA/bnxt_re: Enable atomics only if host bios supports RDMA/bnxt_re: Specify RDMA component when allocating stats context RDMA/bnxt_re: Fixed the max_rd_atomic support for initiator and destination QP RDMA/bnxt_re: Report supported value to IB stack in query_device RDMA/bnxt_re: Do not free the ctx_tbl entry if delete GID fails RDMA/bnxt_re: Fix WQE Size posted to HW to prevent it from throwing error RDMA/bnxt_re: Free doorbell page index (DPI) during dealloc ucontext ...

Linus Torvalds committed 9 years ago

Commit bb236db2 parents 24a1635 a62ab6632 files · +306 −119Browse files

Unified · Split

32 files
  1. drivers/infiniband/core/cma.c +2 −0
  2. drivers/infiniband/core/uverbs_cmd.c +2 −11
  3. drivers/infiniband/hw/bnxt_re/bnxt_re.h +9 −0
  4. drivers/infiniband/hw/bnxt_re/ib_verbs.c +72 −47
  5. drivers/infiniband/hw/bnxt_re/ib_verbs.h +1 −2
  6. drivers/infiniband/hw/bnxt_re/main.c +1 −0
  7. drivers/infiniband/hw/bnxt_re/qplib_fp.c +29 −0
  8. drivers/infiniband/hw/bnxt_re/qplib_fp.h +1 −0
  9. drivers/infiniband/hw/bnxt_re/qplib_sp.c +16 −0
  10. drivers/infiniband/hw/bnxt_re/qplib_sp.h +3 −0
  11. drivers/infiniband/hw/cxgb3/iwch_provider.c +4 −5
  12. drivers/infiniband/hw/cxgb4/cq.c +1 −0
  13. drivers/infiniband/hw/cxgb4/qp.c +1 −1
  14. drivers/infiniband/hw/i40iw/i40iw.h +1 −0
  15. drivers/infiniband/hw/i40iw/i40iw_cm.c +4 −1
  16. drivers/infiniband/hw/i40iw/i40iw_ctrl.c +2 −0
  17. drivers/infiniband/hw/i40iw/i40iw_main.c +30 −30
  18. drivers/infiniband/hw/i40iw/i40iw_puda.c +4 −1
  19. drivers/infiniband/hw/i40iw/i40iw_utils.c +58 −2
  20. drivers/infiniband/hw/i40iw/i40iw_verbs.c +14 −5
  21. drivers/infiniband/hw/i40iw/i40iw_verbs.h +1 −1
  22. drivers/infiniband/hw/mlx4/cm.c +4 −0
  23. drivers/infiniband/hw/mlx5/mr.c +1 −1
  24. drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +3 −1
  25. drivers/infiniband/hw/qedr/verbs.c +12 −4
  26. drivers/infiniband/sw/rdmavt/qp.c +1 −3
  27. drivers/infiniband/sw/rxe/rxe_resp.c +3 −0
  28. drivers/infiniband/sw/rxe/rxe_verbs.c +3 −0
  29. drivers/infiniband/ulp/ipoib/ipoib_main.c +1 −0
  30. drivers/infiniband/ulp/iser/iser_initiator.c +4 −2
  31. include/rdma/ib_addr.h +4 −2
  32. include/rdma/rdmavt_qp.h +14 −0
drivers/infiniband/core/cma.c+2−0
@@ -1033,6 +1033,8 @@ int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr, · 1032 unmodified lines
10331033 } else
10341034 ret = iw_cm_init_qp_attr(id_priv->cm_id.iw, qp_attr,
10351035 qp_attr_mask);
1036+ qp_attr->port_num = id_priv->id.port_num;
1037+ *qp_attr_mask |= IB_QP_PORT;
10361038 } else
10371039 ret = -ENOSYS;
10381040
drivers/infiniband/core/uverbs_cmd.c+2−11
@@ -1296,7 +1296,6 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file, · 1295 unmodified lines
12961296 struct ib_uobject *uobj;
12971297 struct ib_cq *cq;
12981298 struct ib_ucq_object *obj;
1299− struct ib_uverbs_event_queue *ev_queue;
13001299 int ret = -EINVAL;
13011300
13021301 if (copy_from_user(&cmd, buf, sizeof cmd))
@@ -1313,7 +1312,6 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file, · 10 unmodified lines
13131312 */
13141313 uverbs_uobject_get(uobj);
13151314 cq = uobj->object;
1316− ev_queue = cq->cq_context;
13171315 obj = container_of(cq->uobject, struct ib_ucq_object, uobject);
13181316
13191317 memset(&resp, 0, sizeof(resp));
@@ -1935,7 +1933,8 @@ static int modify_qp(struct ib_uverbs_file *file, · 615 unmodified lines
19351933 goto out;
19361934 }
19371935
1938− if (!rdma_is_port_valid(qp->device, cmd->base.port_num)) {
1936+ if ((cmd->base.attr_mask & IB_QP_PORT) &&
1937+ !rdma_is_port_valid(qp->device, cmd->base.port_num)) {
19391938 ret = -EINVAL;
19401939 goto release_qp;
19411940 }
@@ -2088,7 +2087,6 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file, · 146 unmodified lines
20882087 struct ib_uverbs_destroy_qp cmd;
20892088 struct ib_uverbs_destroy_qp_resp resp;
20902089 struct ib_uobject *uobj;
2091− struct ib_qp *qp;
20922090 struct ib_uqp_object *obj;
20932091 int ret = -EINVAL;
20942092
@@ -2102,7 +2100,6 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file, · 7 unmodified lines
21022100 if (IS_ERR(uobj))
21032101 return PTR_ERR(uobj);
21042102
2105− qp = uobj->object;
21062103 obj = container_of(uobj, struct ib_uqp_object, uevent.uobject);
21072104 /*
21082105 * Make sure we don't free the memory in remove_commit as we still
@@ -3004,7 +3001,6 @@ int ib_uverbs_ex_destroy_wq(struct ib_uverbs_file *file, · 895 unmodified lines
30043001 {
30053002 struct ib_uverbs_ex_destroy_wq cmd = {};
30063003 struct ib_uverbs_ex_destroy_wq_resp resp = {};
3007− struct ib_wq *wq;
30083004 struct ib_uobject *uobj;
30093005 struct ib_uwq_object *obj;
30103006 size_t required_cmd_sz;
@@ -3038,7 +3034,6 @@ int ib_uverbs_ex_destroy_wq(struct ib_uverbs_file *file, · 27 unmodified lines
30383034 if (IS_ERR(uobj))
30393035 return PTR_ERR(uobj);
30403036
3041− wq = uobj->object;
30423037 obj = container_of(uobj, struct ib_uwq_object, uevent.uobject);
30433038 /*
30443039 * Make sure we don't free the memory in remove_commit as we still
@@ -3728,10 +3723,8 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, · 683 unmodified lines
37283723 struct ib_uverbs_destroy_srq cmd;
37293724 struct ib_uverbs_destroy_srq_resp resp;
37303725 struct ib_uobject *uobj;
3731− struct ib_srq *srq;
37323726 struct ib_uevent_object *obj;
37333727 int ret = -EINVAL;
3734− enum ib_srq_type srq_type;
37353728
37363729 if (copy_from_user(&cmd, buf, sizeof cmd))
37373730 return -EFAULT;
@@ -3741,9 +3734,7 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, · 3 unmodified lines
37413734 if (IS_ERR(uobj))
37423735 return PTR_ERR(uobj);
37433736
3744− srq = uobj->object;
37453737 obj = container_of(uobj, struct ib_uevent_object, uobject);
3746− srq_type = srq->srq_type;
37473738 /*
37483739 * Make sure we don't free the memory in remove_commit as we still
37493740 * needs the uobject memory to create the response.
drivers/infiniband/hw/bnxt_re/bnxt_re.h+9−0
@@ -51,6 +51,8 @@ · 50 unmodified lines
5151 #define BNXT_RE_PAGE_SIZE_8M BIT(23)
5252 #define BNXT_RE_PAGE_SIZE_1G BIT(30)
5353
54+#define BNXT_RE_MAX_MR_SIZE BIT(30)
55+
5456 #define BNXT_RE_MAX_QPC_COUNT (64 * 1024)
5557 #define BNXT_RE_MAX_MRW_COUNT (64 * 1024)
5658 #define BNXT_RE_MAX_SRQC_COUNT (64 * 1024)
@@ -60,6 +62,13 @@ · 3 unmodified lines
6062
6163 #define BNXT_RE_RQ_WQE_THRESHOLD 32
6264
65+/*
66+ * Setting the default ack delay value to 16, which means
67+ * the default timeout is approx. 260ms(4 usec * 2 ^(timeout))
68+ */
69+
70+#define BNXT_RE_DEFAULT_ACK_DELAY 16
71+
6372 struct bnxt_re_work {
6473 struct work_struct work;
6574 unsigned long event;
drivers/infiniband/hw/bnxt_re/ib_verbs.c+72−47
@@ -145,10 +145,8 @@ int bnxt_re_query_device(struct ib_device *ibdev, · 144 unmodified lines
145145 ib_attr->fw_ver = (u64)(unsigned long)(dev_attr->fw_ver);
146146 bnxt_qplib_get_guid(rdev->netdev->dev_addr,
147147 (u8 *)&ib_attr->sys_image_guid);
148− ib_attr->max_mr_size = ~0ull;
149− ib_attr->page_size_cap = BNXT_RE_PAGE_SIZE_4K | BNXT_RE_PAGE_SIZE_8K |
150− BNXT_RE_PAGE_SIZE_64K | BNXT_RE_PAGE_SIZE_2M |
151− BNXT_RE_PAGE_SIZE_8M | BNXT_RE_PAGE_SIZE_1G;
148+ ib_attr->max_mr_size = BNXT_RE_MAX_MR_SIZE;
149+ ib_attr->page_size_cap = BNXT_RE_PAGE_SIZE_4K;
152150
153151 ib_attr->vendor_id = rdev->en_dev->pdev->vendor;
154152 ib_attr->vendor_part_id = rdev->en_dev->pdev->device;
@@ -174,9 +172,11 @@ int bnxt_re_query_device(struct ib_device *ibdev, · 19 unmodified lines
174172 ib_attr->max_mr = dev_attr->max_mr;
175173 ib_attr->max_pd = dev_attr->max_pd;
176174 ib_attr->max_qp_rd_atom = dev_attr->max_qp_rd_atom;
177− ib_attr->max_qp_init_rd_atom = dev_attr->max_qp_rd_atom;
178− ib_attr->atomic_cap = IB_ATOMIC_HCA;
179− ib_attr->masked_atomic_cap = IB_ATOMIC_HCA;
175+ ib_attr->max_qp_init_rd_atom = dev_attr->max_qp_init_rd_atom;
176+ if (dev_attr->is_atomic) {
177+ ib_attr->atomic_cap = IB_ATOMIC_HCA;
178+ ib_attr->masked_atomic_cap = IB_ATOMIC_HCA;
179+ }
180180
181181 ib_attr->max_ee_rd_atom = 0;
182182 ib_attr->max_res_rd_atom = 0;
@@ -201,7 +201,7 @@ int bnxt_re_query_device(struct ib_device *ibdev, · 18 unmodified lines
201201 ib_attr->max_fast_reg_page_list_len = MAX_PBL_LVL_1_PGS;
202202
203203 ib_attr->max_pkeys = 1;
204− ib_attr->local_ca_ack_delay = 0;
204+ ib_attr->local_ca_ack_delay = BNXT_RE_DEFAULT_ACK_DELAY;
205205 return 0;
206206 }
207207
@@ -390,15 +390,17 @@ int bnxt_re_del_gid(struct ib_device *ibdev, u8 port_num, · 182 unmodified lines
390390 return -EINVAL;
391391 ctx->refcnt--;
392392 if (!ctx->refcnt) {
393− rc = bnxt_qplib_del_sgid
394− (sgid_tbl,
395− &sgid_tbl->tbl[ctx->idx], true);
396− if (rc)
393+ rc = bnxt_qplib_del_sgid(sgid_tbl,
394+ &sgid_tbl->tbl[ctx->idx],
395+ true);
396+ if (rc) {
397397 dev_err(rdev_to_dev(rdev),
398398 "Failed to remove GID: %#x", rc);
399− ctx_tbl = sgid_tbl->ctx;
400− ctx_tbl[ctx->idx] = NULL;
401− kfree(ctx);
399+ } else {
400+ ctx_tbl = sgid_tbl->ctx;
401+ ctx_tbl[ctx->idx] = NULL;
402+ kfree(ctx);
403+ }
402404 }
403405 } else {
404406 return -EINVAL;
@@ -588,10 +590,10 @@ static int bnxt_re_create_fence_mr(struct bnxt_re_pd *pd) · 183 unmodified lines
588590
589591 /* Create a fence MW only for kernel consumers */
590592 mw = bnxt_re_alloc_mw(&pd->ib_pd, IB_MW_TYPE_1, NULL);
591− if (!mw) {
593+ if (IS_ERR(mw)) {
592594 dev_err(rdev_to_dev(rdev),
593595 "Failed to create fence-MW for PD: %p\n", pd);
594− rc = -EINVAL;
596+ rc = PTR_ERR(mw);
595597 goto fail;
596598 }
597599 fence->mw = mw;
@@ -612,30 +614,13 @@ int bnxt_re_dealloc_pd(struct ib_pd *ib_pd) · 14 unmodified lines
612614 int rc;
613615
614616 bnxt_re_destroy_fence_mr(pd);
615− if (ib_pd->uobject && pd->dpi.dbr) {
616− struct ib_ucontext *ib_uctx = ib_pd->uobject->context;
617− struct bnxt_re_ucontext *ucntx;
618617
619− /* Free DPI only if this is the first PD allocated by the
620− * application and mark the context dpi as NULL
621− */
622− ucntx = container_of(ib_uctx, struct bnxt_re_ucontext, ib_uctx);
623−
624− rc = bnxt_qplib_dealloc_dpi(&rdev->qplib_res,
625− &rdev->qplib_res.dpi_tbl,
626− &pd->dpi);
618+ if (pd->qplib_pd.id) {
619+ rc = bnxt_qplib_dealloc_pd(&rdev->qplib_res,
620+ &rdev->qplib_res.pd_tbl,
621+ &pd->qplib_pd);
627622 if (rc)
628− dev_err(rdev_to_dev(rdev), "Failed to deallocate HW DPI");
629− /* Don't fail, continue*/
630− ucntx->dpi = NULL;
631− }
632−
633− rc = bnxt_qplib_dealloc_pd(&rdev->qplib_res,
634− &rdev->qplib_res.pd_tbl,
635− &pd->qplib_pd);
636− if (rc) {
637− dev_err(rdev_to_dev(rdev), "Failed to deallocate HW PD");
638− return rc;
623+ dev_err(rdev_to_dev(rdev), "Failed to deallocate HW PD");
639624 }
640625
641626 kfree(pd);
@@ -667,23 +652,22 @@ struct ib_pd *bnxt_re_alloc_pd(struct ib_device *ibdev, · 25 unmodified lines
667652 if (udata) {
668653 struct bnxt_re_pd_resp resp;
669654
670− if (!ucntx->dpi) {
655+ if (!ucntx->dpi.dbr) {
671656 /* Allocate DPI in alloc_pd to avoid failing of
672657 * ibv_devinfo and family of application when DPIs
673658 * are depleted.
674659 */
675660 if (bnxt_qplib_alloc_dpi(&rdev->qplib_res.dpi_tbl,
676− &pd->dpi, ucntx)) {
661+ &ucntx->dpi, ucntx)) {
677662 rc = -ENOMEM;
678663 goto dbfail;
679664 }
680− ucntx->dpi = &pd->dpi;
681665 }
682666
683667 resp.pdid = pd->qplib_pd.id;
684668 /* Still allow mapping this DBR to the new user PD. */
685− resp.dpi = ucntx->dpi->dpi;
686− resp.dbr = (u64)ucntx->dpi->umdbr;
669+ resp.dpi = ucntx->dpi.dpi;
670+ resp.dbr = (u64)ucntx->dpi.umdbr;
687671
688672 rc = ib_copy_to_udata(udata, &resp, sizeof(resp));
689673 if (rc) {
@@ -960,7 +944,7 @@ static int bnxt_re_init_user_qp(struct bnxt_re_dev *rdev, struct bnxt_re_pd *pd, · 270 unmodified lines
960944 qplib_qp->rq.nmap = umem->nmap;
961945 }
962946
963− qplib_qp->dpi = cntx->dpi;
947+ qplib_qp->dpi = &cntx->dpi;
964948 return 0;
965949 rqfail:
966950 ib_umem_release(qp->sumem);
@@ -1530,13 +1514,24 @@ int bnxt_re_modify_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr, · 563 unmodified lines
15301514 if (qp_attr_mask & IB_QP_MAX_QP_RD_ATOMIC) {
15311515 qp->qplib_qp.modify_flags |=
15321516 CMDQ_MODIFY_QP_MODIFY_MASK_MAX_RD_ATOMIC;
1533− qp->qplib_qp.max_rd_atomic = qp_attr->max_rd_atomic;
1517+ /* Cap the max_rd_atomic to device max */
1518+ qp->qplib_qp.max_rd_atomic = min_t(u32, qp_attr->max_rd_atomic,
1519+ dev_attr->max_qp_rd_atom);
15341520 }
15351521 if (qp_attr_mask & IB_QP_SQ_PSN) {
15361522 qp->qplib_qp.modify_flags |= CMDQ_MODIFY_QP_MODIFY_MASK_SQ_PSN;
15371523 qp->qplib_qp.sq.psn = qp_attr->sq_psn;
15381524 }
15391525 if (qp_attr_mask & IB_QP_MAX_DEST_RD_ATOMIC) {
1526+ if (qp_attr->max_dest_rd_atomic >
1527+ dev_attr->max_qp_init_rd_atom) {
1528+ dev_err(rdev_to_dev(rdev),
1529+ "max_dest_rd_atomic requested%d is > dev_max%d",
1530+ qp_attr->max_dest_rd_atomic,
1531+ dev_attr->max_qp_init_rd_atom);
1532+ return -EINVAL;
1533+ }
1534+
15401535 qp->qplib_qp.modify_flags |=
15411536 CMDQ_MODIFY_QP_MODIFY_MASK_MAX_DEST_RD_ATOMIC;
15421537 qp->qplib_qp.max_dest_rd_atomic = qp_attr->max_dest_rd_atomic;
@@ -2403,7 +2398,7 @@ struct ib_cq *bnxt_re_create_cq(struct ib_device *ibdev, · 860 unmodified lines
24032398 }
24042399 cq->qplib_cq.sghead = cq->umem->sg_head.sgl;
24052400 cq->qplib_cq.nmap = cq->umem->nmap;
2406− cq->qplib_cq.dpi = uctx->dpi;
2401+ cq->qplib_cq.dpi = &uctx->dpi;
24072402 } else {
24082403 cq->max_cql = min_t(u32, entries, MAX_CQL_PER_POLL);
24092404 cq->cql = kcalloc(cq->max_cql, sizeof(struct bnxt_qplib_cqe),
@@ -2905,6 +2900,7 @@ int bnxt_re_poll_cq(struct ib_cq *ib_cq, int num_entries, struct ib_wc *wc) · 495 unmodified lines
29052900
29062901 spin_lock_irqsave(&cq->cq_lock, flags);
29072902 budget = min_t(u32, num_entries, cq->max_cql);
2903+ num_entries = budget;
29082904 if (!cq->cql) {
29092905 dev_err(rdev_to_dev(cq->rdev), "POLL CQ : no CQL to use");
29102906 goto exit;
@@ -3031,6 +3027,11 @@ int bnxt_re_req_notify_cq(struct ib_cq *ib_cq, · 120 unmodified lines
30313027 else if (ib_cqn_flags & IB_CQ_SOLICITED)
30323028 type = DBR_DBR_TYPE_CQ_ARMSE;
30333029
3030+ /* Poll to see if there are missed events */
3031+ if ((ib_cqn_flags & IB_CQ_REPORT_MISSED_EVENTS) &&
3032+ !(bnxt_qplib_is_cq_empty(&cq->qplib_cq)))
3033+ return 1;
3034+
30343035 bnxt_qplib_req_notify_cq(&cq->qplib_cq, type);
30353036
30363037 return 0;
@@ -3245,6 +3246,12 @@ struct ib_mr *bnxt_re_reg_user_mr(struct ib_pd *ib_pd, u64 start, u64 length, · 208 unmodified lines
32453246 struct scatterlist *sg;
32463247 int entry;
32473248
3249+ if (length > BNXT_RE_MAX_MR_SIZE) {
3250+ dev_err(rdev_to_dev(rdev), "MR Size: %lld > Max supported:%ld\n",
3251+ length, BNXT_RE_MAX_MR_SIZE);
3252+ return ERR_PTR(-ENOMEM);
3253+ }
3254+
32483255 mr = kzalloc(sizeof(*mr), GFP_KERNEL);
32493256 if (!mr)
32503257 return ERR_PTR(-ENOMEM);
@@ -3388,8 +3395,26 @@ int bnxt_re_dealloc_ucontext(struct ib_ucontext *ib_uctx) · 137 unmodified lines
33883395 struct bnxt_re_ucontext *uctx = container_of(ib_uctx,
33893396 struct bnxt_re_ucontext,
33903397 ib_uctx);
3398+
3399+ struct bnxt_re_dev *rdev = uctx->rdev;
3400+ int rc = 0;
3401+
33913402 if (uctx->shpg)
33923403 free_page((unsigned long)uctx->shpg);
3404+
3405+ if (uctx->dpi.dbr) {
3406+ /* Free DPI only if this is the first PD allocated by the
3407+ * application and mark the context dpi as NULL
3408+ */
3409+ rc = bnxt_qplib_dealloc_dpi(&rdev->qplib_res,
3410+ &rdev->qplib_res.dpi_tbl,
3411+ &uctx->dpi);
3412+ if (rc)
3413+ dev_err(rdev_to_dev(rdev), "Deallocte HW DPI failed!");
3414+ /* Don't fail, continue*/
3415+ uctx->dpi.dbr = NULL;
3416+ }
3417+
33933418 kfree(uctx);
33943419 return 0;
33953420 }
drivers/infiniband/hw/bnxt_re/ib_verbs.h+1−2
@@ -59,7 +59,6 @@ struct bnxt_re_pd { · 58 unmodified lines
5959 struct bnxt_re_dev *rdev;
6060 struct ib_pd ib_pd;
6161 struct bnxt_qplib_pd qplib_pd;
62− struct bnxt_qplib_dpi dpi;
6362 struct bnxt_re_fence_data fence;
6463 };
6564
@@ -127,7 +126,7 @@ struct bnxt_re_mw { · 61 unmodified lines
127126 struct bnxt_re_ucontext {
128127 struct bnxt_re_dev *rdev;
129128 struct ib_ucontext ib_uctx;
130− struct bnxt_qplib_dpi *dpi;
129+ struct bnxt_qplib_dpi dpi;
131130 void *shpg;
132131 spinlock_t sh_lock; /* protect shpg */
133132 };
drivers/infiniband/hw/bnxt_re/main.c+1−0
@@ -333,6 +333,7 @@ static int bnxt_re_net_stats_ctx_alloc(struct bnxt_re_dev *rdev, · 332 unmodified lines
333333 bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_STAT_CTX_ALLOC, -1, -1);
334334 req.update_period_ms = cpu_to_le32(1000);
335335 req.stats_dma_addr = cpu_to_le64(dma_map);
336+ req.stat_ctx_flags = STAT_CTX_ALLOC_REQ_STAT_CTX_FLAGS_ROCE;
336337 bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
337338 sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
338339 rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
drivers/infiniband/hw/bnxt_re/qplib_fp.c+29−0
@@ -1128,6 +1128,11 @@ int bnxt_qplib_post_send(struct bnxt_qplib_qp *qp, · 1127 unmodified lines
11281128 }
11291129 /* Each SGE entry = 1 WQE size16 */
11301130 wqe_size16 = wqe->num_sge;
1131+ /* HW requires wqe size has room for atleast one SGE even if
1132+ * none was supplied by ULP
1133+ */
1134+ if (!wqe->num_sge)
1135+ wqe_size16++;
11311136 }
11321137
11331138 /* Specifics */
@@ -1364,6 +1369,11 @@ int bnxt_qplib_post_recv(struct bnxt_qplib_qp *qp, · 230 unmodified lines
13641369 rqe->flags = wqe->flags;
13651370 rqe->wqe_size = wqe->num_sge +
13661371 ((offsetof(typeof(*rqe), data) + 15) >> 4);
1372+ /* HW requires wqe size has room for atleast one SGE even if none
1373+ * was supplied by ULP
1374+ */
1375+ if (!wqe->num_sge)
1376+ rqe->wqe_size++;
13671377
13681378 /* Supply the rqe->wr_id index to the wr_id_tbl for now */
13691379 rqe->wr_id[0] = cpu_to_le32(sw_prod);
@@ -1885,6 +1895,25 @@ flush_rq: · 515 unmodified lines
18851895 return rc;
18861896 }
18871897
1898+bool bnxt_qplib_is_cq_empty(struct bnxt_qplib_cq *cq)
1899+{
1900+ struct cq_base *hw_cqe, **hw_cqe_ptr;
1901+ unsigned long flags;
1902+ u32 sw_cons, raw_cons;
1903+ bool rc = true;
1904+
1905+ spin_lock_irqsave(&cq->hwq.lock, flags);
1906+ raw_cons = cq->hwq.cons;
1907+ sw_cons = HWQ_CMP(raw_cons, &cq->hwq);
1908+ hw_cqe_ptr = (struct cq_base **)cq->hwq.pbl_ptr;
1909+ hw_cqe = &hw_cqe_ptr[CQE_PG(sw_cons)][CQE_IDX(sw_cons)];
1910+
1911+ /* Check for Valid bit. If the CQE is valid, return false */
1912+ rc = !CQE_CMP_VALID(hw_cqe, raw_cons, cq->hwq.max_elements);
1913+ spin_unlock_irqrestore(&cq->hwq.lock, flags);
1914+ return rc;
1915+}
1916+
18881917 static int bnxt_qplib_cq_process_res_raweth_qp1(struct bnxt_qplib_cq *cq,
18891918 struct cq_res_raweth_qp1 *hwcqe,
18901919 struct bnxt_qplib_cqe **pcqe,
drivers/infiniband/hw/bnxt_re/qplib_fp.h+1−0
@@ -449,6 +449,7 @@ int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq); · 448 unmodified lines
449449 int bnxt_qplib_destroy_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq);
450450 int bnxt_qplib_poll_cq(struct bnxt_qplib_cq *cq, struct bnxt_qplib_cqe *cqe,
451451 int num, struct bnxt_qplib_qp **qp);
452+bool bnxt_qplib_is_cq_empty(struct bnxt_qplib_cq *cq);
452453 void bnxt_qplib_req_notify_cq(struct bnxt_qplib_cq *cq, u32 arm_type);
453454 void bnxt_qplib_free_nq(struct bnxt_qplib_nq *nq);
454455 int bnxt_qplib_alloc_nq(struct pci_dev *pdev, struct bnxt_qplib_nq *nq);
drivers/infiniband/hw/bnxt_re/qplib_sp.c+16−0
@@ -51,6 +51,19 @@ const struct bnxt_qplib_gid bnxt_qplib_gid_zero = {{ 0, 0, 0, 0, 0, 0, 0, 0, · 50 unmodified lines
5151 0, 0, 0, 0, 0, 0, 0, 0 } };
5252
5353 /* Device */
54+
55+static bool bnxt_qplib_is_atomic_cap(struct bnxt_qplib_rcfw *rcfw)
56+{
57+ int rc;
58+ u16 pcie_ctl2;
59+
60+ rc = pcie_capability_read_word(rcfw->pdev, PCI_EXP_DEVCTL2,
61+ &pcie_ctl2);
62+ if (rc)
63+ return false;
64+ return !!(pcie_ctl2 & PCI_EXP_DEVCTL2_ATOMIC_REQ);
65+}
66+
5467 int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw,
5568 struct bnxt_qplib_dev_attr *attr)
5669 {
@@ -81,6 +94,8 @@ int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw, · 24 unmodified lines
8194
8295 /* Extract the context from the side buffer */
8396 attr->max_qp = le32_to_cpu(sb->max_qp);
97+ /* max_qp value reported by FW for PF doesn't include the QP1 for PF */
98+ attr->max_qp += 1;
8499 attr->max_qp_rd_atom =
85100 sb->max_qp_rd_atom > BNXT_QPLIB_MAX_OUT_RD_ATOM ?
86101 BNXT_QPLIB_MAX_OUT_RD_ATOM : sb->max_qp_rd_atom;
@@ -129,6 +144,7 @@ int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw, · 42 unmodified lines
129144 attr->tqm_alloc_reqs[i * 4 + 3] = *(++tqm_alloc);
130145 }
131146
147+ attr->is_atomic = bnxt_qplib_is_atomic_cap(rcfw);
132148 bail:
133149 bnxt_qplib_rcfw_free_sbuf(rcfw, sbuf);
134150 return rc;
drivers/infiniband/hw/bnxt_re/qplib_sp.h+3−0
@@ -42,6 +42,8 @@ · 41 unmodified lines
4242
4343 #define BNXT_QPLIB_RESERVED_QP_WRS 128
4444
45+#define PCI_EXP_DEVCTL2_ATOMIC_REQ 0x0040
46+
4547 struct bnxt_qplib_dev_attr {
4648 char fw_ver[32];
4749 u16 max_sgid;
@@ -70,6 +72,7 @@ struct bnxt_qplib_dev_attr { · 22 unmodified lines
7072 u32 max_inline_data;
7173 u32 l2_db_size;
7274 u8 tqm_alloc_reqs[MAX_TQM_ALLOC_REQ];
75+ bool is_atomic;
7376 };
7477
7578 struct bnxt_qplib_pd {
drivers/infiniband/hw/cxgb3/iwch_provider.c+4−5
@@ -718,7 +718,7 @@ static struct ib_mr *iwch_alloc_mr(struct ib_pd *pd, · 717 unmodified lines
718718 struct iwch_mr *mhp;
719719 u32 mmid;
720720 u32 stag = 0;
721− int ret = 0;
721+ int ret = -ENOMEM;
722722
723723 if (mr_type != IB_MR_TYPE_MEM_REG ||
724724 max_num_sg > T3_MAX_FASTREG_DEPTH)
@@ -731,10 +731,8 @@ static struct ib_mr *iwch_alloc_mr(struct ib_pd *pd, · 6 unmodified lines
731731 goto err;
732732
733733 mhp->pages = kcalloc(max_num_sg, sizeof(u64), GFP_KERNEL);
734− if (!mhp->pages) {
735− ret = -ENOMEM;
734+ if (!mhp->pages)
736735 goto pl_err;
737− }
738736
739737 mhp->rhp = rhp;
740738 ret = iwch_alloc_pbl(mhp, max_num_sg);
@@ -751,7 +749,8 @@ static struct ib_mr *iwch_alloc_mr(struct ib_pd *pd, · 10 unmodified lines
751749 mhp->attr.state = 1;
752750 mmid = (stag) >> 8;
753751 mhp->ibmr.rkey = mhp->ibmr.lkey = stag;
754− if (insert_handle(rhp, &rhp->mmidr, mhp, mmid))
752+ ret = insert_handle(rhp, &rhp->mmidr, mhp, mmid);
753+ if (ret)
755754 goto err3;
756755
757756 pr_debug("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag);
drivers/infiniband/hw/cxgb4/cq.c+1−0
@@ -963,6 +963,7 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, · 962 unmodified lines
963963 goto err3;
964964
965965 if (ucontext) {
966+ ret = -ENOMEM;
966967 mm = kmalloc(sizeof *mm, GFP_KERNEL);
967968 if (!mm)
968969 goto err4;
drivers/infiniband/hw/cxgb4/qp.c+1−1
@@ -569,7 +569,7 @@ static int build_rdma_read(union t4_wr *wqe, struct ib_send_wr *wr, u8 *len16) · 568 unmodified lines
569569 {
570570 if (wr->num_sge > 1)
571571 return -EINVAL;
572− if (wr->num_sge) {
572+ if (wr->num_sge && wr->sg_list[0].length) {
573573 wqe->read.stag_src = cpu_to_be32(rdma_wr(wr)->rkey);
574574 wqe->read.to_src_hi = cpu_to_be32((u32)(rdma_wr(wr)->remote_addr
575575 >> 32));
drivers/infiniband/hw/i40iw/i40iw.h+1−0
@@ -527,6 +527,7 @@ enum i40iw_status_code i40iw_add_mac_addr(struct i40iw_device *iwdev, · 526 unmodified lines
527527 int i40iw_modify_qp(struct ib_qp *, struct ib_qp_attr *, int, struct ib_udata *);
528528 void i40iw_cq_wq_destroy(struct i40iw_device *iwdev, struct i40iw_sc_cq *cq);
529529
530+void i40iw_cleanup_pending_cqp_op(struct i40iw_device *iwdev);
530531 void i40iw_rem_pdusecount(struct i40iw_pd *iwpd, struct i40iw_device *iwdev);
531532 void i40iw_add_pdusecount(struct i40iw_pd *iwpd);
532533 void i40iw_rem_devusecount(struct i40iw_device *iwdev);
drivers/infiniband/hw/i40iw/i40iw_cm.c+4−1
@@ -3487,7 +3487,8 @@ static void i40iw_cm_disconn_true(struct i40iw_qp *iwqp) · 3486 unmodified lines
34873487 if (((original_hw_tcp_state == I40IW_TCP_STATE_CLOSED) ||
34883488 (original_hw_tcp_state == I40IW_TCP_STATE_TIME_WAIT) ||
34893489 (last_ae == I40IW_AE_RDMAP_ROE_BAD_LLP_CLOSE) ||
3490− (last_ae == I40IW_AE_LLP_CONNECTION_RESET))) {
3490+ (last_ae == I40IW_AE_LLP_CONNECTION_RESET) ||
3491+ iwdev->reset)) {
34913492 issue_close = 1;
34923493 iwqp->cm_id = NULL;
34933494 if (!iwqp->flush_issued) {
@@ -4265,6 +4266,8 @@ void i40iw_cm_disconnect_all(struct i40iw_device *iwdev) · 771 unmodified lines
42654266 cm_node = container_of(list_node, struct i40iw_cm_node, connected_entry);
42664267 attr.qp_state = IB_QPS_ERR;
42674268 i40iw_modify_qp(&cm_node->iwqp->ibqp, &attr, IB_QP_STATE, NULL);
4269+ if (iwdev->reset)
4270+ i40iw_cm_disconn(cm_node->iwqp);
42684271 i40iw_rem_ref_cm_node(cm_node);
42694272 }
42704273 }
drivers/infiniband/hw/i40iw/i40iw_ctrl.c+2−0
@@ -1970,6 +1970,8 @@ static enum i40iw_status_code i40iw_sc_ccq_destroy(struct i40iw_sc_cq *ccq, · 1969 unmodified lines
19701970 ret_code = i40iw_cqp_poll_registers(cqp, tail, 1000);
19711971 }
19721972
1973+ cqp->process_cqp_sds = i40iw_update_sds_noccq;
1974+
19731975 return ret_code;
19741976 }
19751977
drivers/infiniband/hw/i40iw/i40iw_main.c+30−30
@@ -243,6 +243,8 @@ static void i40iw_destroy_cqp(struct i40iw_device *iwdev, bool free_hwcqp) · 242 unmodified lines
243243 if (free_hwcqp)
244244 dev->cqp_ops->cqp_destroy(dev->cqp);
245245
246+ i40iw_cleanup_pending_cqp_op(iwdev);
247+
246248 i40iw_free_dma_mem(dev->hw, &cqp->sq);
247249 kfree(cqp->scratch_array);
248250 iwdev->cqp.scratch_array = NULL;
@@ -274,13 +276,12 @@ static void i40iw_disable_irq(struct i40iw_sc_dev *dev, · 25 unmodified lines
274276 /**
275277 * i40iw_destroy_aeq - destroy aeq
276278 * @iwdev: iwarp device
277− * @reset: true if called before reset
278279 *
279280 * Issue a destroy aeq request and
280281 * free the resources associated with the aeq
281282 * The function is called during driver unload
282283 */
283−static void i40iw_destroy_aeq(struct i40iw_device *iwdev, bool reset)
284+static void i40iw_destroy_aeq(struct i40iw_device *iwdev)
284285 {
285286 enum i40iw_status_code status = I40IW_ERR_NOT_READY;
286287 struct i40iw_sc_dev *dev = &iwdev->sc_dev;
@@ -288,7 +289,7 @@ static void i40iw_destroy_aeq(struct i40iw_device *iwdev, bool reset) · 1 unmodified line
288289
289290 if (!iwdev->msix_shared)
290291 i40iw_disable_irq(dev, iwdev->iw_msixtbl, (void *)iwdev);
291− if (reset)
292+ if (iwdev->reset)
292293 goto exit;
293294
294295 if (!dev->aeq_ops->aeq_destroy(&aeq->sc_aeq, 0, 1))
@@ -304,19 +305,17 @@ exit: · 9 unmodified lines
304305 * i40iw_destroy_ceq - destroy ceq
305306 * @iwdev: iwarp device
306307 * @iwceq: ceq to be destroyed
307− * @reset: true if called before reset
308308 *
309309 * Issue a destroy ceq request and
310310 * free the resources associated with the ceq
311311 */
312312 static void i40iw_destroy_ceq(struct i40iw_device *iwdev,
313− struct i40iw_ceq *iwceq,
314− bool reset)
313+ struct i40iw_ceq *iwceq)
315314 {
316315 enum i40iw_status_code status;
317316 struct i40iw_sc_dev *dev = &iwdev->sc_dev;
318317
319− if (reset)
318+ if (iwdev->reset)
320319 goto exit;
321320
322321 status = dev->ceq_ops->ceq_destroy(&iwceq->sc_ceq, 0, 1);
@@ -335,12 +334,11 @@ exit: · 12 unmodified lines
335334 /**
336335 * i40iw_dele_ceqs - destroy all ceq's
337336 * @iwdev: iwarp device
338− * @reset: true if called before reset
339337 *
340338 * Go through all of the device ceq's and for each ceq
341339 * disable the ceq interrupt and destroy the ceq
342340 */
343−static void i40iw_dele_ceqs(struct i40iw_device *iwdev, bool reset)
341+static void i40iw_dele_ceqs(struct i40iw_device *iwdev)
344342 {
345343 u32 i = 0;
346344 struct i40iw_sc_dev *dev = &iwdev->sc_dev;
@@ -349,32 +347,31 @@ static void i40iw_dele_ceqs(struct i40iw_device *iwdev, bool reset) · 2 unmodified lines
349347
350348 if (iwdev->msix_shared) {
351349 i40iw_disable_irq(dev, msix_vec, (void *)iwdev);
352− i40iw_destroy_ceq(iwdev, iwceq, reset);
350+ i40iw_destroy_ceq(iwdev, iwceq);
353351 iwceq++;
354352 i++;
355353 }
356354
357355 for (msix_vec++; i < iwdev->ceqs_count; i++, msix_vec++, iwceq++) {
358356 i40iw_disable_irq(dev, msix_vec, (void *)iwceq);
359− i40iw_destroy_ceq(iwdev, iwceq, reset);
357+ i40iw_destroy_ceq(iwdev, iwceq);
360358 }
361359 }
362360
363361 /**
364362 * i40iw_destroy_ccq - destroy control cq
365363 * @iwdev: iwarp device
366− * @reset: true if called before reset
367364 *
368365 * Issue destroy ccq request and
369366 * free the resources associated with the ccq
370367 */
371−static void i40iw_destroy_ccq(struct i40iw_device *iwdev, bool reset)
368+static void i40iw_destroy_ccq(struct i40iw_device *iwdev)
372369 {
373370 struct i40iw_sc_dev *dev = &iwdev->sc_dev;
374371 struct i40iw_ccq *ccq = &iwdev->ccq;
375372 enum i40iw_status_code status = 0;
376373
377− if (!reset)
374+ if (!iwdev->reset)
378375 status = dev->ccq_ops->ccq_destroy(dev->ccq, 0, true);
379376 if (status)
380377 i40iw_pr_err("ccq destroy failed %d\n", status);
@@ -810,7 +807,7 @@ static enum i40iw_status_code i40iw_setup_ceqs(struct i40iw_device *iwdev, · 429 unmodified lines
810807 iwceq->msix_idx = msix_vec->idx;
811808 status = i40iw_configure_ceq_vector(iwdev, iwceq, ceq_id, msix_vec);
812809 if (status) {
813− i40iw_destroy_ceq(iwdev, iwceq, false);
810+ i40iw_destroy_ceq(iwdev, iwceq);
814811 break;
815812 }
816813 i40iw_enable_intr(&iwdev->sc_dev, msix_vec->idx);
@@ -912,7 +909,7 @@ static enum i40iw_status_code i40iw_setup_aeq(struct i40iw_device *iwdev) · 95 unmodified lines
912909
913910 status = i40iw_configure_aeq_vector(iwdev);
914911 if (status) {
915− i40iw_destroy_aeq(iwdev, false);
912+ i40iw_destroy_aeq(iwdev);
916913 return status;
917914 }
918915
@@ -1442,12 +1439,11 @@ static enum i40iw_status_code i40iw_save_msix_info(struct i40iw_device *iwdev, · 523 unmodified lines
14421439 /**
14431440 * i40iw_deinit_device - clean up the device resources
14441441 * @iwdev: iwarp device
1445− * @reset: true if called before reset
14461442 *
14471443 * Destroy the ib device interface, remove the mac ip entry and ipv4/ipv6 addresses,
14481444 * destroy the device queues and free the pble and the hmc objects
14491445 */
1450−static void i40iw_deinit_device(struct i40iw_device *iwdev, bool reset)
1446+static void i40iw_deinit_device(struct i40iw_device *iwdev)
14511447 {
14521448 struct i40e_info *ldev = iwdev->ldev;
14531449
@@ -1464,7 +1460,7 @@ static void i40iw_deinit_device(struct i40iw_device *iwdev, bool reset) · 10 unmodified lines
14641460 i40iw_destroy_rdma_device(iwdev->iwibdev);
14651461 /* fallthrough */
14661462 case IP_ADDR_REGISTERED:
1467− if (!reset)
1463+ if (!iwdev->reset)
14681464 i40iw_del_macip_entry(iwdev, (u8)iwdev->mac_ip_table_idx);
14691465 /* fallthrough */
14701466 case INET_NOTIFIER:
@@ -1474,26 +1470,26 @@ static void i40iw_deinit_device(struct i40iw_device *iwdev, bool reset) · 3 unmodified lines
14741470 unregister_inet6addr_notifier(&i40iw_inetaddr6_notifier);
14751471 }
14761472 /* fallthrough */
1473+ case PBLE_CHUNK_MEM:
1474+ i40iw_destroy_pble_pool(dev, iwdev->pble_rsrc);
1475+ /* fallthrough */
14771476 case CEQ_CREATED:
1478− i40iw_dele_ceqs(iwdev, reset);
1477+ i40iw_dele_ceqs(iwdev);
14791478 /* fallthrough */
14801479 case AEQ_CREATED:
1481− i40iw_destroy_aeq(iwdev, reset);
1480+ i40iw_destroy_aeq(iwdev);
14821481 /* fallthrough */
14831482 case IEQ_CREATED:
1484− i40iw_puda_dele_resources(&iwdev->vsi, I40IW_PUDA_RSRC_TYPE_IEQ, reset);
1483+ i40iw_puda_dele_resources(&iwdev->vsi, I40IW_PUDA_RSRC_TYPE_IEQ, iwdev->reset);
14851484 /* fallthrough */
14861485 case ILQ_CREATED:
1487− i40iw_puda_dele_resources(&iwdev->vsi, I40IW_PUDA_RSRC_TYPE_ILQ, reset);
1486+ i40iw_puda_dele_resources(&iwdev->vsi, I40IW_PUDA_RSRC_TYPE_ILQ, iwdev->reset);
14881487 /* fallthrough */
14891488 case CCQ_CREATED:
1490− i40iw_destroy_ccq(iwdev, reset);
1491− /* fallthrough */
1492− case PBLE_CHUNK_MEM:
1493− i40iw_destroy_pble_pool(dev, iwdev->pble_rsrc);
1489+ i40iw_destroy_ccq(iwdev);
14941490 /* fallthrough */
14951491 case HMC_OBJS_CREATED:
1496− i40iw_del_hmc_objects(dev, dev->hmc_info, true, reset);
1492+ i40iw_del_hmc_objects(dev, dev->hmc_info, true, iwdev->reset);
14971493 /* fallthrough */
14981494 case CQP_CREATED:
14991495 i40iw_destroy_cqp(iwdev, true);
@@ -1670,6 +1666,7 @@ static int i40iw_open(struct i40e_info *ldev, struct i40e_client *client) · 170 unmodified lines
16701666 status = i40iw_hmc_init_pble(&iwdev->sc_dev, iwdev->pble_rsrc);
16711667 if (status)
16721668 break;
1669+ iwdev->init_state = PBLE_CHUNK_MEM;
16731670 iwdev->virtchnl_wq = alloc_ordered_workqueue("iwvch", WQ_MEM_RECLAIM);
16741671 i40iw_register_notifiers();
16751672 iwdev->init_state = INET_NOTIFIER;
@@ -1693,7 +1690,7 @@ static int i40iw_open(struct i40e_info *ldev, struct i40e_client *client) · 17 unmodified lines
16931690 } while (0);
16941691
16951692 i40iw_pr_err("status = %d last completion = %d\n", status, iwdev->init_state);
1696− i40iw_deinit_device(iwdev, false);
1693+ i40iw_deinit_device(iwdev);
16971694 return -ERESTART;
16981695 }
16991696
@@ -1774,9 +1771,12 @@ static void i40iw_close(struct i40e_info *ldev, struct i40e_client *client, bool · 74 unmodified lines
17741771 iwdev = &hdl->device;
17751772 iwdev->closing = true;
17761773
1774+ if (reset)
1775+ iwdev->reset = true;
1776+
17771777 i40iw_cm_disconnect_all(iwdev);
17781778 destroy_workqueue(iwdev->virtchnl_wq);
1779− i40iw_deinit_device(iwdev, reset);
1779+ i40iw_deinit_device(iwdev);
17801780 }
17811781
17821782 /**
drivers/infiniband/hw/i40iw/i40iw_puda.c+4−1
@@ -408,6 +408,9 @@ enum i40iw_status_code i40iw_puda_send(struct i40iw_sc_qp *qp, · 407 unmodified lines
408408 set_64bit_val(wqe, 0, info->paddr);
409409 set_64bit_val(wqe, 8, LS_64(info->len, I40IWQPSQ_FRAG_LEN));
410410 set_64bit_val(wqe, 16, header[0]);
411+
412+ /* Ensure all data is written before writing valid bit */
413+ wmb();
411414 set_64bit_val(wqe, 24, header[1]);
412415
413416 i40iw_debug_buf(qp->dev, I40IW_DEBUG_PUDA, "PUDA SEND WQE", wqe, 32);
@@ -1411,10 +1414,10 @@ static void i40iw_ieq_handle_exception(struct i40iw_puda_rsrc *ieq, · 997 unmodified lines
14111414
14121415 if (!list_empty(rxlist)) {
14131416 tmpbuf = (struct i40iw_puda_buf *)rxlist->next;
1414− plist = &tmpbuf->list;
14151417 while ((struct list_head *)tmpbuf != rxlist) {
14161418 if ((int)(buf->seqnum - tmpbuf->seqnum) < 0)
14171419 break;
1420+ plist = &tmpbuf->list;
14181421 tmpbuf = (struct i40iw_puda_buf *)plist->next;
14191422 }
14201423 /* Insert buf before tmpbuf */
drivers/infiniband/hw/i40iw/i40iw_utils.c+58−2
@@ -337,6 +337,7 @@ struct i40iw_cqp_request *i40iw_get_cqp_request(struct i40iw_cqp *cqp, bool wait · 336 unmodified lines
337337 */
338338 void i40iw_free_cqp_request(struct i40iw_cqp *cqp, struct i40iw_cqp_request *cqp_request)
339339 {
340+ struct i40iw_device *iwdev = container_of(cqp, struct i40iw_device, cqp);
340341 unsigned long flags;
341342
342343 if (cqp_request->dynamic) {
@@ -350,6 +351,7 @@ void i40iw_free_cqp_request(struct i40iw_cqp *cqp, struct i40iw_cqp_request *cqp · 7 unmodified lines
350351 list_add_tail(&cqp_request->list, &cqp->cqp_avail_reqs);
351352 spin_unlock_irqrestore(&cqp->req_lock, flags);
352353 }
354+ wake_up(&iwdev->close_wq);
353355 }
354356
355357 /**
@@ -364,6 +366,56 @@ void i40iw_put_cqp_request(struct i40iw_cqp *cqp, · 8 unmodified lines
364366 i40iw_free_cqp_request(cqp, cqp_request);
365367 }
366368
369+/**
370+ * i40iw_free_pending_cqp_request -free pending cqp request objs
371+ * @cqp: cqp ptr
372+ * @cqp_request: to be put back in cqp list
373+ */
374+static void i40iw_free_pending_cqp_request(struct i40iw_cqp *cqp,
375+ struct i40iw_cqp_request *cqp_request)
376+{
377+ struct i40iw_device *iwdev = container_of(cqp, struct i40iw_device, cqp);
378+
379+ if (cqp_request->waiting) {
380+ cqp_request->compl_info.error = true;
381+ cqp_request->request_done = true;
382+ wake_up(&cqp_request->waitq);
383+ }
384+ i40iw_put_cqp_request(cqp, cqp_request);
385+ wait_event_timeout(iwdev->close_wq,
386+ !atomic_read(&cqp_request->refcount),
387+ 1000);
388+}
389+
390+/**
391+ * i40iw_cleanup_pending_cqp_op - clean-up cqp with no completions
392+ * @iwdev: iwarp device
393+ */
394+void i40iw_cleanup_pending_cqp_op(struct i40iw_device *iwdev)
395+{
396+ struct i40iw_sc_dev *dev = &iwdev->sc_dev;
397+ struct i40iw_cqp *cqp = &iwdev->cqp;
398+ struct i40iw_cqp_request *cqp_request = NULL;
399+ struct cqp_commands_info *pcmdinfo = NULL;
400+ u32 i, pending_work, wqe_idx;
401+
402+ pending_work = I40IW_RING_WORK_AVAILABLE(cqp->sc_cqp.sq_ring);
403+ wqe_idx = I40IW_RING_GETCURRENT_TAIL(cqp->sc_cqp.sq_ring);
404+ for (i = 0; i < pending_work; i++) {
405+ cqp_request = (struct i40iw_cqp_request *)(unsigned long)cqp->scratch_array[wqe_idx];
406+ if (cqp_request)
407+ i40iw_free_pending_cqp_request(cqp, cqp_request);
408+ wqe_idx = (wqe_idx + 1) % I40IW_RING_GETSIZE(cqp->sc_cqp.sq_ring);
409+ }
410+
411+ while (!list_empty(&dev->cqp_cmd_head)) {
412+ pcmdinfo = (struct cqp_commands_info *)i40iw_remove_head(&dev->cqp_cmd_head);
413+ cqp_request = container_of(pcmdinfo, struct i40iw_cqp_request, info);
414+ if (cqp_request)
415+ i40iw_free_pending_cqp_request(cqp, cqp_request);
416+ }
417+}
418+
367419 /**
368420 * i40iw_free_qp - callback after destroy cqp completes
369421 * @cqp_request: cqp request for destroy qp
@@ -546,8 +598,12 @@ void i40iw_rem_ref(struct ib_qp *ibqp) · 176 unmodified lines
546598 cqp_info->in.u.qp_destroy.scratch = (uintptr_t)cqp_request;
547599 cqp_info->in.u.qp_destroy.remove_hash_idx = true;
548600 status = i40iw_handle_cqp_op(iwdev, cqp_request);
549− if (status)
550− i40iw_pr_err("CQP-OP Destroy QP fail");
601+ if (!status)
602+ return;
603+
604+ i40iw_rem_pdusecount(iwqp->iwpd, iwdev);
605+ i40iw_free_qp_resources(iwdev, iwqp, qp_num);
606+ i40iw_rem_devusecount(iwdev);
551607 }
552608
553609 /**
drivers/infiniband/hw/i40iw/i40iw_verbs.c+14−5
@@ -426,9 +426,13 @@ void i40iw_free_qp_resources(struct i40iw_device *iwdev, · 425 unmodified lines
426426 struct i40iw_qp *iwqp,
427427 u32 qp_num)
428428 {
429+ struct i40iw_pbl *iwpbl = &iwqp->iwpbl;
430+
429431 i40iw_dealloc_push_page(iwdev, &iwqp->sc_qp);
430432 if (qp_num)
431433 i40iw_free_resource(iwdev, iwdev->allocated_qps, qp_num);
434+ if (iwpbl->pbl_allocated)
435+ i40iw_free_pble(iwdev->pble_rsrc, &iwpbl->pble_alloc);
432436 i40iw_free_dma_mem(iwdev->sc_dev.hw, &iwqp->q2_ctx_mem);
433437 i40iw_free_dma_mem(iwdev->sc_dev.hw, &iwqp->kqp.dma_mem);
434438 kfree(iwqp->kqp.wrid_mem);
@@ -483,7 +487,7 @@ static int i40iw_setup_virt_qp(struct i40iw_device *iwdev, · 48 unmodified lines
483487 struct i40iw_qp *iwqp,
484488 struct i40iw_qp_init_info *init_info)
485489 {
486− struct i40iw_pbl *iwpbl = iwqp->iwpbl;
490+ struct i40iw_pbl *iwpbl = &iwqp->iwpbl;
487491 struct i40iw_qp_mr *qpmr = &iwpbl->qp_mr;
488492
489493 iwqp->page = qpmr->sq_page;
@@ -688,19 +692,22 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd, · 198 unmodified lines
688692 ucontext = to_ucontext(ibpd->uobject->context);
689693
690694 if (req.user_wqe_buffers) {
695+ struct i40iw_pbl *iwpbl;
696+
691697 spin_lock_irqsave(
692698 &ucontext->qp_reg_mem_list_lock, flags);
693− iwqp->iwpbl = i40iw_get_pbl(
699+ iwpbl = i40iw_get_pbl(
694700 (unsigned long)req.user_wqe_buffers,
695701 &ucontext->qp_reg_mem_list);
696702 spin_unlock_irqrestore(
697703 &ucontext->qp_reg_mem_list_lock, flags);
698704
699− if (!iwqp->iwpbl) {
705+ if (!iwpbl) {
700706 err_code = -ENODATA;
701707 i40iw_pr_err("no pbl info\n");
702708 goto error;
703709 }
710+ memcpy(&iwqp->iwpbl, iwpbl, sizeof(iwqp->iwpbl));
704711 }
705712 }
706713 err_code = i40iw_setup_virt_qp(iwdev, iwqp, &init_info);
@@ -1161,8 +1168,10 @@ static struct ib_cq *i40iw_create_cq(struct ib_device *ibdev, · 454 unmodified lines
11611168 memset(&req, 0, sizeof(req));
11621169 iwcq->user_mode = true;
11631170 ucontext = to_ucontext(context);
1164− if (ib_copy_from_udata(&req, udata, sizeof(struct i40iw_create_cq_req)))
1171+ if (ib_copy_from_udata(&req, udata, sizeof(struct i40iw_create_cq_req))) {
1172+ err_code = -EFAULT;
11651173 goto cq_free_resources;
1174+ }
11661175
11671176 spin_lock_irqsave(&ucontext->cq_reg_mem_list_lock, flags);
11681177 iwpbl = i40iw_get_pbl((unsigned long)req.user_cq_buffer,
@@ -2063,7 +2072,7 @@ static int i40iw_dereg_mr(struct ib_mr *ib_mr) · 894 unmodified lines
20632072 ucontext = to_ucontext(ibpd->uobject->context);
20642073 i40iw_del_memlist(iwmr, ucontext);
20652074 }
2066− if (iwpbl->pbl_allocated)
2075+ if (iwpbl->pbl_allocated && iwmr->type != IW_MEMREG_TYPE_QP)
20672076 i40iw_free_pble(iwdev->pble_rsrc, palloc);
20682077 kfree(iwmr);
20692078 return 0;
drivers/infiniband/hw/i40iw/i40iw_verbs.h+1−1
@@ -170,7 +170,7 @@ struct i40iw_qp { · 169 unmodified lines
170170 struct i40iw_qp_kmode kqp;
171171 struct i40iw_dma_mem host_ctx;
172172 struct timer_list terminate_timer;
173− struct i40iw_pbl *iwpbl;
173+ struct i40iw_pbl iwpbl;
174174 struct i40iw_dma_mem q2_ctx_mem;
175175 struct i40iw_dma_mem ietf_mem;
176176 struct completion sq_drained;
drivers/infiniband/hw/mlx4/cm.c+4−0
@@ -323,6 +323,9 @@ int mlx4_ib_multiplex_cm_handler(struct ib_device *ibdev, int port, int slave_id · 322 unmodified lines
323323 mad->mad_hdr.attr_id == CM_REP_ATTR_ID ||
324324 mad->mad_hdr.attr_id == CM_SIDR_REQ_ATTR_ID) {
325325 sl_cm_id = get_local_comm_id(mad);
326+ id = id_map_get(ibdev, &pv_cm_id, slave_id, sl_cm_id);
327+ if (id)
328+ goto cont;
326329 id = id_map_alloc(ibdev, slave_id, sl_cm_id);
327330 if (IS_ERR(id)) {
328331 mlx4_ib_warn(ibdev, "%s: id{slave: %d, sl_cm_id: 0x%x} Failed to id_map_alloc\n",
@@ -343,6 +346,7 @@ int mlx4_ib_multiplex_cm_handler(struct ib_device *ibdev, int port, int slave_id · 14 unmodified lines
343346 return -EINVAL;
344347 }
345348
349+cont:
346350 set_local_comm_id(mad, id->pv_cm_id);
347351
348352 if (mad->mad_hdr.attr_id == CM_DREQ_ATTR_ID)
drivers/infiniband/hw/mlx5/mr.c+1−1
@@ -835,7 +835,7 @@ static int mr_umem_get(struct ib_pd *pd, u64 start, u64 length, · 834 unmodified lines
835835 access_flags, 0);
836836 err = PTR_ERR_OR_ZERO(*umem);
837837 if (err < 0) {
838− mlx5_ib_err(dev, "umem get failed (%ld)\n", PTR_ERR(umem));
838+ mlx5_ib_err(dev, "umem get failed (%d)\n", err);
839839 return err;
840840 }
841841
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c+3−1
@@ -744,7 +744,8 @@ err: · 743 unmodified lines
744744 if (is_uctx_pd) {
745745 ocrdma_release_ucontext_pd(uctx);
746746 } else {
747− status = _ocrdma_dealloc_pd(dev, pd);
747+ if (_ocrdma_dealloc_pd(dev, pd))
748+ pr_err("%s: _ocrdma_dealloc_pd() failed\n", __func__);
748749 }
749750 exit:
750751 return ERR_PTR(status);
@@ -1901,6 +1902,7 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd, · 1150 unmodified lines
19011902 goto err;
19021903
19031904 if (udata == NULL) {
1905+ status = -ENOMEM;
19041906 srq->rqe_wr_id_tbl = kzalloc(sizeof(u64) * srq->rq.max_cnt,
19051907 GFP_KERNEL);
19061908 if (srq->rqe_wr_id_tbl == NULL)
drivers/infiniband/hw/qedr/verbs.c+12−4
@@ -53,6 +53,14 @@ · 52 unmodified lines
5353
5454 #define DB_ADDR_SHIFT(addr) ((addr) << DB_PWM_ADDR_OFFSET_SHIFT)
5555
56+static inline int qedr_ib_copy_to_udata(struct ib_udata *udata, void *src,
57+ size_t len)
58+{
59+ size_t min_len = min_t(size_t, len, udata->outlen);
60+
61+ return ib_copy_to_udata(udata, src, min_len);
62+}
63+
5664 int qedr_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 *pkey)
5765 {
5866 if (index > QEDR_ROCE_PKEY_TABLE_LEN)
@@ -378,7 +386,7 @@ struct ib_ucontext *qedr_alloc_ucontext(struct ib_device *ibdev, · 319 unmodified lines
378386 uresp.sges_per_srq_wr = dev->attr.max_srq_sge;
379387 uresp.max_cqes = QEDR_MAX_CQES;
380388
381− rc = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
389+ rc = qedr_ib_copy_to_udata(udata, &uresp, sizeof(uresp));
382390 if (rc)
383391 goto err;
384392
@@ -499,7 +507,7 @@ struct ib_pd *qedr_alloc_pd(struct ib_device *ibdev, · 114 unmodified lines
499507
500508 uresp.pd_id = pd_id;
501509
502− rc = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
510+ rc = qedr_ib_copy_to_udata(udata, &uresp, sizeof(uresp));
503511 if (rc) {
504512 DP_ERR(dev, "copy error pd_id=0x%x.\n", pd_id);
505513 dev->ops->rdma_dealloc_pd(dev->rdma_ctx, pd_id);
@@ -729,7 +737,7 @@ static int qedr_copy_cq_uresp(struct qedr_dev *dev, · 223 unmodified lines
729737 uresp.db_offset = DB_ADDR_SHIFT(DQ_PWM_OFFSET_UCM_RDMA_CQ_CONS_32BIT);
730738 uresp.icid = cq->icid;
731739
732− rc = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
740+ rc = qedr_ib_copy_to_udata(udata, &uresp, sizeof(uresp));
733741 if (rc)
734742 DP_ERR(dev, "copy error cqid=0x%x.\n", cq->icid);
735743
@@ -1238,7 +1246,7 @@ static int qedr_copy_qp_uresp(struct qedr_dev *dev, · 502 unmodified lines
12381246 uresp.atomic_supported = dev->atomic_cap != IB_ATOMIC_NONE;
12391247 uresp.qp_id = qp->qp_id;
12401248
1241− rc = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
1249+ rc = qedr_ib_copy_to_udata(udata, &uresp, sizeof(uresp));
12421250 if (rc)
12431251 DP_ERR(dev,
12441252 "create qp: failed a copy to user space with qp icid=0x%x.\n",
drivers/infiniband/sw/rdmavt/qp.c+1−3
@@ -1258,9 +1258,7 @@ int rvt_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, · 1257 unmodified lines
12581258
12591259 if (attr_mask & IB_QP_TIMEOUT) {
12601260 qp->timeout = attr->timeout;
1261− qp->timeout_jiffies =
1262− usecs_to_jiffies((4096UL * (1UL << qp->timeout)) /
1263− 1000UL);
1261+ qp->timeout_jiffies = rvt_timeout_to_jiffies(qp->timeout);
12641262 }
12651263
12661264 if (attr_mask & IB_QP_QKEY)
drivers/infiniband/sw/rxe/rxe_resp.c+3−0
@@ -1219,6 +1219,9 @@ void rxe_drain_req_pkts(struct rxe_qp *qp, bool notify) · 1218 unmodified lines
12191219 kfree_skb(skb);
12201220 }
12211221
1222+ if (notify)
1223+ return;
1224+
12221225 while (!qp->srq && qp->rq.queue && queue_head(qp->rq.queue))
12231226 advance_consumer(qp->rq.queue);
12241227 }
drivers/infiniband/sw/rxe/rxe_verbs.c+3−0
@@ -914,6 +914,9 @@ static int rxe_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, · 913 unmodified lines
914914
915915 spin_unlock_irqrestore(&rq->producer_lock, flags);
916916
917+ if (qp->resp.state == QP_STATE_ERROR)
918+ rxe_run_task(&qp->resp.task, 1);
919+
917920 err1:
918921 return err;
919922 }
drivers/infiniband/ulp/ipoib/ipoib_main.c+1−0
@@ -2239,6 +2239,7 @@ static struct net_device *ipoib_add_port(const char *format, · 2238 unmodified lines
22392239 goto register_failed;
22402240 }
22412241
2242+ result = -ENOMEM;
22422243 if (ipoib_cm_add_mode_attr(priv->dev))
22432244 goto sysfs_failed;
22442245 if (ipoib_add_pkey_attr(priv->dev))
drivers/infiniband/ulp/iser/iser_initiator.c+4−2
@@ -137,8 +137,10 @@ iser_prepare_write_cmd(struct iscsi_task *task, · 136 unmodified lines
137137
138138 if (unsol_sz < edtl) {
139139 hdr->flags |= ISER_WSV;
140− hdr->write_stag = cpu_to_be32(mem_reg->rkey);
141− hdr->write_va = cpu_to_be64(mem_reg->sge.addr + unsol_sz);
140+ if (buf_out->data_len > imm_sz) {
141+ hdr->write_stag = cpu_to_be32(mem_reg->rkey);
142+ hdr->write_va = cpu_to_be64(mem_reg->sge.addr + unsol_sz);
143+ }
142144
143145 iser_dbg("Cmd itt:%d, WRITE tags, RKEY:%#.4X "
144146 "VA:%#llX + unsol:%d\n",
include/rdma/ib_addr.h+4−2
@@ -205,11 +205,13 @@ static inline void iboe_addr_get_sgid(struct rdma_dev_addr *dev_addr, · 204 unmodified lines
205205 dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);
206206 if (dev) {
207207 ip4 = in_dev_get(dev);
208− if (ip4 && ip4->ifa_list && ip4->ifa_list->ifa_address) {
208+ if (ip4 && ip4->ifa_list && ip4->ifa_list->ifa_address)
209209 ipv6_addr_set_v4mapped(ip4->ifa_list->ifa_address,
210210 (struct in6_addr *)gid);
211+
212+ if (ip4)
211213 in_dev_put(ip4);
212− }
214+
213215 dev_put(dev);
214216 }
215217 }
include/rdma/rdmavt_qp.h+14−0
@@ -647,6 +647,20 @@ static inline u32 rvt_div_mtu(struct rvt_qp *qp, u32 len) · 646 unmodified lines
647647 return len >> qp->log_pmtu;
648648 }
649649
650+/**
651+ * rvt_timeout_to_jiffies - Convert a ULP timeout input into jiffies
652+ * @timeout - timeout input(0 - 31).
653+ *
654+ * Return a timeout value in jiffies.
655+ */
656+static inline unsigned long rvt_timeout_to_jiffies(u8 timeout)
657+{
658+ if (timeout > 31)
659+ timeout = 31;
660+
661+ return usecs_to_jiffies(1U << timeout) * 4096UL / 1000UL;
662+}
663+
650664 extern const int ib_rvt_state_ops[];
651665
652666 struct rvt_dev_info;