Skip to content

Commit 28a0ea7

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
Pull rdma fixes from Jason Gunthorpe: "This fixes one major regression with NFS and mlx4 due to the max_sg rework in this merge window, tidies a few minor error_path regressions, and various small fixes. The HFI1 driver is broken this cycle due to a regression caused by a PCI change, it is looking like Bjorn will merge a fix for this. Also, the lingering ipoib issue I mentioned earlier still remains unfixed. Summary: - Fix possible FD type confusion crash - Fix a user trigger-able crash in cxgb4 - Fix bad handling of IOMMU resources causing user controlled leaking in bnxt - Add missing locking in ipoib to fix a rare 'stuck tx' situation - Add missing locking in cma - Add two missing missing uverbs cleanups on failure paths, regressions from this merge window - Fix a regression from this merge window that caused RDMA NFS to not work with the mlx4 driver due to the max_sg changes" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: RDMA/mlx4: Ensure that maximal send/receive SGE less than supported by HW RDMA/cma: Protect cma dev list with lock RDMA/uverbs: Fix error cleanup path of ib_uverbs_add_one() bnxt_re: Fix couple of memory leaks that could lead to IOMMU call traces IB/ipoib: Avoid a race condition between start_xmit and cm_rep_handler iw_cxgb4: only allow 1 flush on user qps IB/core: Release object lock if destroy failed RDMA/ucma: check fd type in ucma_migrate_id()
2 parents 11da3a7 + 8f28b17 commit 28a0ea7

File tree

9 files changed

+33
-12
lines changed

9 files changed

+33
-12
lines changed

drivers/infiniband/core/cma.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
724724
dgid = (union ib_gid *) &addr->sib_addr;
725725
pkey = ntohs(addr->sib_pkey);
726726

727+
mutex_lock(&lock);
727728
list_for_each_entry(cur_dev, &dev_list, list) {
728729
for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) {
729730
if (!rdma_cap_af_ib(cur_dev->device, p))
@@ -750,18 +751,19 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
750751
cma_dev = cur_dev;
751752
sgid = gid;
752753
id_priv->id.port_num = p;
754+
goto found;
753755
}
754756
}
755757
}
756758
}
757-
758-
if (!cma_dev)
759-
return -ENODEV;
759+
mutex_unlock(&lock);
760+
return -ENODEV;
760761

761762
found:
762763
cma_attach_to_dev(id_priv, cma_dev);
763-
addr = (struct sockaddr_ib *) cma_src_addr(id_priv);
764-
memcpy(&addr->sib_addr, &sgid, sizeof sgid);
764+
mutex_unlock(&lock);
765+
addr = (struct sockaddr_ib *)cma_src_addr(id_priv);
766+
memcpy(&addr->sib_addr, &sgid, sizeof(sgid));
765767
cma_translate_ib(addr, &id_priv->id.route.addr.dev_addr);
766768
return 0;
767769
}

drivers/infiniband/core/rdma_core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,8 @@ static int __uverbs_cleanup_ufile(struct ib_uverbs_file *ufile,
882882
WARN_ON(uverbs_try_lock_object(obj, UVERBS_LOOKUP_WRITE));
883883
if (!uverbs_destroy_uobject(obj, reason))
884884
ret = 0;
885+
else
886+
atomic_set(&obj->usecnt, 0);
885887
}
886888
return ret;
887889
}

drivers/infiniband/core/ucma.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ static DEFINE_MUTEX(mut);
124124
static DEFINE_IDR(ctx_idr);
125125
static DEFINE_IDR(multicast_idr);
126126

127+
static const struct file_operations ucma_fops;
128+
127129
static inline struct ucma_context *_ucma_find_context(int id,
128130
struct ucma_file *file)
129131
{
@@ -1581,6 +1583,10 @@ static ssize_t ucma_migrate_id(struct ucma_file *new_file,
15811583
f = fdget(cmd.fd);
15821584
if (!f.file)
15831585
return -ENOENT;
1586+
if (f.file->f_op != &ucma_fops) {
1587+
ret = -EINVAL;
1588+
goto file_put;
1589+
}
15841590

15851591
/* Validate current fd and prevent destruction of id. */
15861592
ctx = ucma_get_ctx(f.file->private_data, cmd.id);

drivers/infiniband/core/uverbs_main.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ static void ib_uverbs_add_one(struct ib_device *device)
10501050
uverbs_dev->num_comp_vectors = device->num_comp_vectors;
10511051

10521052
if (ib_uverbs_create_uapi(device, uverbs_dev))
1053-
goto err;
1053+
goto err_uapi;
10541054

10551055
cdev_init(&uverbs_dev->cdev, NULL);
10561056
uverbs_dev->cdev.owner = THIS_MODULE;
@@ -1077,11 +1077,10 @@ static void ib_uverbs_add_one(struct ib_device *device)
10771077

10781078
err_class:
10791079
device_destroy(uverbs_class, uverbs_dev->cdev.dev);
1080-
10811080
err_cdev:
10821081
cdev_del(&uverbs_dev->cdev);
1082+
err_uapi:
10831083
clear_bit(devnum, dev_map);
1084-
10851084
err:
10861085
if (atomic_dec_and_test(&uverbs_dev->refcount))
10871086
ib_uverbs_comp_dev(uverbs_dev);

drivers/infiniband/hw/bnxt_re/ib_verbs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,8 @@ int bnxt_re_destroy_qp(struct ib_qp *ib_qp)
833833
"Failed to destroy Shadow QP");
834834
return rc;
835835
}
836+
bnxt_qplib_free_qp_res(&rdev->qplib_res,
837+
&rdev->qp1_sqp->qplib_qp);
836838
mutex_lock(&rdev->qp_lock);
837839
list_del(&rdev->qp1_sqp->list);
838840
atomic_dec(&rdev->qp_count);

drivers/infiniband/hw/bnxt_re/qplib_fp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static int bnxt_qplib_alloc_qp_hdr_buf(struct bnxt_qplib_res *res,
196196
struct bnxt_qplib_qp *qp)
197197
{
198198
struct bnxt_qplib_q *rq = &qp->rq;
199-
struct bnxt_qplib_q *sq = &qp->rq;
199+
struct bnxt_qplib_q *sq = &qp->sq;
200200
int rc = 0;
201201

202202
if (qp->sq_hdr_buf_size && sq->hwq.max_elements) {

drivers/infiniband/hw/cxgb4/qp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,12 @@ static void flush_qp(struct c4iw_qp *qhp)
16851685
schp = to_c4iw_cq(qhp->ibqp.send_cq);
16861686

16871687
if (qhp->ibqp.uobject) {
1688+
1689+
/* for user qps, qhp->wq.flushed is protected by qhp->mutex */
1690+
if (qhp->wq.flushed)
1691+
return;
1692+
1693+
qhp->wq.flushed = 1;
16881694
t4_set_wq_in_error(&qhp->wq, 0);
16891695
t4_set_cq_in_error(&rchp->cq);
16901696
spin_lock_irqsave(&rchp->comp_handler_lock, flag);

drivers/infiniband/hw/mlx4/main.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,11 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
517517
props->page_size_cap = dev->dev->caps.page_size_cap;
518518
props->max_qp = dev->dev->quotas.qp;
519519
props->max_qp_wr = dev->dev->caps.max_wqes - MLX4_IB_SQ_MAX_SPARE;
520-
props->max_send_sge = dev->dev->caps.max_sq_sg;
521-
props->max_recv_sge = dev->dev->caps.max_rq_sg;
522-
props->max_sge_rd = MLX4_MAX_SGE_RD;
520+
props->max_send_sge =
521+
min(dev->dev->caps.max_sq_sg, dev->dev->caps.max_rq_sg);
522+
props->max_recv_sge =
523+
min(dev->dev->caps.max_sq_sg, dev->dev->caps.max_rq_sg);
524+
props->max_sge_rd = MLX4_MAX_SGE_RD;
523525
props->max_cq = dev->dev->quotas.cq;
524526
props->max_cqe = dev->dev->caps.max_cqes;
525527
props->max_mr = dev->dev->quotas.mpt;

drivers/infiniband/ulp/ipoib/ipoib_cm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,12 +1027,14 @@ static int ipoib_cm_rep_handler(struct ib_cm_id *cm_id,
10271027

10281028
skb_queue_head_init(&skqueue);
10291029

1030+
netif_tx_lock_bh(p->dev);
10301031
spin_lock_irq(&priv->lock);
10311032
set_bit(IPOIB_FLAG_OPER_UP, &p->flags);
10321033
if (p->neigh)
10331034
while ((skb = __skb_dequeue(&p->neigh->queue)))
10341035
__skb_queue_tail(&skqueue, skb);
10351036
spin_unlock_irq(&priv->lock);
1037+
netif_tx_unlock_bh(p->dev);
10361038

10371039
while ((skb = __skb_dequeue(&skqueue))) {
10381040
skb->dev = p->dev;

0 commit comments

Comments
 (0)