netdev.vger.kernel.org archive mirror
 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>,
	Artemy Kovalyov <artemyko@mellanox.com>,
	Guy Levi <guyle@mellanox.com>, Haggai Eran <haggaie@mellanox.com>,
	Jerome Glisse <jglisse@redhat.com>,
	Moni Shoua <monis@mellanox.com>,
	Saeed Mahameed <saeedm@mellanox.com>,
	linux-netdev <netdev@vger.kernel.org>
Subject: [PATCH rdma-next 4/4] IB/mlx5: Compare only index part of a memory window rkey
Date: Tue, 19 Mar 2019 11:24:39 +0200	[thread overview]
Message-ID: <20190319092439.10701-5-leon@kernel.org> (raw)
In-Reply-To: <20190319092439.10701-1-leon@kernel.org>

From: Artemy Kovalyov <artemyko@mellanox.com>

The InfiniBand Architecture Specification section 10.6.7.2.4 TYPE
2 MEMORY WINDOWS says that if the CI supports the Base Memory Management
Extensions defined in this specification, the R_Key format for a Type
2 Memory Window must consist of:
* 24 bit index in the most significant bits of the R_Key, which is
owned by the CI, and
* 8 bit key in the least significant bits of the R_Key, which is
owned by the Consumer.

This means that the kernel should compare only the index part of a R_Key
to determine equality with another R_Key.

Fixes: db570d7deafb ("IB/mlx5: Add ODP support to MW")
Signed-off-by: Artemy Kovalyov <artemyko@mellanox.com>
Signed-off-by: Moni Shoua <monis@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/mlx5/odp.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx5/odp.c b/drivers/infiniband/hw/mlx5/odp.c
index 95dccac1f844..2b197da1cc37 100644
--- a/drivers/infiniband/hw/mlx5/odp.c
+++ b/drivers/infiniband/hw/mlx5/odp.c
@@ -711,6 +711,15 @@ struct pf_frame {
 	int depth;
 };
 
+static bool mkey_is_eq(struct mlx5_core_mkey *mmkey, u32 key)
+{
+	if (!mmkey)
+		return false;
+	if (mmkey->type == MLX5_MKEY_MW)
+		return mlx5_base_mkey(mmkey->key) == mlx5_base_mkey(key);
+	return mmkey->key == key;
+}
+
 static int get_indirect_num_descs(struct mlx5_core_mkey *mmkey)
 {
 	struct mlx5_ib_mw *mw;
@@ -760,7 +769,7 @@ static int pagefault_single_data_segment(struct mlx5_ib_dev *dev,
 
 next_mr:
 	mmkey = __mlx5_mr_lookup(dev->mdev, mlx5_base_mkey(key));
-	if (!mmkey || mmkey->key != key) {
+	if (!mkey_is_eq(mmkey, key)) {
 		mlx5_ib_dbg(dev, "failed to find mkey %x\n", key);
 		ret = -EFAULT;
 		goto srcu_unlock;
-- 
2.20.1


  parent reply	other threads:[~2019-03-19  9:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-19  9:24 [PATCH rdma-next 0/4] Small set of mlx5 related fixes Leon Romanovsky
2019-03-19  9:24 ` [PATCH rdma-next 1/4] IB/mlx5: Reset access mask when looping inside page fault handler Leon Romanovsky
2019-03-19  9:24 ` [PATCH rdma-next 2/4] IB/mlx5: WQE dump jumps over first 16 bytes Leon Romanovsky
2019-03-19  9:24 ` [PATCH mlx5-next 3/4] net/mlx5: Decrease default mr cache size Leon Romanovsky
2019-03-27 10:07   ` Or Gerlitz
2019-03-27 11:41     ` Leon Romanovsky
2019-03-27 11:58       ` Or Gerlitz
2019-03-27 13:36         ` Leon Romanovsky
2019-03-27 14:24           ` Or Gerlitz
2019-03-19  9:24 ` Leon Romanovsky [this message]
2019-03-27 18:29 ` [PATCH rdma-next 0/4] Small set of mlx5 related fixes Jason Gunthorpe

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=20190319092439.10701-5-leon@kernel.org \
    --to=leon@kernel.org \
    --cc=artemyko@mellanox.com \
    --cc=dledford@redhat.com \
    --cc=guyle@mellanox.com \
    --cc=haggaie@mellanox.com \
    --cc=jgg@mellanox.com \
    --cc=jglisse@redhat.com \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=monis@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).