@@ -301,10 +301,13 @@ static void unmap_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct
301
301
sg_free_table (& mr -> sg_head );
302
302
}
303
303
304
- static int add_direct_chain (struct mlx5_vdpa_dev * mvdev , u64 start , u64 size , u8 perm ,
304
+ static int add_direct_chain (struct mlx5_vdpa_dev * mvdev ,
305
+ struct mlx5_vdpa_mr * mr ,
306
+ u64 start ,
307
+ u64 size ,
308
+ u8 perm ,
305
309
struct vhost_iotlb * iotlb )
306
310
{
307
- struct mlx5_vdpa_mr * mr = & mvdev -> mr ;
308
311
struct mlx5_vdpa_direct_mr * dmr ;
309
312
struct mlx5_vdpa_direct_mr * n ;
310
313
LIST_HEAD (tmp );
@@ -354,9 +357,10 @@ static int add_direct_chain(struct mlx5_vdpa_dev *mvdev, u64 start, u64 size, u8
354
357
* indirect memory key that provides access to the enitre address space given
355
358
* by iotlb.
356
359
*/
357
- static int create_user_mr (struct mlx5_vdpa_dev * mvdev , struct vhost_iotlb * iotlb )
360
+ static int create_user_mr (struct mlx5_vdpa_dev * mvdev ,
361
+ struct mlx5_vdpa_mr * mr ,
362
+ struct vhost_iotlb * iotlb )
358
363
{
359
- struct mlx5_vdpa_mr * mr = & mvdev -> mr ;
360
364
struct mlx5_vdpa_direct_mr * dmr ;
361
365
struct mlx5_vdpa_direct_mr * n ;
362
366
struct vhost_iotlb_map * map ;
@@ -384,7 +388,7 @@ static int create_user_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb
384
388
LOG_MAX_KLM_SIZE );
385
389
mr -> num_klms += nnuls ;
386
390
}
387
- err = add_direct_chain (mvdev , ps , pe - ps , pperm , iotlb );
391
+ err = add_direct_chain (mvdev , mr , ps , pe - ps , pperm , iotlb );
388
392
if (err )
389
393
goto err_chain ;
390
394
}
@@ -393,7 +397,7 @@ static int create_user_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb
393
397
pperm = map -> perm ;
394
398
}
395
399
}
396
- err = add_direct_chain (mvdev , ps , pe - ps , pperm , iotlb );
400
+ err = add_direct_chain (mvdev , mr , ps , pe - ps , pperm , iotlb );
397
401
if (err )
398
402
goto err_chain ;
399
403
@@ -489,13 +493,8 @@ static void destroy_user_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_mr *mr
489
493
}
490
494
}
491
495
492
- static void _mlx5_vdpa_destroy_mr (struct mlx5_vdpa_dev * mvdev , unsigned int asid )
496
+ static void _mlx5_vdpa_destroy_mr (struct mlx5_vdpa_dev * mvdev , struct mlx5_vdpa_mr * mr )
493
497
{
494
- struct mlx5_vdpa_mr * mr = & mvdev -> mr ;
495
-
496
- if (mvdev -> group2asid [MLX5_VDPA_DATAVQ_GROUP ] != asid )
497
- return ;
498
-
499
498
if (!mr -> initialized )
500
499
return ;
501
500
@@ -507,38 +506,33 @@ static void _mlx5_vdpa_destroy_mr(struct mlx5_vdpa_dev *mvdev, unsigned int asid
507
506
mr -> initialized = false;
508
507
}
509
508
510
- void mlx5_vdpa_destroy_mr (struct mlx5_vdpa_dev * mvdev , unsigned int asid )
509
+ void mlx5_vdpa_destroy_mr (struct mlx5_vdpa_dev * mvdev ,
510
+ struct mlx5_vdpa_mr * mr )
511
511
{
512
- struct mlx5_vdpa_mr * mr = & mvdev -> mr ;
513
-
514
512
mutex_lock (& mr -> mkey_mtx );
515
513
516
- _mlx5_vdpa_destroy_mr (mvdev , asid );
514
+ _mlx5_vdpa_destroy_mr (mvdev , mr );
517
515
518
516
mutex_unlock (& mr -> mkey_mtx );
519
517
}
520
518
521
519
void mlx5_vdpa_destroy_mr_resources (struct mlx5_vdpa_dev * mvdev )
522
520
{
523
- mlx5_vdpa_destroy_mr (mvdev , mvdev -> group2asid [ MLX5_VDPA_DATAVQ_GROUP ] );
521
+ mlx5_vdpa_destroy_mr (mvdev , & mvdev -> mr );
524
522
prune_iotlb (mvdev );
525
523
}
526
524
527
525
static int _mlx5_vdpa_create_mr (struct mlx5_vdpa_dev * mvdev ,
528
- struct vhost_iotlb * iotlb ,
529
- unsigned int asid )
526
+ struct mlx5_vdpa_mr * mr ,
527
+ struct vhost_iotlb * iotlb )
530
528
{
531
- struct mlx5_vdpa_mr * mr = & mvdev -> mr ;
532
529
int err ;
533
530
534
- if (mvdev -> group2asid [MLX5_VDPA_DATAVQ_GROUP ] != asid )
535
- return 0 ;
536
-
537
531
if (mr -> initialized )
538
532
return 0 ;
539
533
540
534
if (iotlb )
541
- err = create_user_mr (mvdev , iotlb );
535
+ err = create_user_mr (mvdev , mr , iotlb );
542
536
else
543
537
err = create_dma_mr (mvdev , mr );
544
538
@@ -550,13 +544,14 @@ static int _mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev,
550
544
return 0 ;
551
545
}
552
546
553
- int mlx5_vdpa_create_mr (struct mlx5_vdpa_dev * mvdev , struct vhost_iotlb * iotlb ,
554
- unsigned int asid )
547
+ int mlx5_vdpa_create_mr (struct mlx5_vdpa_dev * mvdev ,
548
+ struct mlx5_vdpa_mr * mr ,
549
+ struct vhost_iotlb * iotlb )
555
550
{
556
551
int err ;
557
552
558
553
mutex_lock (& mvdev -> mr .mkey_mtx );
559
- err = _mlx5_vdpa_create_mr (mvdev , iotlb , asid );
554
+ err = _mlx5_vdpa_create_mr (mvdev , mr , iotlb );
560
555
mutex_unlock (& mvdev -> mr .mkey_mtx );
561
556
return err ;
562
557
}
@@ -574,7 +569,7 @@ int mlx5_vdpa_handle_set_map(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *io
574
569
* change_map = true;
575
570
}
576
571
if (!* change_map )
577
- err = _mlx5_vdpa_create_mr (mvdev , iotlb , asid );
572
+ err = _mlx5_vdpa_create_mr (mvdev , mr , iotlb );
578
573
mutex_unlock (& mr -> mkey_mtx );
579
574
580
575
return err ;
@@ -603,7 +598,7 @@ int mlx5_vdpa_create_dma_mr(struct mlx5_vdpa_dev *mvdev)
603
598
{
604
599
int err ;
605
600
606
- err = mlx5_vdpa_create_mr (mvdev , NULL , 0 );
601
+ err = mlx5_vdpa_create_mr (mvdev , & mvdev -> mr , NULL );
607
602
if (err )
608
603
return err ;
609
604
0 commit comments