Skip to content

Commit b601792

Browse files
ddmatsujgunthorpe
authored andcommitted
RDMA/rxe: Add page invalidation support
On page invalidation, an MMU notifier callback is invoked to unmap DMA addresses and update the driver page table(umem_odp->dma_list). The callback is registered when an ODP-enabled MR is created. Link: https://patch.msgid.link/r/[email protected] Signed-off-by: Daisuke Matsuda <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 7f88072 commit b601792

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

drivers/infiniband/sw/rxe/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ rdma_rxe-y := \
2323
rxe_task.o \
2424
rxe_net.o \
2525
rxe_hw_counters.o
26+
27+
rdma_rxe-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += rxe_odp.o

drivers/infiniband/sw/rxe/rxe_loc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,7 @@ static inline unsigned int wr_opcode_mask(int opcode, struct rxe_qp *qp)
181181
return rxe_wr_opcode_info[opcode].mask[qp->ibqp.qp_type];
182182
}
183183

184+
/* rxe_odp.c */
185+
extern const struct mmu_interval_notifier_ops rxe_mn_ops;
186+
184187
#endif /* RXE_LOC_H */

drivers/infiniband/sw/rxe/rxe_odp.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
2+
/*
3+
* Copyright (c) 2022-2023 Fujitsu Ltd. All rights reserved.
4+
*/
5+
6+
#include <linux/hmm.h>
7+
8+
#include <rdma/ib_umem_odp.h>
9+
10+
#include "rxe.h"
11+
12+
static bool rxe_ib_invalidate_range(struct mmu_interval_notifier *mni,
13+
const struct mmu_notifier_range *range,
14+
unsigned long cur_seq)
15+
{
16+
struct ib_umem_odp *umem_odp =
17+
container_of(mni, struct ib_umem_odp, notifier);
18+
unsigned long start, end;
19+
20+
if (!mmu_notifier_range_blockable(range))
21+
return false;
22+
23+
mutex_lock(&umem_odp->umem_mutex);
24+
mmu_interval_set_seq(mni, cur_seq);
25+
26+
start = max_t(u64, ib_umem_start(umem_odp), range->start);
27+
end = min_t(u64, ib_umem_end(umem_odp), range->end);
28+
29+
/* update umem_odp->dma_list */
30+
ib_umem_odp_unmap_dma_pages(umem_odp, start, end);
31+
32+
mutex_unlock(&umem_odp->umem_mutex);
33+
return true;
34+
}
35+
36+
const struct mmu_interval_notifier_ops rxe_mn_ops = {
37+
.invalidate = rxe_ib_invalidate_range,
38+
};

0 commit comments

Comments
 (0)