Skip to contentSkip to conversation

RDMA core, IPoiB and mlx5 fixes

PATCH In review Leon Romanovsky 3 participants 13 messages Sep 24, 2017 – Sep 29, 2017 4 messages not in the archive

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover RDMA core, IPoiB and mlx5 fixes

The following patch fixes struct name wrongly exposed in UAPI, number of crashes in various part of infiniband stack and mlx5 driver.

Thanks

Alex Vesker (1):
IB/ipoib: Fix inconsistency with free_netdev and free_rdma_netdev

Ilya Lesokhin (2):
IB/mlx5: Simplify mlx5_ib_cont_pages
IB/mlx5: Fix NULL deference on mlx5_ib_update_xlt failure

Leon Romanovsky (1):
IB/core: Fix typo in the name of the tag-matching cap struct

Parav Pandit (2):
IB/core: Fix qp_sec use after free access
IB: Correct MR length field to be 64-bit

Shalom Lagziel (1):
IB/ipoib: Fix sysfs Pkey create<->remove possible deadlock

 drivers/infiniband/core/security.c        |  4 ++-
 drivers/infiniband/core/uverbs_cmd.c      | 14 ++++-----
 drivers/infiniband/hw/mlx5/main.c         | 10 +++----
 drivers/infiniband/hw/mlx5/mem.c          | 47 +++++++++++--------------------
 drivers/infiniband/hw/mlx5/mr.c           | 27 +++++++++++-------
 drivers/infiniband/hw/nes/nes_verbs.c     |  4 +--
 drivers/infiniband/ulp/ipoib/ipoib_main.c | 15 +++++++---
 drivers/infiniband/ulp/ipoib/ipoib_vlan.c | 30 ++++++++++++++------
 drivers/infiniband/ulp/iser/iser_memory.c |  2 +-
 include/rdma/ib_verbs.h                   |  6 ++--
 include/uapi/rdma/ib_user_verbs.h         |  2 +-
 net/sunrpc/xprtrdma/frwr_ops.c            |  2 +-
 12 files changed, 90 insertions(+), 73 deletions(-)

--
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw

PATCH 1/7 IB/core: Fix typo in the name of the tag-matching cap struct

In reply to a message not in the archive

From: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/[email protected]>

The tag matching functionality is implemented by mlx5 driver by extending XRQ, however this internal kernel information was exposed to user space applications with *xrq* name instead of *tm*.

This patch renames *xrq* to *tm* to handle that.

---
 drivers/infiniband/core/uverbs_cmd.c | 14 +++++++-------
 drivers/infiniband/hw/mlx5/main.c    | 10 +++++-----
 include/rdma/ib_verbs.h              |  4 ++--
 include/uapi/rdma/ib_user_verbs.h    |  2 +-
 4 files changed, 15 insertions(+), 15 deletions(-)
drivers/infiniband/core/uverbs_cmd.c +7 -7
index 4ab30d832ac5..52a2cf2d83aa 100644
@@ -3869,15 +3869,15 @@ int ib_uverbs_ex_query_device(struct ib_uverbs_file *file,
 	resp.raw_packet_caps = attr.raw_packet_caps;
 	resp.response_length += sizeof(resp.raw_packet_caps);
 
-	if (ucore->outlen < resp.response_length + sizeof(resp.xrq_caps))
+	if (ucore->outlen < resp.response_length + sizeof(resp.tm_caps))
 		goto end;
 
-	resp.xrq_caps.max_rndv_hdr_size = attr.xrq_caps.max_rndv_hdr_size;
-	resp.xrq_caps.max_num_tags      = attr.xrq_caps.max_num_tags;
-	resp.xrq_caps.max_ops		= attr.xrq_caps.max_ops;
-	resp.xrq_caps.max_sge		= attr.xrq_caps.max_sge;
-	resp.xrq_caps.flags		= attr.xrq_caps.flags;
-	resp.response_length += sizeof(resp.xrq_caps);
+	resp.tm_caps.max_rndv_hdr_size	= attr.tm_caps.max_rndv_hdr_size;
+	resp.tm_caps.max_num_tags	= attr.tm_caps.max_num_tags;
+	resp.tm_caps.max_ops		= attr.tm_caps.max_ops;
+	resp.tm_caps.max_sge		= attr.tm_caps.max_sge;
+	resp.tm_caps.flags		= attr.tm_caps.flags;
+	resp.response_length += sizeof(resp.tm_caps);
 end:
 	err = ib_copy_to_udata(ucore, &resp, resp.response_length);
 	return err;
drivers/infiniband/hw/mlx5/main.c +5 -5
index 05fb4bdff6a0..d6fbad8f34aa 100644
@@ -778,13 +778,13 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
 	}
 
 	if (MLX5_CAP_GEN(mdev, tag_matching)) {
-		props->xrq_caps.max_rndv_hdr_size = MLX5_TM_MAX_RNDV_MSG_SIZE;
-		props->xrq_caps.max_num_tags =
+		props->tm_caps.max_rndv_hdr_size = MLX5_TM_MAX_RNDV_MSG_SIZE;
+		props->tm_caps.max_num_tags =
 			(1 << MLX5_CAP_GEN(mdev, log_tag_matching_list_sz)) - 1;
-		props->xrq_caps.flags = IB_TM_CAP_RC;
-		props->xrq_caps.max_ops =
+		props->tm_caps.flags = IB_TM_CAP_RC;
+		props->tm_caps.max_ops =
 			1 << MLX5_CAP_GEN(mdev, log_max_qp_sz);
-		props->xrq_caps.max_sge = MLX5_TM_MAX_SGE;
+		props->tm_caps.max_sge = MLX5_TM_MAX_SGE;
 	}
 
 	if (field_avail(typeof(resp), cqe_comp_caps, uhw->outlen)) {
include/rdma/ib_verbs.h +2 -2
index bdb1279a415b..bbb5f54db882 100644
@@ -285,7 +285,7 @@ enum ib_tm_cap_flags {
 	IB_TM_CAP_RC		    = 1 << 0,
 };
 
-struct ib_xrq_caps {
+struct ib_tm_caps {
 	/* Max size of RNDV header */
 	u32 max_rndv_hdr_size;
 	/* Max number of entries in tag matching list */
@@ -358,7 +358,7 @@ struct ib_device_attr {
 	struct ib_rss_caps	rss_caps;
 	u32			max_wq_type_rq;
 	u32			raw_packet_caps; /* Use ib_raw_packet_caps enum */
-	struct ib_xrq_caps	xrq_caps;
+	struct ib_tm_caps	tm_caps;
 };
 
 enum ib_mtu {
include/uapi/rdma/ib_user_verbs.h +1 -1
index 9a0b6479fe0c..d4e0b53bfc75 100644
@@ -261,7 +261,7 @@ struct ib_uverbs_ex_query_device_resp {
 	struct ib_uverbs_rss_caps rss_caps;
 	__u32  max_wq_type_rq;
 	__u32 raw_packet_caps;
-	struct ib_uverbs_tm_caps xrq_caps;
+	struct ib_uverbs_tm_caps tm_caps;
 };
 
 struct ib_uverbs_query_port {
Signature · 6 lines
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#8 lore raw

PATCH 2/7 IB/core: Fix qp_sec use after free access

In reply to a message not in the archive

From: Parav Pandit <parav-VPRAkNaXOzVWk0Htik3J/[email protected]>

When security_ib_alloc_security fails, qp->qp_sec memory is freed. However ib_destroy_qp still tries to access this memory which result in kernel crash. So its initialized to NULL to avoid such access.

---
 drivers/infiniband/core/security.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/core/security.c +3 -1
index 70ad19c4c73e..88bdafb297f5 100644
@@ -432,8 +432,10 @@ int ib_create_qp_security(struct ib_qp *qp, struct ib_device *dev)
 	atomic_set(&qp->qp_sec->error_list_count, 0);
 	init_completion(&qp->qp_sec->error_complete);
 	ret = security_ib_alloc_security(&qp->qp_sec->security);
-	if (ret)
+	if (ret) {
 		kfree(qp->qp_sec);
+		qp->qp_sec = NULL;
+	}
 
 	return ret;
 }
Signature · 6 lines
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#9 lore raw

PATCH 3/7 IB: Correct MR length field to be 64-bit

In reply to a message not in the archive

From: Parav Pandit <parav-VPRAkNaXOzVWk0Htik3J/[email protected]>

The ib_mr->length represents the length of the MR in bytes as per the IBTA spec 1.3 section 11.2.10.3 (REGISTER PHYSICAL MEMORY REGION).

Currently ib_mr->length field is defined as only 32-bits field. This might result into truncation and failed WRs of consumers who registers more than 4GB bytes memory regions and whose WRs accessing such MRs.

This patch makes the length 64-bit to avoid such truncation.

Cc Sagi Grimberg <[email protected]>
Cc Chuck Lever <[email protected]>
Cc Faisal Latif <[email protected]>
Fixes 4c67e2bfc8b7 ("IB/core: Introduce new fast registration API")
---
 drivers/infiniband/hw/nes/nes_verbs.c     | 4 ++--
 drivers/infiniband/ulp/iser/iser_memory.c | 2 +-
 include/rdma/ib_verbs.h                   | 2 +-
 net/sunrpc/xprtrdma/frwr_ops.c            | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
drivers/infiniband/hw/nes/nes_verbs.c +2 -2
index f0dc5f4aa177..442b9bdc0f03 100644
@@ -3232,7 +3232,7 @@ static int nes_post_send(struct ib_qp *ibqp, struct ib_send_wr *ib_wr,
 					    mr->ibmr.iova);
 			set_wqe_32bit_value(wqe->wqe_words,
 					    NES_IWARP_SQ_FMR_WQE_LENGTH_LOW_IDX,
-					    mr->ibmr.length);
+					    lower_32_bits(mr->ibmr.length));
 			set_wqe_32bit_value(wqe->wqe_words,
 					    NES_IWARP_SQ_FMR_WQE_LENGTH_HIGH_IDX, 0);
 			set_wqe_32bit_value(wqe->wqe_words,
@@ -3274,7 +3274,7 @@ static int nes_post_send(struct ib_qp *ibqp, struct ib_send_wr *ib_wr,
 					    mr->npages * 8);
 
 			nes_debug(NES_DBG_IW_TX, "SQ_REG_MR: iova_start: %llx, "
-				  "length: %d, rkey: %0x, pgl_paddr: %llx, "
+				  "length: %lld, rkey: %0x, pgl_paddr: %llx, "
 				  "page_list_len: %u, wqe_misc: %x\n",
 				  (unsigned long long) mr->ibmr.iova,
 				  mr->ibmr.length,
drivers/infiniband/ulp/iser/iser_memory.c +1 -1
index 9c3e9ab53a41..322209d5ff58 100644
@@ -154,7 +154,7 @@ static void iser_dump_page_vec(struct iser_page_vec *page_vec)
 {
 	int i;
 
-	iser_err("page vec npages %d data length %d\n",
+	iser_err("page vec npages %d data length %lld\n",
 		 page_vec->npages, page_vec->fake_mr.length);
 	for (i = 0; i < page_vec->npages; i++)
 		iser_err("vec[%d]: %llx\n", i, page_vec->pages[i]);
include/rdma/ib_verbs.h +1 -1
index bbb5f54db882..e8608b2dc844 100644
@@ -1739,7 +1739,7 @@ struct ib_mr {
 	u32		   lkey;
 	u32		   rkey;
 	u64		   iova;
-	u32		   length;
+	u64		   length;
 	unsigned int	   page_size;
 	bool		   need_inval;
 	union {
net/sunrpc/xprtrdma/frwr_ops.c +1 -1
index 5a936a6a31a3..df062e086bdb 100644
@@ -401,7 +401,7 @@ frwr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
 	if (unlikely(n != mw->mw_nents))
 		goto out_mapmr_err;
 
-	dprintk("RPC:       %s: Using frmr %p to map %u segments (%u bytes)\n",
+	dprintk("RPC:       %s: Using frmr %p to map %u segments (%llu bytes)\n",
 		__func__, frmr, mw->mw_nents, mr->length);
 
 	key = (u8)(mr->rkey & 0x000000FF);
Signature · 6 lines
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#10 lore raw

PATCH 4/7 IB/ipoib: Fix sysfs Pkey create<->remove possible deadlock

In reply to a message not in the archive

From: Shalom Lagziel <shaloml-VPRAkNaXOzVWk0Htik3J/[email protected]>

A possible ABBA lock can happen with RTNL and vlan_rwsem. For example:

Flow A: Device Flush

	__ipoib_ib_dev_flush
	down_read(vlan_rwsem) 			// Lock A
	ipoib_flush_ah
	flush_workqueue(priv->wq) 		// Wait for completion
	A work on shared WQ (Mcast carrier)
		ipoib_mcast_carrier_on_task
		while (!rtnl_trylock())         // Wait for lock B

Flow B: Sysfs PKEY delete

	ipoib_vlan_delete
	lock(RTNL) 				// Lock B
	down_write(vlan_rwsem) 			// Wait for lock A

This can happen with PKEY creates as well. The solution is to release the RTNL lock in sysfs functions in case it is not possible to lock VLAN RW semaphore and reset the SYS call.

Fixes 69956d83267e ("IB/ipoib: Sync between remove_one to sysfs calls that use rtnl_lock")
---
 drivers/infiniband/ulp/ipoib/ipoib_vlan.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/infiniband/ulp/ipoib/ipoib_vlan.c +14 -6
index 9927cd6b7082..e01c58edca15 100644
@@ -141,14 +141,17 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
 		return restart_syscall();
 	}
 
-	priv = ipoib_intf_alloc(ppriv->ca, ppriv->port, intf_name);
-	if (!priv) {
+	if (!down_write_trylock(&ppriv->vlan_rwsem)) {
 		rtnl_unlock();
 		mutex_unlock(&ppriv->sysfs_mutex);
-		return -ENOMEM;
+		return restart_syscall();
 	}
 
-	down_write(&ppriv->vlan_rwsem);
+	priv = ipoib_intf_alloc(ppriv->ca, ppriv->port, intf_name);
+	if (!priv) {
+		result = -ENOMEM;
+		goto out;
+	}
 
 	/*
 	 * First ensure this isn't a duplicate. We check the parent device and
@@ -175,7 +178,7 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
 	rtnl_unlock();
 	mutex_unlock(&ppriv->sysfs_mutex);
 
-	if (result) {
+	if (result && priv) {
 		free_netdev(priv->dev);
 		kfree(priv);
 	}
@@ -204,7 +207,12 @@ int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey)
 		return restart_syscall();
 	}
 
-	down_write(&ppriv->vlan_rwsem);
+	if (!down_write_trylock(&ppriv->vlan_rwsem)) {
+		rtnl_unlock();
+		mutex_unlock(&ppriv->sysfs_mutex);
+		return restart_syscall();
+	}
+
 	list_for_each_entry_safe(priv, tpriv, &ppriv->child_intfs, list) {
 		if (priv->pkey == pkey &&
 		    priv->child_type == IPOIB_LEGACY_CHILD) {
Signature · 6 lines
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#11 lore raw

PATCH 5/7 IB/ipoib: Fix inconsistency with free_netdev and free_rdma_netdev

In reply to a message not in the archive

From: Alex Vesker <valex-VPRAkNaXOzVWk0Htik3J/[email protected]>

Call free_rdma_netdev instead of free_netdev each time we want to release a netdevice. This call is also relevant for future freeing of offloaded child interfaces.

This patch also adds a missing call for free netdevice when releasing a parent interface that has child interfaces using ipoib_remove_one.

Fixes cd565b4b51e5 ('IB/IPoIB: Support acceleration options callbacks')
---
 drivers/infiniband/ulp/ipoib/ipoib_main.c | 15 +++++++++++----
 drivers/infiniband/ulp/ipoib/ipoib_vlan.c | 10 ++++++++--
 2 files changed, 19 insertions(+), 6 deletions(-)
drivers/infiniband/ulp/ipoib/ipoib_main.c +11 -4
index bac95b509a9b..dcc77014018d 100644
@@ -2180,6 +2180,7 @@ static struct net_device *ipoib_add_port(const char *format,
 {
 	struct ipoib_dev_priv *priv;
 	struct ib_port_attr attr;
+	struct rdma_netdev *rn;
 	int result = -ENOMEM;
 
 	priv = ipoib_intf_alloc(hca, port, format);
@@ -2279,7 +2280,8 @@ static struct net_device *ipoib_add_port(const char *format,
 	ipoib_dev_cleanup(priv->dev);
 
 device_init_failed:
-	free_netdev(priv->dev);
+	rn = netdev_priv(priv->dev);
+	rn->free_rdma_netdev(priv->dev);
 	kfree(priv);
 
 alloc_mem_failed:
@@ -2328,7 +2330,7 @@ static void ipoib_remove_one(struct ib_device *device, void *client_data)
 		return;
 
 	list_for_each_entry_safe(priv, tmp, dev_list, list) {
-		struct rdma_netdev *rn = netdev_priv(priv->dev);
+		struct rdma_netdev *parent_rn = netdev_priv(priv->dev);
 
 		ib_unregister_event_handler(&priv->event_handler);
 		flush_workqueue(ipoib_workqueue);
@@ -2350,10 +2352,15 @@ static void ipoib_remove_one(struct ib_device *device, void *client_data)
 		unregister_netdev(priv->dev);
 		mutex_unlock(&priv->sysfs_mutex);
 
-		rn->free_rdma_netdev(priv->dev);
+		parent_rn->free_rdma_netdev(priv->dev);
+
+		list_for_each_entry_safe(cpriv, tcpriv, &priv->child_intfs, list) {
+			struct rdma_netdev *child_rn;
 
-		list_for_each_entry_safe(cpriv, tcpriv, &priv->child_intfs, list)
+			child_rn = netdev_priv(cpriv->dev);
+			child_rn->free_rdma_netdev(cpriv->dev);
 			kfree(cpriv);
+		}
 
 		kfree(priv);
 	}
drivers/infiniband/ulp/ipoib/ipoib_vlan.c +8 -2
index e01c58edca15..55a9b71ed05a 100644
@@ -179,7 +179,10 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
 	mutex_unlock(&ppriv->sysfs_mutex);
 
 	if (result && priv) {
-		free_netdev(priv->dev);
+		struct rdma_netdev *rn;
+
+		rn = netdev_priv(priv->dev);
+		rn->free_rdma_netdev(priv->dev);
 		kfree(priv);
 	}
 
@@ -232,7 +235,10 @@ int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey)
 	mutex_unlock(&ppriv->sysfs_mutex);
 
 	if (dev) {
-		free_netdev(dev);
+		struct rdma_netdev *rn;
+
+		rn = netdev_priv(dev);
+		rn->free_rdma_netdev(priv->dev);
 		kfree(priv);
 		return 0;
 	}
Signature · 6 lines
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#12 lore raw

PATCH 6/7 IB/mlx5: Simplify mlx5_ib_cont_pages

In reply to a message not in the archive

From: Ilya Lesokhin <ilyal-VPRAkNaXOzVWk0Htik3J/[email protected]>

The patch simplifies mlx5_ib_cont_pages and fixes the following issues in the original implementation:

First issues is related to alignment of the PFNs. After the check base + p != PFN, the alignment of the PFN wasn't checked. So the PFN sequence 0, 1, 1, 2 would result in a page_shift of 13 even though the 3rd PFN is not 8KB aligned.

This wasn't actually a bug because it was supported by all the existing mlx5 compatible device, but we don't want to require this support in all future devices.

Another issue is because the inner loop didn't advance PFN so the test "if (base + p != pfn)" always failed for SGE with len > (1<<page_shift).

Fixes e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters")
---
 drivers/infiniband/hw/mlx5/mem.c | 47 +++++++++++++++-------------------------
 1 file changed, 17 insertions(+), 30 deletions(-)
drivers/infiniband/hw/mlx5/mem.c +17 -30
index 914f212e7ef6..f3dbd75a0a96 100644
@@ -50,13 +50,9 @@ void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr,
 {
 	unsigned long tmp;
 	unsigned long m;
-	int i, k;
-	u64 base = 0;
-	int p = 0;
-	int skip;
-	int mask;
-	u64 len;
-	u64 pfn;
+	u64 base = ~0, p = 0;
+	u64 len, pfn;
+	int i = 0;
 	struct scatterlist *sg;
 	int entry;
 	unsigned long page_shift = umem->page_shift;
@@ -76,33 +72,24 @@ void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr,
 	m = find_first_bit(&tmp, BITS_PER_LONG);
 	if (max_page_shift)
 		m = min_t(unsigned long, max_page_shift - page_shift, m);
-	skip = 1 << m;
-	mask = skip - 1;
-	i = 0;
+
 	for_each_sg(umem->sg_head.sgl, sg, umem->nmap, entry) {
 		len = sg_dma_len(sg) >> page_shift;
 		pfn = sg_dma_address(sg) >> page_shift;
-		for (k = 0; k < len; k++) {
-			if (!(i & mask)) {
-				tmp = (unsigned long)pfn;
-				m = min_t(unsigned long, m, find_first_bit(&tmp, BITS_PER_LONG));
-				skip = 1 << m;
-				mask = skip - 1;
-				base = pfn;
-				p = 0;
-			} else {
-				if (base + p != pfn) {
-					tmp = (unsigned long)p;
-					m = find_first_bit(&tmp, BITS_PER_LONG);
-					skip = 1 << m;
-					mask = skip - 1;
-					base = pfn;
-					p = 0;
-				}
-			}
-			p++;
-			i++;
+		if (base + p != pfn) {
+			/* If either the offset or the new
+			 * base are unaligned update m
+			 */
+			tmp = (unsigned long)(pfn | p);
+			if (!IS_ALIGNED(tmp, 1 << m))
+				m = find_first_bit(&tmp, BITS_PER_LONG);
+
+			base = pfn;
+			p = 0;
 		}
+
+		p += len;
+		i += len;
 	}
 
 	if (i) {
Signature · 6 lines
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#13 lore raw

PATCH 7/7 IB/mlx5: Fix NULL deference on mlx5_ib_update_xlt failure

In reply to a message not in the archive

From: Ilya Lesokhin <ilyal-VPRAkNaXOzVWk0Htik3J/[email protected]>

mlx5_ib_reg_user_mr called mlx5_ib_dereg_mr in case of MR population failure. This resulted in a NULL dereference as ibmr->device wasn't initialized yet.

We address this by adding an internal dereg_mr function that can handle partially initialized MRs, and fixing clean_mr to work on partially initialized MRs.

Fixes ff740aefecb9 ("IB/mlx5: Decouple MR allocation and population flows")
---
 drivers/infiniband/hw/mlx5/mr.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)
drivers/infiniband/hw/mlx5/mr.c +17 -10
index 0e2789d9bb4d..37bbc543847a 100644
@@ -47,7 +47,8 @@ enum {
 
 #define MLX5_UMR_ALIGN 2048
 
-static int clean_mr(struct mlx5_ib_mr *mr);
+static int clean_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr);
+static int dereg_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr);
 static int mr_cache_max_order(struct mlx5_ib_dev *dev);
 static int unreg_umr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr);
 
@@ -1270,8 +1271,9 @@ struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
 
 		err = mlx5_ib_update_xlt(mr, 0, ncont, page_shift,
 					 update_xlt_flags);
+
 		if (err) {
-			mlx5_ib_dereg_mr(&mr->ibmr);
+			dereg_mr(dev, mr);
 			return ERR_PTR(err);
 		}
 	}
@@ -1356,7 +1358,7 @@ int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,
 		err = mr_umem_get(pd, addr, len, access_flags, &mr->umem,
 				  &npages, &page_shift, &ncont, &order);
 		if (err < 0) {
-			clean_mr(mr);
+			clean_mr(dev, mr);
 			return err;
 		}
 	}
@@ -1410,7 +1412,7 @@ int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,
 		if (err) {
 			mlx5_ib_warn(dev, "Failed to rereg UMR\n");
 			ib_umem_release(mr->umem);
-			clean_mr(mr);
+			clean_mr(dev, mr);
 			return err;
 		}
 	}
@@ -1469,9 +1471,8 @@ mlx5_free_priv_descs(struct mlx5_ib_mr *mr)
 	}
 }
 
-static int clean_mr(struct mlx5_ib_mr *mr)
+static int clean_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr)
 {
-	struct mlx5_ib_dev *dev = to_mdev(mr->ibmr.device);
 	int allocated_from_cache = mr->allocated_from_cache;
 	int err;
 
@@ -1507,10 +1508,8 @@ static int clean_mr(struct mlx5_ib_mr *mr)
 	return 0;
 }
 
-int mlx5_ib_dereg_mr(struct ib_mr *ibmr)
+static int dereg_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr)
 {
-	struct mlx5_ib_dev *dev = to_mdev(ibmr->device);
-	struct mlx5_ib_mr *mr = to_mmr(ibmr);
 	int npages = mr->npages;
 	struct ib_umem *umem = mr->umem;
 
@@ -1539,7 +1538,7 @@ int mlx5_ib_dereg_mr(struct ib_mr *ibmr)
 	}
 #endif
 
-	clean_mr(mr);
+	clean_mr(dev, mr);
 
 	if (umem) {
 		ib_umem_release(umem);
@@ -1549,6 +1548,14 @@ int mlx5_ib_dereg_mr(struct ib_mr *ibmr)
 	return 0;
 }
 
+int mlx5_ib_dereg_mr(struct ib_mr *ibmr)
+{
+	struct mlx5_ib_dev *dev = to_mdev(ibmr->device);
+	struct mlx5_ib_mr *mr = to_mmr(ibmr);
+
+	return dereg_mr(dev, mr);
+}
+
 struct ib_mr *mlx5_ib_alloc_mr(struct ib_pd *pd,
 			       enum ib_mr_type mr_type,
 			       u32 max_num_sg)
Signature · 6 lines
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw

Re: [PATCH rdma-rc 1/7] IB/core: Fix typo in the name of the tag-matching cap struct

In reply to a message not in the archive
Quoted 11 lines · Sun, Sep 24, 2017 at 08:46:29PM CEST, [email protected].…

From: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/[email protected]>

The tag matching functionality is implemented by mlx5 driver by extending XRQ, however this internal kernel information was exposed to user space applications with *xrq* name instead of *tm*.

This patch renames *xrq* to *tm* to handle that.

[...]

include/uapi/rdma/ib_user_verbs.h struct ib_uverbs_ex_query_device_resp { · line 264

Quoted 10 lines
include/uapi/rdma/ib_user_verbs.h +1 -1
index 9a0b6479fe0c..d4e0b53bfc75 100644
@@ -261,7 +261,7 @@ struct ib_uverbs_ex_query_device_resp {
 	struct ib_uverbs_rss_caps rss_caps;
 	__u32  max_wq_type_rq;
 	__u32 raw_packet_caps;
-	struct ib_uverbs_tm_caps xrq_caps;
+	struct ib_uverbs_tm_caps tm_caps;

Breaks UAPI?

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

Re: [PATCH rdma-rc 1/7] IB/core: Fix typo in the name of the tag-matching cap struct

Quoted 15 lines · Jiri Pirko
Quoted 11 lines · Sun, Sep 24, 2017 at 08:46:29PM CEST, [email protected].…

From: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/[email protected]>

The tag matching functionality is implemented by mlx5 driver by extending XRQ, however this internal kernel information was exposed to user space applications with *xrq* name instead of *tm*.

This patch renames *xrq* to *tm* to handle that.

[...]

Quoted 12 lines

include/uapi/rdma/ib_user_verbs.h struct ib_uverbs_ex_query_device_resp { · line 264

Quoted 10 lines
include/uapi/rdma/ib_user_verbs.h +1 -1
index 9a0b6479fe0c..d4e0b53bfc75 100644
@@ -261,7 +261,7 @@ struct ib_uverbs_ex_query_device_resp {
 	struct ib_uverbs_rss_caps rss_caps;
 	__u32  max_wq_type_rq;
 	__u32 raw_packet_caps;
-	struct ib_uverbs_tm_caps xrq_caps;
+	struct ib_uverbs_tm_caps tm_caps;

Breaks UAPI?

Not really, this UAPI was introduced in latest merge window and wasn't exposed to users yet. The -rcX rally is the time where such fixes are supposed to happen.

Thanks

Quoted 1 line
#7 lore raw

Re: [PATCH rdma-rc 1/7] IB/core: Fix typo in the name of the tag-matching cap struct

In reply to a message not in the archive
Quoted 29 lines · Mon, Sep 25, 2017 at 05:45:38AM CEST, [email protected].…
Quoted 15 lines · Jiri Pirko
Quoted 11 lines · Sun, Sep 24, 2017 at 08:46:29PM CEST, [email protected].…

From: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/[email protected]>

The tag matching functionality is implemented by mlx5 driver by extending XRQ, however this internal kernel information was exposed to user space applications with *xrq* name instead of *tm*.

This patch renames *xrq* to *tm* to handle that.

[...]

Quoted 12 lines

include/uapi/rdma/ib_user_verbs.h struct ib_uverbs_ex_query_device_resp { · line 264

Quoted 10 lines
include/uapi/rdma/ib_user_verbs.h +1 -1
index 9a0b6479fe0c..d4e0b53bfc75 100644
@@ -261,7 +261,7 @@ struct ib_uverbs_ex_query_device_resp {
 	struct ib_uverbs_rss_caps rss_caps;
 	__u32  max_wq_type_rq;
 	__u32 raw_packet_caps;
-	struct ib_uverbs_tm_caps xrq_caps;
+	struct ib_uverbs_tm_caps tm_caps;

Breaks UAPI?

Quoted 3 lines

Not really, this UAPI was introduced in latest merge window and wasn't exposed to users yet. The -rcX rally is the time where such fixes are supposed to happen.

Would be nice to mention this in the patch description. Perhaps under "---".

Quoted 4 lines

Thanks

Quoted 1 line

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#14 lore raw
In reply to a message not in the archive
Quoted 38 lines · Leon Romanovsky

The following patch fixes struct name wrongly exposed in UAPI, number of crashes in various part of infiniband stack and mlx5 driver.

Thanks

Alex Vesker (1):
IB/ipoib: Fix inconsistency with free_netdev and free_rdma_netdev

Ilya Lesokhin (2):
IB/mlx5: Simplify mlx5_ib_cont_pages
IB/mlx5: Fix NULL deference on mlx5_ib_update_xlt failure

Leon Romanovsky (1):
IB/core: Fix typo in the name of the tag-matching cap struct

Parav Pandit (2):
IB/core: Fix qp_sec use after free access
IB: Correct MR length field to be 64-bit

Shalom Lagziel (1):
IB/ipoib: Fix sysfs Pkey create<->remove possible deadlock

 drivers/infiniband/core/security.c        |  4 ++-
 drivers/infiniband/core/uverbs_cmd.c      | 14 ++++-----
 drivers/infiniband/hw/mlx5/main.c         | 10 +++----
 drivers/infiniband/hw/mlx5/mem.c          | 47 +++++++++++--------
------------
 drivers/infiniband/hw/mlx5/mr.c           | 27 +++++++++++-------
 drivers/infiniband/hw/nes/nes_verbs.c     |  4 +--
 drivers/infiniband/ulp/ipoib/ipoib_main.c | 15 +++++++---
 drivers/infiniband/ulp/ipoib/ipoib_vlan.c | 30 ++++++++++++++------
 drivers/infiniband/ulp/iser/iser_memory.c |  2 +-
 include/rdma/ib_verbs.h                   |  6 ++--
 include/uapi/rdma/ib_user_verbs.h         |  2 +-
 net/sunrpc/xprtrdma/frwr_ops.c            |  2 +-
 12 files changed, 90 insertions(+), 73 deletions(-)
Quoted 2 lines

--
2.14.1

It appears I failed to send notification that this series had been applied for rc. You probably noticed it was in the pull request and has already been taken, but just in case you hadn't, here's your notice ;-)

Signature · 8 lines
Doug Ledford <[email protected]>
    GPG KeyID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#16 lore raw
In reply to a message not in the archive
Quoted 39 lines · Doug Ledford
Quoted 38 lines · Leon Romanovsky

The following patch fixes struct name wrongly exposed in UAPI, number of crashes in various part of infiniband stack and mlx5 driver.

Thanks

Alex Vesker (1):
IB/ipoib: Fix inconsistency with free_netdev and free_rdma_netdev

Ilya Lesokhin (2):
IB/mlx5: Simplify mlx5_ib_cont_pages
IB/mlx5: Fix NULL deference on mlx5_ib_update_xlt failure

Leon Romanovsky (1):
IB/core: Fix typo in the name of the tag-matching cap struct

Parav Pandit (2):
IB/core: Fix qp_sec use after free access
IB: Correct MR length field to be 64-bit

Shalom Lagziel (1):
IB/ipoib: Fix sysfs Pkey create<->remove possible deadlock

 drivers/infiniband/core/security.c        |  4 ++-
 drivers/infiniband/core/uverbs_cmd.c      | 14 ++++-----
 drivers/infiniband/hw/mlx5/main.c         | 10 +++----
 drivers/infiniband/hw/mlx5/mem.c          | 47 +++++++++++--------
------------
 drivers/infiniband/hw/mlx5/mr.c           | 27 +++++++++++-------
 drivers/infiniband/hw/nes/nes_verbs.c     |  4 +--
 drivers/infiniband/ulp/ipoib/ipoib_main.c | 15 +++++++---
 drivers/infiniband/ulp/ipoib/ipoib_vlan.c | 30 ++++++++++++++------
 drivers/infiniband/ulp/iser/iser_memory.c |  2 +-
 include/rdma/ib_verbs.h                   |  6 ++--
 include/uapi/rdma/ib_user_verbs.h         |  2 +-
 net/sunrpc/xprtrdma/frwr_ops.c            |  2 +-
 12 files changed, 90 insertions(+), 73 deletions(-)
Quoted 7 lines
Quoted 2 lines

--
2.14.1

It appears I failed to send notification that this series had been applied for rc. You probably noticed it was in the pull request and has already been taken, but just in case you hadn't, here's your notice ;-)

indeed, I saw it.

Thanks for the update.

Quoted 7 lines

--
Doug Ledford <[email protected]>

    GPG KeyID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD