All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Doug Ledford <dledford@redhat.com>, Jason Gunthorpe <jgg@mellanox.com>
Cc: Leon Romanovsky <leonro@mellanox.com>,
	RDMA mailing list <linux-rdma@vger.kernel.org>,
	Guy Levi <guyle@mellanox.com>, Ido Kalir <idok@mellanox.com>,
	Jason Gunthorpe <jgg@ziepe.ca>, Majd Dibbiny <majd@mellanox.com>,
	Mark Zhang <markz@mellanox.com>, Moni Shoua <monis@mellanox.com>
Subject: [PATCH rdma-rc 5/8] IB/mlx5: Consolidate use_umr checks into single function
Date: Thu, 15 Aug 2019 11:38:31 +0300	[thread overview]
Message-ID: <20190815083834.9245-6-leon@kernel.org> (raw)
In-Reply-To: <20190815083834.9245-1-leon@kernel.org>

From: Moni Shoua <monis@mellanox.com>

Introduce helper function to unify various use_umr checks.

Signed-off-by: Moni Shoua <monis@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/mlx5/mlx5_ib.h | 14 ++++++++++++++
 drivers/infiniband/hw/mlx5/mr.c      |  4 +---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index f6a53455bf8b..9ae587b74b12 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -1475,4 +1475,18 @@ int bfregn_to_uar_index(struct mlx5_ib_dev *dev,
 			bool dyn_bfreg);
 
 int mlx5_ib_qp_set_counter(struct ib_qp *qp, struct rdma_counter *counter);
+
+static inline bool mlx5_ib_can_use_umr(struct mlx5_ib_dev *dev,
+				       bool do_modify_atomic)
+{
+	if (MLX5_CAP_GEN(dev->mdev, umr_modify_entity_size_disabled))
+		return false;
+
+	if (do_modify_atomic &&
+	    MLX5_CAP_GEN(dev->mdev, atomic) &&
+	    MLX5_CAP_GEN(dev->mdev, umr_modify_atomic_disabled))
+		return false;
+
+	return true;
+}
 #endif /* MLX5_IB_H */
diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index b74fad08412f..8bce65c03b84 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -1293,9 +1293,7 @@ struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
 	if (err < 0)
 		return ERR_PTR(err);
 
-	use_umr = !MLX5_CAP_GEN(dev->mdev, umr_modify_entity_size_disabled) &&
-		  (!MLX5_CAP_GEN(dev->mdev, umr_modify_atomic_disabled) ||
-		   !MLX5_CAP_GEN(dev->mdev, atomic));
+	use_umr = mlx5_ib_can_use_umr(dev, true);
 
 	if (order <= mr_cache_max_order(dev) && use_umr) {
 		mr = alloc_mr_from_cache(pd, umem, virt_addr, length, ncont,
-- 
2.20.1


  parent reply	other threads:[~2019-08-15  8:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-15  8:38 [PATCH rdma-rc 0/8] Fixes for v5.3 Leon Romanovsky
2019-08-15  8:38 ` [PATCH rdma-rc 1/8] IB/core: Fix NULL pointer dereference when bind QP to counter Leon Romanovsky
2019-08-15  8:38 ` [PATCH rdma-rc 2/8] RDMA/counters: Properly implement PID checks Leon Romanovsky
2019-08-15  8:38 ` [PATCH rdma-rc 3/8] RDMA/restrack: Rewrite PID namespace check to be reliable Leon Romanovsky
2019-08-15  8:38 ` [PATCH rdma-rc 4/8] RDMA/mlx5: Fix MR npages calculation for IB_ACCESS_HUGETLB Leon Romanovsky
2019-08-15  8:38 ` Leon Romanovsky [this message]
2019-08-15  8:38 ` [PATCH rdma-rc 6/8] IB/mlx5: Report and handle ODP support properly Leon Romanovsky
2019-08-15  8:38 ` [PATCH rdma-rc 7/8] IB/mlx5: Fix MR re-registration flow to use UMR properly Leon Romanovsky
2019-08-15  8:38 ` [PATCH rdma-rc 8/8] IB/mlx5: Block MR WR if UMR is not possible Leon Romanovsky
2019-08-15 19:29 ` [PATCH rdma-rc 0/8] Fixes for v5.3 Jason Gunthorpe
2019-08-15 20:26   ` Guy Levi(SW)
2019-08-20 16:56 ` Doug Ledford
2019-08-20 17:38   ` Jason Gunthorpe
2019-08-20 17:47     ` Doug Ledford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190815083834.9245-6-leon@kernel.org \
    --to=leon@kernel.org \
    --cc=dledford@redhat.com \
    --cc=guyle@mellanox.com \
    --cc=idok@mellanox.com \
    --cc=jgg@mellanox.com \
    --cc=jgg@ziepe.ca \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=majd@mellanox.com \
    --cc=markz@mellanox.com \
    --cc=monis@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.