mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-23 12:10:10 -04:00
RDMA/mlx5: Use ib_umem_get_cq_buf_or_va() for user CQ buffer
Pin the user CQ buffer with ib_umem_get_cq_buf_or_va() and take ownership of the umem in the driver. Apply the same ownership pattern to the resize path. Link: https://patch.msgid.link/r/20260529134312.2836341-9-jiri@resnulli.us Signed-off-by: Jiri Pirko <jiri@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
committed by
Jason Gunthorpe
parent
e3433474db
commit
ffdc91c993
@@ -746,15 +746,15 @@ static int create_cq_user(struct mlx5_ib_dev *dev, struct ib_udata *udata,
|
||||
|
||||
*cqe_size = ucmd.cqe_size;
|
||||
|
||||
if (!cq->ibcq.umem)
|
||||
cq->ibcq.umem = ib_umem_get_va(&dev->ib_dev, ucmd.buf_addr,
|
||||
entries * ucmd.cqe_size,
|
||||
IB_ACCESS_LOCAL_WRITE);
|
||||
if (IS_ERR(cq->ibcq.umem))
|
||||
return PTR_ERR(cq->ibcq.umem);
|
||||
cq->buf.umem = ib_umem_get_cq_buf_or_va(&dev->ib_dev, attrs,
|
||||
ucmd.buf_addr,
|
||||
entries * ucmd.cqe_size,
|
||||
IB_ACCESS_LOCAL_WRITE);
|
||||
if (IS_ERR(cq->buf.umem))
|
||||
return PTR_ERR(cq->buf.umem);
|
||||
|
||||
page_size = mlx5_umem_find_best_cq_quantized_pgoff(
|
||||
cq->ibcq.umem, cqc, log_page_size, MLX5_ADAPTER_PAGE_SHIFT,
|
||||
cq->buf.umem, cqc, log_page_size, MLX5_ADAPTER_PAGE_SHIFT,
|
||||
page_offset, 64, &page_offset_quantized);
|
||||
if (!page_size) {
|
||||
err = -EINVAL;
|
||||
@@ -765,12 +765,12 @@ static int create_cq_user(struct mlx5_ib_dev *dev, struct ib_udata *udata,
|
||||
if (err)
|
||||
goto err_umem;
|
||||
|
||||
ncont = ib_umem_num_dma_blocks(cq->ibcq.umem, page_size);
|
||||
ncont = ib_umem_num_dma_blocks(cq->buf.umem, page_size);
|
||||
mlx5_ib_dbg(
|
||||
dev,
|
||||
"addr 0x%llx, size %u, npages %zu, page_size %lu, ncont %d\n",
|
||||
ucmd.buf_addr, entries * ucmd.cqe_size,
|
||||
ib_umem_num_pages(cq->ibcq.umem), page_size, ncont);
|
||||
ib_umem_num_pages(cq->buf.umem), page_size, ncont);
|
||||
|
||||
*inlen = MLX5_ST_SZ_BYTES(create_cq_in) +
|
||||
MLX5_FLD_SZ_BYTES(create_cq_in, pas[0]) * ncont;
|
||||
@@ -781,7 +781,7 @@ static int create_cq_user(struct mlx5_ib_dev *dev, struct ib_udata *udata,
|
||||
}
|
||||
|
||||
pas = (__be64 *)MLX5_ADDR_OF(create_cq_in, *cqb, pas);
|
||||
mlx5_ib_populate_pas(cq->ibcq.umem, page_size, pas, 0);
|
||||
mlx5_ib_populate_pas(cq->buf.umem, page_size, pas, 0);
|
||||
|
||||
cqc = MLX5_ADDR_OF(create_cq_in, *cqb, cq_context);
|
||||
MLX5_SET(cqc, cqc, log_page_size,
|
||||
@@ -854,7 +854,7 @@ static int create_cq_user(struct mlx5_ib_dev *dev, struct ib_udata *udata,
|
||||
mlx5_ib_db_unmap_user(context, &cq->db);
|
||||
|
||||
err_umem:
|
||||
/* UMEM is released by ib_core */
|
||||
ib_umem_release(cq->buf.umem);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -864,6 +864,7 @@ static void destroy_cq_user(struct mlx5_ib_cq *cq, struct ib_udata *udata)
|
||||
udata, struct mlx5_ib_ucontext, ibucontext);
|
||||
|
||||
mlx5_ib_db_unmap_user(context, &cq->db);
|
||||
ib_umem_release(cq->buf.umem);
|
||||
}
|
||||
|
||||
static void init_cq_frag_buf(struct mlx5_ib_cq_buf *buf)
|
||||
@@ -1436,8 +1437,8 @@ int mlx5_ib_resize_cq(struct ib_cq *ibcq, unsigned int entries,
|
||||
|
||||
if (udata) {
|
||||
cq->ibcq.cqe = entries - 1;
|
||||
ib_umem_release(cq->ibcq.umem);
|
||||
cq->ibcq.umem = cq->resize_umem;
|
||||
ib_umem_release(cq->buf.umem);
|
||||
cq->buf.umem = cq->resize_umem;
|
||||
cq->resize_umem = NULL;
|
||||
} else {
|
||||
struct mlx5_ib_cq_buf tbuf;
|
||||
|
||||
Reference in New Issue
Block a user