Skip to content

Commit 08dbd56

Browse files
elic307imstsirkin
authored andcommitted
vdpa/mlx5: Avoid destroying MR on empty iotlb
The current code treats an empty iotlb provdied in set_map() as a special case and destroy the memory region object. This must not be done since the virtqueue objects reference this MR. Doing so will cause the driver unload to emit errors and log timeouts caused by the firmware complaining on busy resources. This patch treats an empty iotlb as any other change of mapping. In this case, mlx5_vdpa_create_mr() will fail and the entire set_map() call to fail. This issue has not been encountered before but was seen to occur in a non-official version of qemu. Since qemu is a userspace program, the driver must protect against such case. Fixes: 94abbcc ("vdpa/mlx5: Add shared memory registration code") Signed-off-by: Eli Cohen <elic@nvidia.com> Link: https://lore.kernel.org/r/20210811053713.66658-1-elic@nvidia.com Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent a24ce06 commit 08dbd56

1 file changed

Lines changed: 0 additions & 9 deletions

File tree

  • drivers/vdpa/mlx5/core

‎drivers/vdpa/mlx5/core/mr.c‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -512,22 +512,13 @@ void mlx5_vdpa_destroy_mr(struct mlx5_vdpa_dev *mvdev)
512512
mutex_unlock(&mr->mkey_mtx);
513513
}
514514

515-
static bool map_empty(struct vhost_iotlb *iotlb)
516-
{
517-
return !vhost_iotlb_itree_first(iotlb, 0, U64_MAX);
518-
}
519-
520515
int mlx5_vdpa_handle_set_map(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb,
521516
bool *change_map)
522517
{
523518
struct mlx5_vdpa_mr *mr = &mvdev->mr;
524519
int err = 0;
525520

526521
*change_map = false;
527-
if (map_empty(iotlb)) {
528-
mlx5_vdpa_destroy_mr(mvdev);
529-
return 0;
530-
}
531522
mutex_lock(&mr->mkey_mtx);
532523
if (mr->initialized) {
533524
mlx5_vdpa_info(mvdev, "memory map update\n");

0 commit comments

Comments
 (0)