diff mbox series

[for-next,1/5] RDMA/rxe: Remove rxe_phys_buf.size

Message ID 1668141030-2-2-git-send-email-lizhijian@fujitsu.com (mailing list archive)
State Changes Requested
Delegated to: Jason Gunthorpe
Headers show
Series iova_to_vaddr refactor | expand

Commit Message

Zhijian Li (Fujitsu) Nov. 11, 2022, 4:30 a.m. UTC
Every rxe_phys_buf used by either IB_MR_TYPE_MEM_REG or IB_MR_TYPE_USER
has the same size, which should be same with ibmr->page_size. So we can
use ibmr->page_size correspondingly.

Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
---
 drivers/infiniband/sw/rxe/rxe_mr.c    | 11 ++++-------
 drivers/infiniband/sw/rxe/rxe_verbs.c |  1 -
 drivers/infiniband/sw/rxe/rxe_verbs.h |  1 -
 3 files changed, 4 insertions(+), 9 deletions(-)

Comments

Jason Gunthorpe Nov. 18, 2022, 4:38 p.m. UTC | #1
On Fri, Nov 11, 2022 at 04:30:26AM +0000, Li Zhijian wrote:
> Every rxe_phys_buf used by either IB_MR_TYPE_MEM_REG or IB_MR_TYPE_USER
> has the same size, which should be same with ibmr->page_size. So we can
> use ibmr->page_size correspondingly.

ibmr->page_size is really only supposed to be used by MRs that are
going to be used with FMR. It is some protocol to pass information to
the IB_WR_REG_MR op

The whole way rxe stores the MRs really could stand to be modernized,
just replace the whole mr->map and everything under it with a simple
xarray of page pointers.

You are right though, the page_size of the logical page array should
be global to the mr, not stored in every entry. It isn't a sgl, it is
a dynamic array. Just don't abuse ibmr->page_size for it..

Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c
index d4f10c2d1aa7..f6366a635b92 100644
--- a/drivers/infiniband/sw/rxe/rxe_mr.c
+++ b/drivers/infiniband/sw/rxe/rxe_mr.c
@@ -145,6 +145,7 @@  int rxe_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length, u64 iova,
 
 	mr->page_shift = PAGE_SHIFT;
 	mr->page_mask = PAGE_SIZE - 1;
+	mr->ibmr.page_size = PAGE_SIZE;
 
 	num_buf			= 0;
 	map = mr->map;
@@ -167,7 +168,6 @@  int rxe_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length, u64 iova,
 			}
 
 			buf->addr = (uintptr_t)vaddr;
-			buf->size = PAGE_SIZE;
 			num_buf++;
 			buf++;
 
@@ -219,7 +219,7 @@  static void lookup_iova(struct rxe_mr *mr, u64 iova, int *m_out, int *n_out,
 	size_t offset = iova - mr->ibmr.iova + mr->offset;
 	int			map_index;
 	int			buf_index;
-	u64			length;
+	u64			length = mr->ibmr.page_size;
 
 	if (likely(mr->page_shift)) {
 		*offset_out = offset & mr->page_mask;
@@ -230,8 +230,6 @@  static void lookup_iova(struct rxe_mr *mr, u64 iova, int *m_out, int *n_out,
 		map_index = 0;
 		buf_index = 0;
 
-		length = mr->map[map_index]->buf[buf_index].size;
-
 		while (offset >= length) {
 			offset -= length;
 			buf_index++;
@@ -240,7 +238,6 @@  static void lookup_iova(struct rxe_mr *mr, u64 iova, int *m_out, int *n_out,
 				map_index++;
 				buf_index = 0;
 			}
-			length = mr->map[map_index]->buf[buf_index].size;
 		}
 
 		*m_out = map_index;
@@ -274,7 +271,7 @@  void *iova_to_vaddr(struct rxe_mr *mr, u64 iova, int length)
 
 	lookup_iova(mr, iova, &m, &n, &offset);
 
-	if (offset + length > mr->map[m]->buf[n].size) {
+	if (offset + length > mr->ibmr.page_size) {
 		pr_warn("crosses page boundary\n");
 		addr = NULL;
 		goto out;
@@ -336,7 +333,7 @@  int rxe_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, int length,
 		src = (dir == RXE_TO_MR_OBJ) ? addr : va;
 		dest = (dir == RXE_TO_MR_OBJ) ? va : addr;
 
-		bytes	= buf->size - offset;
+		bytes	= mr->ibmr.page_size - offset;
 
 		if (bytes > length)
 			bytes = length;
diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
index 88825edc7dce..5da394c675bf 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
@@ -991,7 +991,6 @@  static int rxe_set_page(struct ib_mr *ibmr, u64 addr)
 	buf = &map->buf[mr->nbuf % RXE_BUF_PER_MAP];
 
 	buf->addr = addr;
-	buf->size = ibmr->page_size;
 	mr->nbuf++;
 
 	return 0;
diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h
index 22a299b0a9f0..acab785ba7e2 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.h
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.h
@@ -281,7 +281,6 @@  enum rxe_mr_lookup_type {
 
 struct rxe_phys_buf {
 	u64      addr;
-	u64      size;
 };
 
 struct rxe_map {