66293a
From 174e7b137042f19b5ce88beb4fc0ff4ec6b0c72a Mon Sep 17 00:00:00 2001
66293a
From: Md Haris Iqbal <haris.phnx@gmail.com>
66293a
Date: Thu, 7 Jul 2022 09:30:06 +0200
66293a
Subject: [PATCH 1/1] RDMA/rxe: For invalidate compare according to set keys in
66293a
 mr
66293a
Git-commit: 174e7b137042f19b5ce88beb4fc0ff4ec6b0c72a
66293a
Patch-mainline: v6.0
66293a
References: git-fixes
66293a
66293a
The 'rkey' input can be an lkey or rkey, and in rxe the lkey or rkey have
66293a
the same value, including the variant bits.
66293a
66293a
So, if mr->rkey is set, compare the invalidate key with it, otherwise
66293a
compare with the mr->lkey.
66293a
66293a
Since we already did a lookup on the non-varient bits to get this far, the
66293a
check's only purpose is to confirm that the wqe has the correct variant
66293a
bits.
66293a
66293a
Fixes: 001345339f4c ("RDMA/rxe: Separate HW and SW l/rkeys")
66293a
Link: https://lore.kernel.org/r/20220707073006.328737-1-haris.phnx@gmail.com
66293a
Signed-off-by: Md Haris Iqbal <haris.phnx@gmail.com>
66293a
Reviewed-by: Bob Pearson <rpearsonhpe@gmail.com>
66293a
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
66293a
Acked-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
66293a
---
66293a
 drivers/infiniband/sw/rxe/rxe_loc.h |  2 +-
66293a
 drivers/infiniband/sw/rxe/rxe_mr.c  | 12 ++++++------
66293a
 2 files changed, 7 insertions(+), 7 deletions(-)
66293a
66293a
diff --git a/drivers/infiniband/sw/rxe/rxe_loc.h b/drivers/infiniband/sw/rxe/rxe_loc.h
66293a
index 336164843db4..f9af30f582c6 100644
66293a
--- a/drivers/infiniband/sw/rxe/rxe_loc.h
66293a
+++ b/drivers/infiniband/sw/rxe/rxe_loc.h
66293a
@@ -77,7 +77,7 @@ struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key,
66293a
 			 enum rxe_mr_lookup_type type);
66293a
 int mr_check_range(struct rxe_mr *mr, u64 iova, size_t length);
66293a
 int advance_dma_data(struct rxe_dma_info *dma, unsigned int length);
66293a
-int rxe_invalidate_mr(struct rxe_qp *qp, u32 rkey);
66293a
+int rxe_invalidate_mr(struct rxe_qp *qp, u32 key);
66293a
 int rxe_reg_fast_mr(struct rxe_qp *qp, struct rxe_send_wqe *wqe);
66293a
 int rxe_mr_set_page(struct ib_mr *ibmr, u64 addr);
66293a
 int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata);
66293a
diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c
66293a
index 9a5c2af6a56f..6fdbd7929ccc 100644
66293a
--- a/drivers/infiniband/sw/rxe/rxe_mr.c
66293a
+++ b/drivers/infiniband/sw/rxe/rxe_mr.c
66293a
@@ -576,22 +576,22 @@ struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key,
66293a
 	return mr;
66293a
 }
66293a
 
66293a
-int rxe_invalidate_mr(struct rxe_qp *qp, u32 rkey)
66293a
+int rxe_invalidate_mr(struct rxe_qp *qp, u32 key)
66293a
 {
66293a
 	struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
66293a
 	struct rxe_mr *mr;
66293a
 	int ret;
66293a
 
66293a
-	mr = rxe_pool_get_index(&rxe->mr_pool, rkey >> 8);
66293a
+	mr = rxe_pool_get_index(&rxe->mr_pool, key >> 8);
66293a
 	if (!mr) {
66293a
-		pr_err("%s: No MR for rkey %#x\n", __func__, rkey);
66293a
+		pr_err("%s: No MR for key %#x\n", __func__, key);
66293a
 		ret = -EINVAL;
66293a
 		goto err;
66293a
 	}
66293a
 
66293a
-	if (rkey != mr->rkey) {
66293a
-		pr_err("%s: rkey (%#x) doesn't match mr->rkey (%#x)\n",
66293a
-			__func__, rkey, mr->rkey);
66293a
+	if (mr->rkey ? (key != mr->rkey) : (key != mr->lkey)) {
66293a
+		pr_err("%s: wr key (%#x) doesn't match mr key (%#x)\n",
66293a
+			__func__, key, (mr->rkey ? mr->rkey : mr->lkey));
66293a
 		ret = -EINVAL;
66293a
 		goto err_drop_ref;
66293a
 	}
66293a
-- 
66293a
2.38.0.1.gee35aeee4b76
66293a