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

Li Zhijian
2022-11-11T04:31:02Z

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(-)

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 {
--
2.31.1