mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 18:21:24 +02:00
IB/mlx5: Push pdn above pagefault_dmabuf_mr()
Remove the mlx5_mr_pdn() inside pagefault_dmabuf_mr(), the only user of the pdn is the init path which is inside an ioctl. Link: https://patch.msgid.link/r/10-v1-29ebd2c229b5+fd5-ib_mr_pd_jgg@nvidia.com Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
parent
62731d26bd
commit
c9bf47d205
|
|
@ -1213,11 +1213,6 @@ static inline struct mlx5_ib_pd *to_mpd(struct ib_pd *ibpd)
|
|||
return container_of(ibpd, struct mlx5_ib_pd, ibpd);
|
||||
}
|
||||
|
||||
static inline u32 mlx5_mr_pdn(struct mlx5_ib_mr *mr)
|
||||
{
|
||||
return to_mpd(mr->ibmr.pd)->pdn;
|
||||
}
|
||||
|
||||
static inline struct mlx5_ib_srq *to_msrq(struct ib_srq *ibsrq)
|
||||
{
|
||||
return container_of(ibsrq, struct mlx5_ib_srq, ibsrq);
|
||||
|
|
@ -1424,7 +1419,7 @@ int mlx5_ib_advise_mr_prefetch(struct ib_pd *pd,
|
|||
enum ib_uverbs_advise_mr_advice advice,
|
||||
u32 flags, struct ib_sge *sg_list, u32 num_sge);
|
||||
int mlx5_ib_init_odp_mr(struct mlx5_ib_mr *mr, struct ib_pd *pd);
|
||||
int mlx5_ib_init_dmabuf_mr(struct mlx5_ib_mr *mr);
|
||||
int mlx5_ib_init_dmabuf_mr(struct mlx5_ib_mr *mr, struct ib_pd *pd);
|
||||
#else /* CONFIG_INFINIBAND_ON_DEMAND_PAGING */
|
||||
static inline int mlx5_ib_odp_init_one(struct mlx5_ib_dev *ibdev) { return 0; }
|
||||
static inline int mlx5r_odp_create_eq(struct mlx5_ib_dev *dev,
|
||||
|
|
@ -1456,7 +1451,7 @@ static inline int mlx5_ib_init_odp_mr(struct mlx5_ib_mr *mr, struct ib_pd *pd)
|
|||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
static inline int mlx5_ib_init_dmabuf_mr(struct mlx5_ib_mr *mr)
|
||||
static inline int mlx5_ib_init_dmabuf_mr(struct mlx5_ib_mr *mr, struct ib_pd *pd)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -969,7 +969,7 @@ reg_user_mr_dmabuf(struct ib_pd *pd, struct device *dma_device,
|
|||
mr->data_direct = true;
|
||||
}
|
||||
|
||||
err = mlx5_ib_init_dmabuf_mr(mr);
|
||||
err = mlx5_ib_init_dmabuf_mr(mr, pd);
|
||||
if (err)
|
||||
goto err_dereg_mr;
|
||||
return &mr->ibmr;
|
||||
|
|
|
|||
|
|
@ -836,17 +836,15 @@ static int pagefault_implicit_mr(struct mlx5_ib_mr *imr,
|
|||
}
|
||||
|
||||
static int pagefault_dmabuf_mr(struct mlx5_ib_mr *mr, size_t bcnt,
|
||||
u32 *bytes_mapped, u32 flags)
|
||||
u32 *bytes_mapped, u32 flags, u32 pdn)
|
||||
{
|
||||
struct ib_umem_dmabuf *umem_dmabuf = to_ib_umem_dmabuf(mr->umem);
|
||||
struct mlx5_ib_dev *dev = mr_to_mdev(mr);
|
||||
int access_mode = mr->data_direct ? MLX5_MKC_ACCESS_MODE_KSM :
|
||||
MLX5_MKC_ACCESS_MODE_MTT;
|
||||
unsigned int old_page_shift = mr->page_shift;
|
||||
unsigned int page_shift;
|
||||
unsigned long page_size;
|
||||
u32 xlt_flags = 0;
|
||||
u32 pdn = 0;
|
||||
int err;
|
||||
|
||||
if (flags & MLX5_PF_FLAGS_ENABLE)
|
||||
|
|
@ -865,10 +863,6 @@ static int pagefault_dmabuf_mr(struct mlx5_ib_mr *mr, size_t bcnt,
|
|||
err = -EINVAL;
|
||||
} else {
|
||||
page_shift = order_base_2(page_size);
|
||||
if (mr->data_direct)
|
||||
pdn = dev->ddr.pdn;
|
||||
else
|
||||
pdn = mlx5_mr_pdn(mr);
|
||||
if (page_shift != mr->page_shift && mr->dmabuf_faulted) {
|
||||
err = mlx5r_umr_dmabuf_update_pgsz(mr, xlt_flags, pdn,
|
||||
page_shift);
|
||||
|
|
@ -915,7 +909,7 @@ static int pagefault_mr(struct mlx5_ib_mr *mr, u64 io_virt, size_t bcnt,
|
|||
return -EFAULT;
|
||||
|
||||
if (mr->umem->is_dmabuf)
|
||||
return pagefault_dmabuf_mr(mr, bcnt, bytes_mapped, flags);
|
||||
return pagefault_dmabuf_mr(mr, bcnt, bytes_mapped, flags, 0);
|
||||
|
||||
if (!odp->is_implicit_odp) {
|
||||
u64 offset = io_virt < mr->ibmr.iova ? 0 : io_virt - mr->ibmr.iova;
|
||||
|
|
@ -951,12 +945,19 @@ int mlx5_ib_init_odp_mr(struct mlx5_ib_mr *mr, struct ib_pd *pd)
|
|||
return ret >= 0 ? 0 : ret;
|
||||
}
|
||||
|
||||
int mlx5_ib_init_dmabuf_mr(struct mlx5_ib_mr *mr)
|
||||
int mlx5_ib_init_dmabuf_mr(struct mlx5_ib_mr *mr, struct ib_pd *pd)
|
||||
{
|
||||
struct mlx5_ib_dev *dev = mr_to_mdev(mr);
|
||||
u32 pdn;
|
||||
int ret;
|
||||
|
||||
if (mr->data_direct)
|
||||
pdn = dev->ddr.pdn;
|
||||
else
|
||||
pdn = to_mpd(pd)->pdn;
|
||||
|
||||
ret = pagefault_dmabuf_mr(mr, mr->umem->length, NULL,
|
||||
MLX5_PF_FLAGS_ENABLE);
|
||||
MLX5_PF_FLAGS_ENABLE, pdn);
|
||||
|
||||
return ret >= 0 ? 0 : ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user