mirror of
https://github.com/torvalds/linux.git
synced 2025-11-30 23:16:01 +07:00
IB: Extend UVERBS_METHOD_REG_MR to get DMAH
Extend UVERBS_METHOD_REG_MR to get DMAH and pass it to all drivers. It will be used in mlx5 driver as part of the next patch from the series. Signed-off-by: Yishai Hadas <yishaih@nvidia.com> Reviewed-by: Edward Srouji <edwards@nvidia.com> Link: https://patch.msgid.link/2ae1e628c0675db81f092cc00d3ad6fbf6139405.1752752567.git.leon@kernel.org Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
committed by
Leon Romanovsky
parent
3c81907075
commit
a272019a46
@@ -741,7 +741,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs)
|
||||
}
|
||||
|
||||
mr = pd->device->ops.reg_user_mr(pd, cmd.start, cmd.length, cmd.hca_va,
|
||||
cmd.access_flags,
|
||||
cmd.access_flags, NULL,
|
||||
&attrs->driver_udata);
|
||||
if (IS_ERR(mr)) {
|
||||
ret = PTR_ERR(mr);
|
||||
|
||||
@@ -238,7 +238,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_REG_DMABUF_MR)(
|
||||
return ret;
|
||||
|
||||
mr = pd->device->ops.reg_user_mr_dmabuf(pd, offset, length, iova, fd,
|
||||
access_flags,
|
||||
access_flags, NULL,
|
||||
attrs);
|
||||
if (IS_ERR(mr))
|
||||
return PTR_ERR(mr);
|
||||
@@ -276,6 +276,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_REG_MR)(
|
||||
u32 valid_access_flags = IB_ACCESS_SUPPORTED;
|
||||
u64 length, iova, fd_offset = 0, addr = 0;
|
||||
struct ib_device *ib_dev = pd->device;
|
||||
struct ib_dmah *dmah = NULL;
|
||||
bool has_fd_offset = false;
|
||||
bool has_addr = false;
|
||||
bool has_fd = false;
|
||||
@@ -340,6 +341,13 @@ static int UVERBS_HANDLER(UVERBS_METHOD_REG_MR)(
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (uverbs_attr_is_valid(attrs, UVERBS_ATTR_REG_MR_DMA_HANDLE)) {
|
||||
dmah = uverbs_attr_get_obj(attrs,
|
||||
UVERBS_ATTR_REG_MR_DMA_HANDLE);
|
||||
if (IS_ERR(dmah))
|
||||
return PTR_ERR(dmah);
|
||||
}
|
||||
|
||||
ret = uverbs_get_flags32(&access_flags, attrs,
|
||||
UVERBS_ATTR_REG_MR_ACCESS_FLAGS,
|
||||
valid_access_flags);
|
||||
@@ -351,11 +359,12 @@ static int UVERBS_HANDLER(UVERBS_METHOD_REG_MR)(
|
||||
return ret;
|
||||
|
||||
if (has_fd)
|
||||
mr = pd->device->ops.reg_user_mr_dmabuf(pd, fd_offset, length, iova,
|
||||
fd, access_flags, attrs);
|
||||
mr = pd->device->ops.reg_user_mr_dmabuf(pd, fd_offset, length,
|
||||
iova, fd, access_flags,
|
||||
dmah, attrs);
|
||||
else
|
||||
mr = pd->device->ops.reg_user_mr(pd, addr, length,
|
||||
iova, access_flags, NULL);
|
||||
mr = pd->device->ops.reg_user_mr(pd, addr, length, iova,
|
||||
access_flags, dmah, NULL);
|
||||
|
||||
if (IS_ERR(mr))
|
||||
return PTR_ERR(mr);
|
||||
@@ -365,6 +374,10 @@ static int UVERBS_HANDLER(UVERBS_METHOD_REG_MR)(
|
||||
mr->type = IB_MR_TYPE_USER;
|
||||
mr->uobject = uobj;
|
||||
atomic_inc(&pd->usecnt);
|
||||
if (dmah) {
|
||||
mr->dmah = dmah;
|
||||
atomic_inc(&dmah->usecnt);
|
||||
}
|
||||
rdma_restrack_new(&mr->res, RDMA_RESTRACK_MR);
|
||||
rdma_restrack_set_name(&mr->res, NULL);
|
||||
rdma_restrack_add(&mr->res);
|
||||
@@ -488,6 +501,10 @@ DECLARE_UVERBS_NAMED_METHOD(
|
||||
UVERBS_OBJECT_PD,
|
||||
UVERBS_ACCESS_READ,
|
||||
UA_MANDATORY),
|
||||
UVERBS_ATTR_IDR(UVERBS_ATTR_REG_MR_DMA_HANDLE,
|
||||
UVERBS_OBJECT_DMAH,
|
||||
UVERBS_ACCESS_READ,
|
||||
UA_OPTIONAL),
|
||||
UVERBS_ATTR_PTR_IN(UVERBS_ATTR_REG_MR_IOVA,
|
||||
UVERBS_ATTR_TYPE(u64),
|
||||
UA_MANDATORY),
|
||||
|
||||
@@ -2223,7 +2223,7 @@ struct ib_mr *ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
}
|
||||
|
||||
mr = pd->device->ops.reg_user_mr(pd, start, length, virt_addr,
|
||||
access_flags, NULL);
|
||||
access_flags, NULL, NULL);
|
||||
|
||||
if (IS_ERR(mr))
|
||||
return mr;
|
||||
@@ -2262,6 +2262,7 @@ int ib_dereg_mr_user(struct ib_mr *mr, struct ib_udata *udata)
|
||||
{
|
||||
struct ib_pd *pd = mr->pd;
|
||||
struct ib_dm *dm = mr->dm;
|
||||
struct ib_dmah *dmah = mr->dmah;
|
||||
struct ib_sig_attrs *sig_attrs = mr->sig_attrs;
|
||||
int ret;
|
||||
|
||||
@@ -2272,6 +2273,8 @@ int ib_dereg_mr_user(struct ib_mr *mr, struct ib_udata *udata)
|
||||
atomic_dec(&pd->usecnt);
|
||||
if (dm)
|
||||
atomic_dec(&dm->usecnt);
|
||||
if (dmah)
|
||||
atomic_dec(&dmah->usecnt);
|
||||
kfree(sig_attrs);
|
||||
}
|
||||
|
||||
|
||||
@@ -4235,6 +4235,7 @@ free_mr:
|
||||
|
||||
struct ib_mr *bnxt_re_reg_user_mr(struct ib_pd *ib_pd, u64 start, u64 length,
|
||||
u64 virt_addr, int mr_access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct bnxt_re_pd *pd = container_of(ib_pd, struct bnxt_re_pd, ib_pd);
|
||||
@@ -4242,6 +4243,9 @@ struct ib_mr *bnxt_re_reg_user_mr(struct ib_pd *ib_pd, u64 start, u64 length,
|
||||
struct ib_umem *umem;
|
||||
struct ib_mr *ib_mr;
|
||||
|
||||
if (dmah)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
umem = ib_umem_get(&rdev->ibdev, start, length, mr_access_flags);
|
||||
if (IS_ERR(umem))
|
||||
return ERR_CAST(umem);
|
||||
@@ -4255,6 +4259,7 @@ struct ib_mr *bnxt_re_reg_user_mr(struct ib_pd *ib_pd, u64 start, u64 length,
|
||||
struct ib_mr *bnxt_re_reg_user_mr_dmabuf(struct ib_pd *ib_pd, u64 start,
|
||||
u64 length, u64 virt_addr, int fd,
|
||||
int mr_access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct uverbs_attr_bundle *attrs)
|
||||
{
|
||||
struct bnxt_re_pd *pd = container_of(ib_pd, struct bnxt_re_pd, ib_pd);
|
||||
@@ -4263,6 +4268,9 @@ struct ib_mr *bnxt_re_reg_user_mr_dmabuf(struct ib_pd *ib_pd, u64 start,
|
||||
struct ib_umem *umem;
|
||||
struct ib_mr *ib_mr;
|
||||
|
||||
if (dmah)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
umem_dmabuf = ib_umem_dmabuf_get_pinned(&rdev->ibdev, start, length,
|
||||
fd, mr_access_flags);
|
||||
if (IS_ERR(umem_dmabuf))
|
||||
|
||||
@@ -258,10 +258,12 @@ struct ib_mw *bnxt_re_alloc_mw(struct ib_pd *ib_pd, enum ib_mw_type type,
|
||||
int bnxt_re_dealloc_mw(struct ib_mw *mw);
|
||||
struct ib_mr *bnxt_re_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
u64 virt_addr, int mr_access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata);
|
||||
struct ib_mr *bnxt_re_reg_user_mr_dmabuf(struct ib_pd *ib_pd, u64 start,
|
||||
u64 length, u64 virt_addr,
|
||||
int fd, int mr_access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct uverbs_attr_bundle *attrs);
|
||||
int bnxt_re_alloc_ucontext(struct ib_ucontext *ctx, struct ib_udata *udata);
|
||||
void bnxt_re_dealloc_ucontext(struct ib_ucontext *context);
|
||||
|
||||
@@ -1006,6 +1006,7 @@ int c4iw_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
|
||||
void c4iw_dealloc(struct uld_ctx *ctx);
|
||||
struct ib_mr *c4iw_reg_user_mr(struct ib_pd *pd, u64 start,
|
||||
u64 length, u64 virt, int acc,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata);
|
||||
struct ib_mr *c4iw_get_dma_mr(struct ib_pd *pd, int acc);
|
||||
int c4iw_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata);
|
||||
|
||||
@@ -489,7 +489,8 @@ err_free_mhp:
|
||||
}
|
||||
|
||||
struct ib_mr *c4iw_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
u64 virt, int acc, struct ib_udata *udata)
|
||||
u64 virt, int acc, struct ib_dmah *dmah,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
__be64 *pages;
|
||||
int shift, n, i;
|
||||
@@ -501,6 +502,9 @@ struct ib_mr *c4iw_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
|
||||
pr_debug("ib_pd %p\n", pd);
|
||||
|
||||
if (dmah)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
if (length == ~0ULL)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
|
||||
@@ -167,10 +167,12 @@ int efa_create_cq_umem(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
|
||||
struct ib_umem *umem, struct uverbs_attr_bundle *attrs);
|
||||
struct ib_mr *efa_reg_mr(struct ib_pd *ibpd, u64 start, u64 length,
|
||||
u64 virt_addr, int access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata);
|
||||
struct ib_mr *efa_reg_user_mr_dmabuf(struct ib_pd *ibpd, u64 start,
|
||||
u64 length, u64 virt_addr,
|
||||
int fd, int access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct uverbs_attr_bundle *attrs);
|
||||
int efa_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata);
|
||||
int efa_get_port_immutable(struct ib_device *ibdev, u32 port_num,
|
||||
|
||||
@@ -1765,6 +1765,7 @@ static int efa_register_mr(struct ib_pd *ibpd, struct efa_mr *mr, u64 start,
|
||||
struct ib_mr *efa_reg_user_mr_dmabuf(struct ib_pd *ibpd, u64 start,
|
||||
u64 length, u64 virt_addr,
|
||||
int fd, int access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct uverbs_attr_bundle *attrs)
|
||||
{
|
||||
struct efa_dev *dev = to_edev(ibpd->device);
|
||||
@@ -1772,6 +1773,11 @@ struct ib_mr *efa_reg_user_mr_dmabuf(struct ib_pd *ibpd, u64 start,
|
||||
struct efa_mr *mr;
|
||||
int err;
|
||||
|
||||
if (dmah) {
|
||||
err = -EOPNOTSUPP;
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
mr = efa_alloc_mr(ibpd, access_flags, &attrs->driver_udata);
|
||||
if (IS_ERR(mr)) {
|
||||
err = PTR_ERR(mr);
|
||||
@@ -1804,12 +1810,18 @@ err_out:
|
||||
|
||||
struct ib_mr *efa_reg_mr(struct ib_pd *ibpd, u64 start, u64 length,
|
||||
u64 virt_addr, int access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct efa_dev *dev = to_edev(ibpd->device);
|
||||
struct efa_mr *mr;
|
||||
int err;
|
||||
|
||||
if (dmah) {
|
||||
err = -EOPNOTSUPP;
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
mr = efa_alloc_mr(ibpd, access_flags, udata);
|
||||
if (IS_ERR(mr)) {
|
||||
err = PTR_ERR(mr);
|
||||
|
||||
@@ -1200,13 +1200,17 @@ int erdma_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
|
||||
}
|
||||
|
||||
struct ib_mr *erdma_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 len,
|
||||
u64 virt, int access, struct ib_udata *udata)
|
||||
u64 virt, int access, struct ib_dmah *dmah,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct erdma_mr *mr = NULL;
|
||||
struct erdma_dev *dev = to_edev(ibpd->device);
|
||||
u32 stag;
|
||||
int ret;
|
||||
|
||||
if (dmah)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
if (!len || len > dev->attrs.max_mr_size)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
|
||||
@@ -452,7 +452,8 @@ int erdma_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata);
|
||||
void erdma_disassociate_ucontext(struct ib_ucontext *ibcontext);
|
||||
int erdma_req_notify_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags);
|
||||
struct ib_mr *erdma_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 len,
|
||||
u64 virt, int access, struct ib_udata *udata);
|
||||
u64 virt, int access, struct ib_dmah *dmah,
|
||||
struct ib_udata *udata);
|
||||
struct ib_mr *erdma_get_dma_mr(struct ib_pd *ibpd, int rights);
|
||||
int erdma_dereg_mr(struct ib_mr *ibmr, struct ib_udata *data);
|
||||
int erdma_mmap(struct ib_ucontext *ctx, struct vm_area_struct *vma);
|
||||
|
||||
@@ -1219,6 +1219,7 @@ int hns_roce_dealloc_pd(struct ib_pd *pd, struct ib_udata *udata);
|
||||
struct ib_mr *hns_roce_get_dma_mr(struct ib_pd *pd, int acc);
|
||||
struct ib_mr *hns_roce_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
u64 virt_addr, int access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata);
|
||||
struct ib_mr *hns_roce_rereg_user_mr(struct ib_mr *mr, int flags, u64 start,
|
||||
u64 length, u64 virt_addr,
|
||||
|
||||
@@ -231,12 +231,18 @@ err_free:
|
||||
|
||||
struct ib_mr *hns_roce_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
u64 virt_addr, int access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct hns_roce_dev *hr_dev = to_hr_dev(pd->device);
|
||||
struct hns_roce_mr *mr;
|
||||
int ret;
|
||||
|
||||
if (dmah) {
|
||||
ret = -EOPNOTSUPP;
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
mr = kzalloc(sizeof(*mr), GFP_KERNEL);
|
||||
if (!mr) {
|
||||
ret = -ENOMEM;
|
||||
|
||||
@@ -3013,10 +3013,12 @@ static int irdma_reg_user_mr_type_cq(struct irdma_mem_reg_req req,
|
||||
* @len: length of mr
|
||||
* @virt: virtual address
|
||||
* @access: access of mr
|
||||
* @dmah: dma handle
|
||||
* @udata: user data
|
||||
*/
|
||||
static struct ib_mr *irdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 len,
|
||||
u64 virt, int access,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
#define IRDMA_MEM_REG_MIN_REQ_LEN offsetofend(struct irdma_mem_reg_req, sq_pages)
|
||||
@@ -3026,6 +3028,9 @@ static struct ib_mr *irdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 len,
|
||||
struct irdma_mr *iwmr = NULL;
|
||||
int err;
|
||||
|
||||
if (dmah)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
if (len > iwdev->rf->sc_dev.hw_attrs.max_mr_size)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
@@ -3085,6 +3090,7 @@ error:
|
||||
static struct ib_mr *irdma_reg_user_mr_dmabuf(struct ib_pd *pd, u64 start,
|
||||
u64 len, u64 virt,
|
||||
int fd, int access,
|
||||
struct ib_dmah *dmah,
|
||||
struct uverbs_attr_bundle *attrs)
|
||||
{
|
||||
struct irdma_device *iwdev = to_iwdev(pd->device);
|
||||
@@ -3092,6 +3098,9 @@ static struct ib_mr *irdma_reg_user_mr_dmabuf(struct ib_pd *pd, u64 start,
|
||||
struct irdma_mr *iwmr;
|
||||
int err;
|
||||
|
||||
if (dmah)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
if (len > iwdev->rf->sc_dev.hw_attrs.max_mr_size)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
|
||||
@@ -632,6 +632,7 @@ struct ib_mr *mana_ib_get_dma_mr(struct ib_pd *ibpd, int access_flags);
|
||||
|
||||
struct ib_mr *mana_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
u64 iova, int access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata);
|
||||
|
||||
int mana_ib_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata);
|
||||
@@ -721,5 +722,6 @@ int mana_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags);
|
||||
|
||||
struct ib_mr *mana_ib_reg_user_mr_dmabuf(struct ib_pd *ibpd, u64 start, u64 length,
|
||||
u64 iova, int fd, int mr_access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct uverbs_attr_bundle *attrs);
|
||||
#endif
|
||||
|
||||
@@ -106,6 +106,7 @@ static int mana_ib_gd_destroy_mr(struct mana_ib_dev *dev, u64 mr_handle)
|
||||
|
||||
struct ib_mr *mana_ib_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 length,
|
||||
u64 iova, int access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct mana_ib_pd *pd = container_of(ibpd, struct mana_ib_pd, ibpd);
|
||||
@@ -116,6 +117,9 @@ struct ib_mr *mana_ib_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 length,
|
||||
u64 dma_region_handle;
|
||||
int err;
|
||||
|
||||
if (dmah)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
dev = container_of(ibdev, struct mana_ib_dev, ib_dev);
|
||||
|
||||
ibdev_dbg(ibdev,
|
||||
@@ -188,6 +192,7 @@ err_free:
|
||||
|
||||
struct ib_mr *mana_ib_reg_user_mr_dmabuf(struct ib_pd *ibpd, u64 start, u64 length,
|
||||
u64 iova, int fd, int access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct uverbs_attr_bundle *attrs)
|
||||
{
|
||||
struct mana_ib_pd *pd = container_of(ibpd, struct mana_ib_pd, ibpd);
|
||||
@@ -199,6 +204,9 @@ struct ib_mr *mana_ib_reg_user_mr_dmabuf(struct ib_pd *ibpd, u64 start, u64 leng
|
||||
u64 dma_region_handle;
|
||||
int err;
|
||||
|
||||
if (dmah)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
dev = container_of(ibdev, struct mana_ib_dev, ib_dev);
|
||||
|
||||
access_flags &= ~IB_ACCESS_OPTIONAL;
|
||||
|
||||
@@ -759,6 +759,7 @@ int mlx4_ib_umem_write_mtt(struct mlx4_ib_dev *dev, struct mlx4_mtt *mtt,
|
||||
struct ib_umem *umem);
|
||||
struct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
u64 virt_addr, int access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata);
|
||||
int mlx4_ib_dereg_mr(struct ib_mr *mr, struct ib_udata *udata);
|
||||
int mlx4_ib_alloc_mw(struct ib_mw *mw, struct ib_udata *udata);
|
||||
|
||||
@@ -139,6 +139,7 @@ static struct ib_umem *mlx4_get_umem_mr(struct ib_device *device, u64 start,
|
||||
|
||||
struct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
u64 virt_addr, int access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct mlx4_ib_dev *dev = to_mdev(pd->device);
|
||||
@@ -147,6 +148,9 @@ struct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
int err;
|
||||
int n;
|
||||
|
||||
if (dmah)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
mr = kzalloc(sizeof(*mr), GFP_KERNEL);
|
||||
if (!mr)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
@@ -1370,10 +1370,12 @@ int mlx5_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata);
|
||||
struct ib_mr *mlx5_ib_get_dma_mr(struct ib_pd *pd, int acc);
|
||||
struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
u64 virt_addr, int access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata);
|
||||
struct ib_mr *mlx5_ib_reg_user_mr_dmabuf(struct ib_pd *pd, u64 start,
|
||||
u64 length, u64 virt_addr,
|
||||
int fd, int access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct uverbs_attr_bundle *attrs);
|
||||
int mlx5_ib_advise_mr(struct ib_pd *pd,
|
||||
enum ib_uverbs_advise_mr_advice advice,
|
||||
|
||||
@@ -1529,13 +1529,14 @@ err_dereg_mr:
|
||||
|
||||
struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
u64 iova, int access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct mlx5_ib_dev *dev = to_mdev(pd->device);
|
||||
struct ib_umem *umem;
|
||||
int err;
|
||||
|
||||
if (!IS_ENABLED(CONFIG_INFINIBAND_USER_MEM))
|
||||
if (!IS_ENABLED(CONFIG_INFINIBAND_USER_MEM) || dmah)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
mlx5_ib_dbg(dev, "start 0x%llx, iova 0x%llx, length 0x%llx, access_flags 0x%x\n",
|
||||
@@ -1689,6 +1690,7 @@ end:
|
||||
struct ib_mr *mlx5_ib_reg_user_mr_dmabuf(struct ib_pd *pd, u64 offset,
|
||||
u64 length, u64 virt_addr,
|
||||
int fd, int access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct uverbs_attr_bundle *attrs)
|
||||
{
|
||||
struct mlx5_ib_dev *dev = to_mdev(pd->device);
|
||||
@@ -1696,7 +1698,7 @@ struct ib_mr *mlx5_ib_reg_user_mr_dmabuf(struct ib_pd *pd, u64 offset,
|
||||
int err;
|
||||
|
||||
if (!IS_ENABLED(CONFIG_INFINIBAND_USER_MEM) ||
|
||||
!IS_ENABLED(CONFIG_INFINIBAND_ON_DEMAND_PAGING))
|
||||
!IS_ENABLED(CONFIG_INFINIBAND_ON_DEMAND_PAGING) || dmah)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
if (uverbs_attr_is_valid(attrs, MLX5_IB_ATTR_REG_DMABUF_MR_ACCESS_FLAGS)) {
|
||||
@@ -1903,7 +1905,7 @@ struct ib_mr *mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,
|
||||
*/
|
||||
recreate:
|
||||
return mlx5_ib_reg_user_mr(new_pd, start, length, iova,
|
||||
new_access_flags, udata);
|
||||
new_access_flags, NULL, udata);
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -825,7 +825,8 @@ static struct ib_mr *mthca_get_dma_mr(struct ib_pd *pd, int acc)
|
||||
}
|
||||
|
||||
static struct ib_mr *mthca_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
u64 virt, int acc, struct ib_udata *udata)
|
||||
u64 virt, int acc, struct ib_dmah *dmah,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct mthca_dev *dev = to_mdev(pd->device);
|
||||
struct ib_block_iter biter;
|
||||
@@ -838,6 +839,9 @@ static struct ib_mr *mthca_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
int err = 0;
|
||||
int write_mtt_size;
|
||||
|
||||
if (dmah)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
if (udata->inlen < sizeof ucmd) {
|
||||
if (!context->reg_mr_warned) {
|
||||
mthca_warn(dev, "Process '%s' did not pass in MR attrs.\n",
|
||||
|
||||
@@ -847,13 +847,17 @@ static void build_user_pbes(struct ocrdma_dev *dev, struct ocrdma_mr *mr)
|
||||
}
|
||||
|
||||
struct ib_mr *ocrdma_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 len,
|
||||
u64 usr_addr, int acc, struct ib_udata *udata)
|
||||
u64 usr_addr, int acc, struct ib_dmah *dmah,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
int status = -ENOMEM;
|
||||
struct ocrdma_dev *dev = get_ocrdma_dev(ibpd->device);
|
||||
struct ocrdma_mr *mr;
|
||||
struct ocrdma_pd *pd;
|
||||
|
||||
if (dmah)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
pd = get_ocrdma_pd(ibpd);
|
||||
|
||||
if (acc & IB_ACCESS_REMOTE_WRITE && !(acc & IB_ACCESS_LOCAL_WRITE))
|
||||
|
||||
@@ -98,7 +98,8 @@ int ocrdma_post_srq_recv(struct ib_srq *, const struct ib_recv_wr *,
|
||||
int ocrdma_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata);
|
||||
struct ib_mr *ocrdma_get_dma_mr(struct ib_pd *, int acc);
|
||||
struct ib_mr *ocrdma_reg_user_mr(struct ib_pd *, u64 start, u64 length,
|
||||
u64 virt, int acc, struct ib_udata *);
|
||||
u64 virt, int acc, struct ib_dmah *dmah,
|
||||
struct ib_udata *);
|
||||
struct ib_mr *ocrdma_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
|
||||
u32 max_num_sg);
|
||||
int ocrdma_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
|
||||
|
||||
@@ -2953,13 +2953,17 @@ done:
|
||||
}
|
||||
|
||||
struct ib_mr *qedr_reg_user_mr(struct ib_pd *ibpd, u64 start, u64 len,
|
||||
u64 usr_addr, int acc, struct ib_udata *udata)
|
||||
u64 usr_addr, int acc, struct ib_dmah *dmah,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct qedr_dev *dev = get_qedr_dev(ibpd->device);
|
||||
struct qedr_mr *mr;
|
||||
struct qedr_pd *pd;
|
||||
int rc = -ENOMEM;
|
||||
|
||||
if (dmah)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
pd = get_qedr_pd(ibpd);
|
||||
DP_DEBUG(dev, QEDR_MSG_MR,
|
||||
"qedr_register user mr pd = %d start = %lld, len = %lld, usr_addr = %lld, acc = %d\n",
|
||||
|
||||
@@ -79,7 +79,8 @@ int qedr_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata);
|
||||
struct ib_mr *qedr_get_dma_mr(struct ib_pd *, int acc);
|
||||
|
||||
struct ib_mr *qedr_reg_user_mr(struct ib_pd *, u64 start, u64 length,
|
||||
u64 virt, int acc, struct ib_udata *);
|
||||
u64 virt, int acc, struct ib_dmah *dmah,
|
||||
struct ib_udata *);
|
||||
|
||||
int qedr_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg,
|
||||
int sg_nents, unsigned int *sg_offset);
|
||||
|
||||
@@ -592,6 +592,7 @@ int usnic_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata)
|
||||
|
||||
struct ib_mr *usnic_ib_reg_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
u64 virt_addr, int access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct usnic_ib_mr *mr;
|
||||
@@ -600,6 +601,9 @@ struct ib_mr *usnic_ib_reg_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
usnic_dbg("start 0x%llx va 0x%llx length 0x%llx\n", start,
|
||||
virt_addr, length);
|
||||
|
||||
if (dmah)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
mr = kzalloc(sizeof(*mr), GFP_KERNEL);
|
||||
if (!mr)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
@@ -60,6 +60,7 @@ int usnic_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
|
||||
int usnic_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata);
|
||||
struct ib_mr *usnic_ib_reg_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
u64 virt_addr, int access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata);
|
||||
int usnic_ib_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata);
|
||||
int usnic_ib_alloc_ucontext(struct ib_ucontext *uctx, struct ib_udata *udata);
|
||||
|
||||
@@ -104,12 +104,14 @@ struct ib_mr *pvrdma_get_dma_mr(struct ib_pd *pd, int acc)
|
||||
* @length: length of region
|
||||
* @virt_addr: I/O virtual address
|
||||
* @access_flags: access flags for memory region
|
||||
* @dmah: dma handle
|
||||
* @udata: user data
|
||||
*
|
||||
* @return: ib_mr pointer on success, otherwise returns an errno.
|
||||
*/
|
||||
struct ib_mr *pvrdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
u64 virt_addr, int access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct pvrdma_dev *dev = to_vdev(pd->device);
|
||||
@@ -121,6 +123,9 @@ struct ib_mr *pvrdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
struct pvrdma_cmd_create_mr_resp *resp = &rsp.create_mr_resp;
|
||||
int ret, npages;
|
||||
|
||||
if (dmah)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
if (length == 0 || length > dev->dsr->caps.max_mr_size) {
|
||||
dev_warn(&dev->pdev->dev, "invalid mem region length\n");
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
@@ -366,6 +366,7 @@ int pvrdma_dealloc_pd(struct ib_pd *ibpd, struct ib_udata *udata);
|
||||
struct ib_mr *pvrdma_get_dma_mr(struct ib_pd *pd, int acc);
|
||||
struct ib_mr *pvrdma_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
u64 virt_addr, int access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata);
|
||||
int pvrdma_dereg_mr(struct ib_mr *mr, struct ib_udata *udata);
|
||||
struct ib_mr *pvrdma_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
|
||||
|
||||
@@ -329,12 +329,14 @@ bail:
|
||||
* @length: length of region to register
|
||||
* @virt_addr: associated virtual address
|
||||
* @mr_access_flags: access flags for this memory region
|
||||
* @dmah: dma handle
|
||||
* @udata: unused by the driver
|
||||
*
|
||||
* Return: the memory region on success, otherwise returns an errno.
|
||||
*/
|
||||
struct ib_mr *rvt_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
u64 virt_addr, int mr_access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct rvt_mr *mr;
|
||||
@@ -343,6 +345,9 @@ struct ib_mr *rvt_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
int n, m;
|
||||
struct ib_mr *ret;
|
||||
|
||||
if (dmah)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
if (length == 0)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ void rvt_mr_exit(struct rvt_dev_info *rdi);
|
||||
struct ib_mr *rvt_get_dma_mr(struct ib_pd *pd, int acc);
|
||||
struct ib_mr *rvt_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
u64 virt_addr, int mr_access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata);
|
||||
int rvt_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata);
|
||||
struct ib_mr *rvt_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
|
||||
|
||||
@@ -1271,6 +1271,7 @@ err_free:
|
||||
|
||||
static struct ib_mr *rxe_reg_user_mr(struct ib_pd *ibpd, u64 start,
|
||||
u64 length, u64 iova, int access,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct rxe_dev *rxe = to_rdev(ibpd->device);
|
||||
@@ -1278,6 +1279,9 @@ static struct ib_mr *rxe_reg_user_mr(struct ib_pd *ibpd, u64 start,
|
||||
struct rxe_mr *mr;
|
||||
int err, cleanup_err;
|
||||
|
||||
if (dmah)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
if (access & ~RXE_ACCESS_SUPPORTED_MR) {
|
||||
rxe_err_pd(pd, "access = %#x not supported (%#x)\n", access,
|
||||
RXE_ACCESS_SUPPORTED_MR);
|
||||
|
||||
@@ -1321,10 +1321,12 @@ int siw_dereg_mr(struct ib_mr *base_mr, struct ib_udata *udata)
|
||||
* @len: len of MR
|
||||
* @rnic_va: not used by siw
|
||||
* @rights: MR access rights
|
||||
* @dmah: dma handle
|
||||
* @udata: user buffer to communicate STag and Key.
|
||||
*/
|
||||
struct ib_mr *siw_reg_user_mr(struct ib_pd *pd, u64 start, u64 len,
|
||||
u64 rnic_va, int rights, struct ib_udata *udata)
|
||||
u64 rnic_va, int rights, struct ib_dmah *dmah,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct siw_mr *mr = NULL;
|
||||
struct siw_umem *umem = NULL;
|
||||
@@ -1336,6 +1338,9 @@ struct ib_mr *siw_reg_user_mr(struct ib_pd *pd, u64 start, u64 len,
|
||||
(void *)(uintptr_t)start, (void *)(uintptr_t)rnic_va,
|
||||
(unsigned long long)len);
|
||||
|
||||
if (dmah)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
if (atomic_inc_return(&sdev->num_mr) > SIW_MAX_MR) {
|
||||
siw_dbg_pd(pd, "too many mr's\n");
|
||||
rv = -ENOMEM;
|
||||
|
||||
@@ -65,7 +65,8 @@ int siw_destroy_cq(struct ib_cq *base_cq, struct ib_udata *udata);
|
||||
int siw_poll_cq(struct ib_cq *base_cq, int num_entries, struct ib_wc *wc);
|
||||
int siw_req_notify_cq(struct ib_cq *base_cq, enum ib_cq_notify_flags flags);
|
||||
struct ib_mr *siw_reg_user_mr(struct ib_pd *base_pd, u64 start, u64 len,
|
||||
u64 rnic_va, int rights, struct ib_udata *udata);
|
||||
u64 rnic_va, int rights, struct ib_dmah *dmah,
|
||||
struct ib_udata *udata);
|
||||
struct ib_mr *siw_alloc_mr(struct ib_pd *base_pd, enum ib_mr_type mr_type,
|
||||
u32 max_sge);
|
||||
struct ib_mr *siw_get_dma_mr(struct ib_pd *base_pd, int rights);
|
||||
|
||||
@@ -1885,6 +1885,7 @@ struct ib_mr {
|
||||
|
||||
struct ib_dm *dm;
|
||||
struct ib_sig_attrs *sig_attrs; /* only for IB_MR_TYPE_INTEGRITY MRs */
|
||||
struct ib_dmah *dmah;
|
||||
/*
|
||||
* Implementation details of the RDMA core, don't use in drivers:
|
||||
*/
|
||||
@@ -2527,10 +2528,12 @@ struct ib_device_ops {
|
||||
struct ib_mr *(*get_dma_mr)(struct ib_pd *pd, int mr_access_flags);
|
||||
struct ib_mr *(*reg_user_mr)(struct ib_pd *pd, u64 start, u64 length,
|
||||
u64 virt_addr, int mr_access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct ib_udata *udata);
|
||||
struct ib_mr *(*reg_user_mr_dmabuf)(struct ib_pd *pd, u64 offset,
|
||||
u64 length, u64 virt_addr, int fd,
|
||||
int mr_access_flags,
|
||||
struct ib_dmah *dmah,
|
||||
struct uverbs_attr_bundle *attrs);
|
||||
struct ib_mr *(*rereg_user_mr)(struct ib_mr *mr, int flags, u64 start,
|
||||
u64 length, u64 virt_addr,
|
||||
|
||||
@@ -311,6 +311,7 @@ enum uverbs_attrs_reg_dmabuf_mr_cmd_attr_ids {
|
||||
enum uverbs_attrs_reg_mr_cmd_attr_ids {
|
||||
UVERBS_ATTR_REG_MR_HANDLE,
|
||||
UVERBS_ATTR_REG_MR_PD_HANDLE,
|
||||
UVERBS_ATTR_REG_MR_DMA_HANDLE,
|
||||
UVERBS_ATTR_REG_MR_IOVA,
|
||||
UVERBS_ATTR_REG_MR_ADDR,
|
||||
UVERBS_ATTR_REG_MR_LENGTH,
|
||||
|
||||
Reference in New Issue
Block a user