@@ -454,30 +454,33 @@ static void destroy_dma_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_mr *mr)
454
454
mlx5_vdpa_destroy_mkey (mvdev , mr -> mkey );
455
455
}
456
456
457
- static int dup_iotlb (struct mlx5_vdpa_dev * mvdev , struct vhost_iotlb * src )
457
+ static int dup_iotlb (struct vhost_iotlb * dst , struct vhost_iotlb * src )
458
458
{
459
459
struct vhost_iotlb_map * map ;
460
460
u64 start = 0 , last = ULLONG_MAX ;
461
461
int err ;
462
462
463
+ if (dst == src )
464
+ return - EINVAL ;
465
+
463
466
if (!src ) {
464
- err = vhost_iotlb_add_range (mvdev -> cvq . iotlb , start , last , start , VHOST_ACCESS_RW );
467
+ err = vhost_iotlb_add_range (dst , start , last , start , VHOST_ACCESS_RW );
465
468
return err ;
466
469
}
467
470
468
471
for (map = vhost_iotlb_itree_first (src , start , last ); map ;
469
472
map = vhost_iotlb_itree_next (map , start , last )) {
470
- err = vhost_iotlb_add_range (mvdev -> cvq . iotlb , map -> start , map -> last ,
473
+ err = vhost_iotlb_add_range (dst , map -> start , map -> last ,
471
474
map -> addr , map -> perm );
472
475
if (err )
473
476
return err ;
474
477
}
475
478
return 0 ;
476
479
}
477
480
478
- static void prune_iotlb (struct mlx5_vdpa_dev * mvdev )
481
+ static void prune_iotlb (struct vhost_iotlb * iotlb )
479
482
{
480
- vhost_iotlb_del_range (mvdev -> cvq . iotlb , 0 , ULLONG_MAX );
483
+ vhost_iotlb_del_range (iotlb , 0 , ULLONG_MAX );
481
484
}
482
485
483
486
static void destroy_user_mr (struct mlx5_vdpa_dev * mvdev , struct mlx5_vdpa_mr * mr )
@@ -544,7 +547,7 @@ void mlx5_vdpa_destroy_mr_resources(struct mlx5_vdpa_dev *mvdev)
544
547
for (int i = 0 ; i < MLX5_VDPA_NUM_AS ; i ++ )
545
548
mlx5_vdpa_destroy_mr (mvdev , mvdev -> mr [i ]);
546
549
547
- prune_iotlb (mvdev );
550
+ prune_iotlb (mvdev -> cvq . iotlb );
548
551
}
549
552
550
553
static int _mlx5_vdpa_create_mr (struct mlx5_vdpa_dev * mvdev ,
@@ -596,8 +599,8 @@ int mlx5_vdpa_update_cvq_iotlb(struct mlx5_vdpa_dev *mvdev,
596
599
597
600
spin_lock (& mvdev -> cvq .iommu_lock );
598
601
599
- prune_iotlb (mvdev );
600
- err = dup_iotlb (mvdev , iotlb );
602
+ prune_iotlb (mvdev -> cvq . iotlb );
603
+ err = dup_iotlb (mvdev -> cvq . iotlb , iotlb );
601
604
602
605
spin_unlock (& mvdev -> cvq .iommu_lock );
603
606
0 commit comments