diff options
author | Eli Cohen <eli@mellanox.com> | 2020-08-04 19:20:47 +0300 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2020-08-06 02:00:24 +0300 |
commit | 94abbccdf2916cb03f9626f2d36c6e9971490c12 (patch) | |
tree | 81f45c0b4cc6ef67f56d3fc13bc256558d1d1c08 /drivers/vdpa/mlx5/core/resources.c | |
parent | 29064bfdabd5ef49eac6909d3a36a075e3b52255 (diff) | |
download | linux-94abbccdf2916cb03f9626f2d36c6e9971490c12.tar.xz |
vdpa/mlx5: Add shared memory registration code
Add code to support registering address space region for the device. The
virtio driver can run as either:
1. Guest virtio driver
2. Userspace virtio driver on the host
3. Kernel virtio driver on the host
In any case a memory key object is required to provide access to memory
for the device.
This code will be shared by network or block driver implementations.
Reviewed-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Eli Cohen <eli@mellanox.com>
Link: https://lore.kernel.org/r/20200804162048.22587-12-eli@mellanox.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/vdpa/mlx5/core/resources.c')
-rw-r--r-- | drivers/vdpa/mlx5/core/resources.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/vdpa/mlx5/core/resources.c b/drivers/vdpa/mlx5/core/resources.c index 6c6552b7e9b5..96e6421c5d1c 100644 --- a/drivers/vdpa/mlx5/core/resources.c +++ b/drivers/vdpa/mlx5/core/resources.c @@ -227,6 +227,7 @@ int mlx5_vdpa_alloc_resources(struct mlx5_vdpa_dev *mvdev) mlx5_vdpa_warn(mvdev, "resources already allocated\n"); return -EINVAL; } + mutex_init(&mvdev->mr.mkey_mtx); res->uar = mlx5_get_uars_page(mdev); if (IS_ERR(res->uar)) { err = PTR_ERR(res->uar); @@ -262,6 +263,7 @@ err_pd: err_uctx: mlx5_put_uars_page(mdev, res->uar); err_uars: + mutex_destroy(&mvdev->mr.mkey_mtx); return err; } @@ -277,5 +279,6 @@ void mlx5_vdpa_free_resources(struct mlx5_vdpa_dev *mvdev) dealloc_pd(mvdev, res->pdn, res->uid); destroy_uctx(mvdev, res->uid); mlx5_put_uars_page(mvdev->mdev, res->uar); + mutex_destroy(&mvdev->mr.mkey_mtx); res->valid = false; } |