IB/mlx5: Improve MR check
Add "type" field to mlx5_core MKEY struct. Check whether page fault happens on MKEY corresponding to MR. Signed-off-by: Artemy Kovalyov <artemyko@mellanox.com> Signed-off-by: Leon Romanovsky <leon@kernel.org> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
17d2f88f92
commit
aa8e08d2f5
|
@ -129,6 +129,7 @@ static void reg_mr_callback(int status, void *context)
|
|||
return;
|
||||
}
|
||||
|
||||
mr->mmkey.type = MLX5_MKEY_MR;
|
||||
spin_lock_irqsave(&dev->mdev->priv.mkey_lock, flags);
|
||||
key = dev->mdev->priv.mkey_key++;
|
||||
spin_unlock_irqrestore(&dev->mdev->priv.mkey_lock, flags);
|
||||
|
@ -728,6 +729,7 @@ struct ib_mr *mlx5_ib_get_dma_mr(struct ib_pd *pd, int acc)
|
|||
goto err_in;
|
||||
|
||||
kfree(in);
|
||||
mr->mmkey.type = MLX5_MKEY_MR;
|
||||
mr->ibmr.lkey = mr->mmkey.key;
|
||||
mr->ibmr.rkey = mr->mmkey.key;
|
||||
mr->umem = NULL;
|
||||
|
@ -1088,6 +1090,7 @@ static struct mlx5_ib_mr *reg_create(struct ib_mr *ibmr, struct ib_pd *pd,
|
|||
mlx5_ib_warn(dev, "create mkey failed\n");
|
||||
goto err_2;
|
||||
}
|
||||
mr->mmkey.type = MLX5_MKEY_MR;
|
||||
mr->umem = umem;
|
||||
mr->dev = dev;
|
||||
mr->live = 1;
|
||||
|
@ -1533,6 +1536,7 @@ struct ib_mr *mlx5_ib_alloc_mr(struct ib_pd *pd,
|
|||
if (err)
|
||||
goto err_destroy_psv;
|
||||
|
||||
mr->mmkey.type = MLX5_MKEY_MR;
|
||||
mr->ibmr.lkey = mr->mmkey.key;
|
||||
mr->ibmr.rkey = mr->mmkey.key;
|
||||
mr->umem = NULL;
|
||||
|
@ -1613,6 +1617,7 @@ struct ib_mw *mlx5_ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type,
|
|||
if (err)
|
||||
goto free;
|
||||
|
||||
mw->mmkey.type = MLX5_MKEY_MW;
|
||||
mw->ibmw.rkey = mw->mmkey.key;
|
||||
|
||||
resp.response_length = min(offsetof(typeof(resp), response_length) +
|
||||
|
|
|
@ -155,9 +155,14 @@ static struct mlx5_ib_mr *mlx5_ib_odp_find_mr_lkey(struct mlx5_ib_dev *dev,
|
|||
{
|
||||
u32 base_key = mlx5_base_mkey(key);
|
||||
struct mlx5_core_mkey *mmkey = __mlx5_mr_lookup(dev->mdev, base_key);
|
||||
struct mlx5_ib_mr *mr = container_of(mmkey, struct mlx5_ib_mr, mmkey);
|
||||
struct mlx5_ib_mr *mr;
|
||||
|
||||
if (!mmkey || mmkey->key != key || !mr->live)
|
||||
if (!mmkey || mmkey->key != key || mmkey->type != MLX5_MKEY_MR)
|
||||
return NULL;
|
||||
|
||||
mr = container_of(mmkey, struct mlx5_ib_mr, mmkey);
|
||||
|
||||
if (!mr->live)
|
||||
return NULL;
|
||||
|
||||
return container_of(mmkey, struct mlx5_ib_mr, mmkey);
|
||||
|
|
|
@ -394,11 +394,17 @@ struct mlx5_core_sig_ctx {
|
|||
u32 sigerr_count;
|
||||
};
|
||||
|
||||
enum {
|
||||
MLX5_MKEY_MR = 1,
|
||||
MLX5_MKEY_MW,
|
||||
};
|
||||
|
||||
struct mlx5_core_mkey {
|
||||
u64 iova;
|
||||
u64 size;
|
||||
u32 key;
|
||||
u32 pd;
|
||||
u32 type;
|
||||
};
|
||||
|
||||
#define MLX5_24BIT_MASK ((1 << 24) - 1)
|
||||
|
|
Loading…
Reference in New Issue