mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-12 21:44:06 +08:00
IB/mlx5: Move to fully dynamic UAR mode once user space supports it
Move to fully dynamic UAR mode once user space supports it. In this case we prevent any legacy mode of UARs on the allocated context and prevent redundant allocation of the static ones. Link: https://lore.kernel.org/r/20200324060143.1569116-6-leon@kernel.org Signed-off-by: Yishai Hadas <yishaih@mellanox.com> Reviewed-by: Michael Guralnik <michaelgur@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
parent
2152862298
commit
0a2fd01c28
@ -741,10 +741,14 @@ static int create_cq_user(struct mlx5_ib_dev *dev, struct ib_udata *udata,
|
|||||||
MLX5_SET(cqc, cqc, log_page_size,
|
MLX5_SET(cqc, cqc, log_page_size,
|
||||||
page_shift - MLX5_ADAPTER_PAGE_SHIFT);
|
page_shift - MLX5_ADAPTER_PAGE_SHIFT);
|
||||||
|
|
||||||
if (ucmd.flags & MLX5_IB_CREATE_CQ_FLAGS_UAR_PAGE_INDEX)
|
if (ucmd.flags & MLX5_IB_CREATE_CQ_FLAGS_UAR_PAGE_INDEX) {
|
||||||
*index = ucmd.uar_page_index;
|
*index = ucmd.uar_page_index;
|
||||||
else
|
} else if (context->bfregi.lib_uar_dyn) {
|
||||||
|
err = -EINVAL;
|
||||||
|
goto err_cqb;
|
||||||
|
} else {
|
||||||
*index = context->bfregi.sys_pages[0];
|
*index = context->bfregi.sys_pages[0];
|
||||||
|
}
|
||||||
|
|
||||||
if (ucmd.cqe_comp_en == 1) {
|
if (ucmd.cqe_comp_en == 1) {
|
||||||
int mini_cqe_format;
|
int mini_cqe_format;
|
||||||
|
@ -1786,6 +1786,7 @@ static int mlx5_ib_alloc_ucontext(struct ib_ucontext *uctx,
|
|||||||
max_cqe_version);
|
max_cqe_version);
|
||||||
u32 dump_fill_mkey;
|
u32 dump_fill_mkey;
|
||||||
bool lib_uar_4k;
|
bool lib_uar_4k;
|
||||||
|
bool lib_uar_dyn;
|
||||||
|
|
||||||
if (!dev->ib_active)
|
if (!dev->ib_active)
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
@ -1844,8 +1845,14 @@ static int mlx5_ib_alloc_ucontext(struct ib_ucontext *uctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
lib_uar_4k = req.lib_caps & MLX5_LIB_CAP_4K_UAR;
|
lib_uar_4k = req.lib_caps & MLX5_LIB_CAP_4K_UAR;
|
||||||
|
lib_uar_dyn = req.lib_caps & MLX5_LIB_CAP_DYN_UAR;
|
||||||
bfregi = &context->bfregi;
|
bfregi = &context->bfregi;
|
||||||
|
|
||||||
|
if (lib_uar_dyn) {
|
||||||
|
bfregi->lib_uar_dyn = lib_uar_dyn;
|
||||||
|
goto uar_done;
|
||||||
|
}
|
||||||
|
|
||||||
/* updates req->total_num_bfregs */
|
/* updates req->total_num_bfregs */
|
||||||
err = calc_total_bfregs(dev, lib_uar_4k, &req, bfregi);
|
err = calc_total_bfregs(dev, lib_uar_4k, &req, bfregi);
|
||||||
if (err)
|
if (err)
|
||||||
@ -1872,6 +1879,7 @@ static int mlx5_ib_alloc_ucontext(struct ib_ucontext *uctx,
|
|||||||
if (err)
|
if (err)
|
||||||
goto out_sys_pages;
|
goto out_sys_pages;
|
||||||
|
|
||||||
|
uar_done:
|
||||||
if (req.flags & MLX5_IB_ALLOC_UCTX_DEVX) {
|
if (req.flags & MLX5_IB_ALLOC_UCTX_DEVX) {
|
||||||
err = mlx5_ib_devx_create(dev, true);
|
err = mlx5_ib_devx_create(dev, true);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
@ -1893,7 +1901,7 @@ static int mlx5_ib_alloc_ucontext(struct ib_ucontext *uctx,
|
|||||||
INIT_LIST_HEAD(&context->db_page_list);
|
INIT_LIST_HEAD(&context->db_page_list);
|
||||||
mutex_init(&context->db_page_mutex);
|
mutex_init(&context->db_page_mutex);
|
||||||
|
|
||||||
resp.tot_bfregs = req.total_num_bfregs;
|
resp.tot_bfregs = lib_uar_dyn ? 0 : req.total_num_bfregs;
|
||||||
resp.num_ports = dev->num_ports;
|
resp.num_ports = dev->num_ports;
|
||||||
|
|
||||||
if (offsetofend(typeof(resp), cqe_version) <= udata->outlen)
|
if (offsetofend(typeof(resp), cqe_version) <= udata->outlen)
|
||||||
@ -2141,6 +2149,9 @@ static int uar_mmap(struct mlx5_ib_dev *dev, enum mlx5_ib_mmap_cmd cmd,
|
|||||||
int max_valid_idx = dyn_uar ? bfregi->num_sys_pages :
|
int max_valid_idx = dyn_uar ? bfregi->num_sys_pages :
|
||||||
bfregi->num_static_sys_pages;
|
bfregi->num_static_sys_pages;
|
||||||
|
|
||||||
|
if (bfregi->lib_uar_dyn)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
if (vma->vm_end - vma->vm_start != PAGE_SIZE)
|
if (vma->vm_end - vma->vm_start != PAGE_SIZE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
@ -139,6 +139,7 @@ struct mlx5_bfreg_info {
|
|||||||
struct mutex lock;
|
struct mutex lock;
|
||||||
u32 ver;
|
u32 ver;
|
||||||
u8 lib_uar_4k : 1;
|
u8 lib_uar_4k : 1;
|
||||||
|
u8 lib_uar_dyn : 1;
|
||||||
u32 num_sys_pages;
|
u32 num_sys_pages;
|
||||||
u32 num_static_sys_pages;
|
u32 num_static_sys_pages;
|
||||||
u32 total_num_bfregs;
|
u32 total_num_bfregs;
|
||||||
|
@ -697,6 +697,9 @@ static int alloc_bfreg(struct mlx5_ib_dev *dev,
|
|||||||
{
|
{
|
||||||
int bfregn = -ENOMEM;
|
int bfregn = -ENOMEM;
|
||||||
|
|
||||||
|
if (bfregi->lib_uar_dyn)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
mutex_lock(&bfregi->lock);
|
mutex_lock(&bfregi->lock);
|
||||||
if (bfregi->ver >= 2) {
|
if (bfregi->ver >= 2) {
|
||||||
bfregn = alloc_high_class_bfreg(dev, bfregi);
|
bfregn = alloc_high_class_bfreg(dev, bfregi);
|
||||||
@ -768,6 +771,9 @@ int bfregn_to_uar_index(struct mlx5_ib_dev *dev,
|
|||||||
u32 index_of_sys_page;
|
u32 index_of_sys_page;
|
||||||
u32 offset;
|
u32 offset;
|
||||||
|
|
||||||
|
if (bfregi->lib_uar_dyn)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
bfregs_per_sys_page = get_uars_per_sys_page(dev, bfregi->lib_uar_4k) *
|
bfregs_per_sys_page = get_uars_per_sys_page(dev, bfregi->lib_uar_4k) *
|
||||||
MLX5_NON_FP_BFREGS_PER_UAR;
|
MLX5_NON_FP_BFREGS_PER_UAR;
|
||||||
index_of_sys_page = bfregn / bfregs_per_sys_page;
|
index_of_sys_page = bfregn / bfregs_per_sys_page;
|
||||||
|
@ -79,6 +79,7 @@ struct mlx5_ib_alloc_ucontext_req {
|
|||||||
|
|
||||||
enum mlx5_lib_caps {
|
enum mlx5_lib_caps {
|
||||||
MLX5_LIB_CAP_4K_UAR = (__u64)1 << 0,
|
MLX5_LIB_CAP_4K_UAR = (__u64)1 << 0,
|
||||||
|
MLX5_LIB_CAP_DYN_UAR = (__u64)1 << 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum mlx5_ib_alloc_uctx_v2_flags {
|
enum mlx5_ib_alloc_uctx_v2_flags {
|
||||||
|
Loading…
Reference in New Issue
Block a user