Merge tag 'rds-odp-for-5.5' into rdma.git for-next
From https://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma Leon Romanovsky says: ==================== Use ODP MRs for kernel ULPs The following series extends MR creation routines to allow creation of user MRs through kernel ULPs as a proxy. The immediate use case is to allow RDS to work over FS-DAX, which requires ODP (on-demand-paging) MRs to be created and such MRs were not possible to create prior this series. The first part of this patchset extends RDMA to have special verb ib_reg_user_mr(). The common use case that uses this function is a userspace application that allocates memory for HCA access but the responsibility to register the memory at the HCA is on an kernel ULP. This ULP acts as an agent for the userspace application. The second part provides advise MR functionality for ULPs. This is integral part of ODP flows and used to trigger pagefaults in advance to prepare memory before running working set. The third part is actual user of those in-kernel APIs. ==================== * tag 'rds-odp-for-5.5': net/rds: Use prefetch for On-Demand-Paging MR net/rds: Handle ODP mr registration/unregistration net/rds: Detect need of On-Demand-Paging memory registration RDMA/mlx5: Fix handling of IOVA != user_va in ODP paths IB/mlx5: Mask out unsupported ODP capabilities for kernel QPs RDMA/mlx5: Don't fake udata for kernel path IB/mlx5: Add ODP WQE handlers for kernel QPs IB/core: Add interface to advise_mr for kernel users IB/core: Introduce ib_reg_user_mr IB: Allow calls to ib_umem_get from kernel ULPs Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
@@ -535,7 +535,7 @@ struct mlx5_ib_mr *mlx5_ib_alloc_implicit_mr(struct mlx5_ib_pd *pd,
|
||||
struct mlx5_ib_mr *imr;
|
||||
int err;
|
||||
|
||||
umem_odp = ib_umem_odp_alloc_implicit(udata, access_flags);
|
||||
umem_odp = ib_umem_odp_alloc_implicit(&dev->ib_dev, access_flags);
|
||||
if (IS_ERR(umem_odp))
|
||||
return ERR_CAST(umem_odp);
|
||||
|
||||
@@ -662,11 +662,10 @@ static int pagefault_real_mr(struct mlx5_ib_mr *mr, struct ib_umem_odp *odp,
|
||||
bool downgrade = flags & MLX5_PF_FLAGS_DOWNGRADE;
|
||||
unsigned long current_seq;
|
||||
u64 access_mask;
|
||||
u64 start_idx, page_mask;
|
||||
u64 start_idx;
|
||||
|
||||
page_shift = odp->page_shift;
|
||||
page_mask = ~(BIT(page_shift) - 1);
|
||||
start_idx = (user_va - (mr->mmkey.iova & page_mask)) >> page_shift;
|
||||
start_idx = (user_va - ib_umem_start(odp)) >> page_shift;
|
||||
access_mask = ODP_READ_ALLOWED_BIT;
|
||||
|
||||
if (odp->umem.writable && !downgrade)
|
||||
@@ -805,11 +804,19 @@ static int pagefault_mr(struct mlx5_ib_mr *mr, u64 io_virt, size_t bcnt,
|
||||
{
|
||||
struct ib_umem_odp *odp = to_ib_umem_odp(mr->umem);
|
||||
|
||||
if (unlikely(io_virt < mr->mmkey.iova))
|
||||
return -EFAULT;
|
||||
|
||||
if (!odp->is_implicit_odp) {
|
||||
if (unlikely(io_virt < ib_umem_start(odp) ||
|
||||
ib_umem_end(odp) - io_virt < bcnt))
|
||||
u64 user_va;
|
||||
|
||||
if (check_add_overflow(io_virt - mr->mmkey.iova,
|
||||
(u64)odp->umem.address, &user_va))
|
||||
return -EFAULT;
|
||||
return pagefault_real_mr(mr, odp, io_virt, bcnt, bytes_mapped,
|
||||
if (unlikely(user_va >= ib_umem_end(odp) ||
|
||||
ib_umem_end(odp) - user_va < bcnt))
|
||||
return -EFAULT;
|
||||
return pagefault_real_mr(mr, odp, user_va, bcnt, bytes_mapped,
|
||||
flags);
|
||||
}
|
||||
return pagefault_implicit_mr(mr, odp, io_virt, bcnt, bytes_mapped,
|
||||
@@ -1275,15 +1282,15 @@ static void mlx5_ib_mr_wqe_pfault_handler(struct mlx5_ib_dev *dev,
|
||||
wqe = wqe_start;
|
||||
qp = (res->res == MLX5_RES_QP) ? res_to_qp(res) : NULL;
|
||||
if (qp && sq) {
|
||||
ret = mlx5_ib_read_user_wqe_sq(qp, wqe_index, wqe, PAGE_SIZE,
|
||||
&bytes_copied);
|
||||
ret = mlx5_ib_read_wqe_sq(qp, wqe_index, wqe, PAGE_SIZE,
|
||||
&bytes_copied);
|
||||
if (ret)
|
||||
goto read_user;
|
||||
ret = mlx5_ib_mr_initiator_pfault_handler(
|
||||
dev, pfault, qp, &wqe, &wqe_end, bytes_copied);
|
||||
} else if (qp && !sq) {
|
||||
ret = mlx5_ib_read_user_wqe_rq(qp, wqe_index, wqe, PAGE_SIZE,
|
||||
&bytes_copied);
|
||||
ret = mlx5_ib_read_wqe_rq(qp, wqe_index, wqe, PAGE_SIZE,
|
||||
&bytes_copied);
|
||||
if (ret)
|
||||
goto read_user;
|
||||
ret = mlx5_ib_mr_responder_pfault_handler_rq(
|
||||
@@ -1291,8 +1298,8 @@ static void mlx5_ib_mr_wqe_pfault_handler(struct mlx5_ib_dev *dev,
|
||||
} else if (!qp) {
|
||||
struct mlx5_ib_srq *srq = res_to_srq(res);
|
||||
|
||||
ret = mlx5_ib_read_user_wqe_srq(srq, wqe_index, wqe, PAGE_SIZE,
|
||||
&bytes_copied);
|
||||
ret = mlx5_ib_read_wqe_srq(srq, wqe_index, wqe, PAGE_SIZE,
|
||||
&bytes_copied);
|
||||
if (ret)
|
||||
goto read_user;
|
||||
ret = mlx5_ib_mr_responder_pfault_handler_srq(
|
||||
|
Reference in New Issue
Block a user