Skip to content

Commit 58aca3d

Browse files
jasowangmstsirkin
authored andcommitted
vdpa: support virtio_map
Virtio core switches from DMA device to virtio_map, let's do that as well for vDPA. Signed-off-by: Jason Wang <jasowang@redhat.com> Message-Id: <20250821064641.5025-8-jasowang@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Lei Yang <leiyang@redhat.com> Reviewed-by: Eugenio Pérez <eperezma@redhat.com>
1 parent bee8c7c commit 58aca3d

14 files changed

Lines changed: 37 additions & 32 deletions

File tree

drivers/vdpa/alibaba/eni_vdpa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ static int eni_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id)
496496
pci_set_master(pdev);
497497
pci_set_drvdata(pdev, eni_vdpa);
498498

499-
eni_vdpa->vdpa.dma_dev = &pdev->dev;
499+
eni_vdpa->vdpa.vmap.dma_dev = &pdev->dev;
500500
eni_vdpa->queues = eni_vdpa_get_num_queues(eni_vdpa);
501501

502502
eni_vdpa->vring = devm_kcalloc(&pdev->dev, eni_vdpa->queues,

drivers/vdpa/ifcvf/ifcvf_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ static int ifcvf_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
713713

714714
ifcvf_mgmt_dev->adapter = adapter;
715715
adapter->pdev = pdev;
716-
adapter->vdpa.dma_dev = &pdev->dev;
716+
adapter->vdpa.vmap.dma_dev = &pdev->dev;
717717
adapter->vdpa.mdev = mdev;
718718
adapter->vf = vf;
719719
vdpa_dev = &adapter->vdpa;

drivers/vdpa/mlx5/core/mr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr
378378
u64 pa, offset;
379379
u64 paend;
380380
struct scatterlist *sg;
381-
struct device *dma = mvdev->vdev.dma_dev;
381+
struct device *dma = mvdev->vdev.vmap.dma_dev;
382382

383383
for (map = vhost_iotlb_itree_first(iotlb, mr->start, mr->end - 1);
384384
map; map = vhost_iotlb_itree_next(map, mr->start, mr->end - 1)) {
@@ -432,7 +432,7 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr
432432

433433
static void unmap_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr *mr)
434434
{
435-
struct device *dma = mvdev->vdev.dma_dev;
435+
struct device *dma = mvdev->vdev.vmap.dma_dev;
436436

437437
destroy_direct_mr(mvdev, mr);
438438
dma_unmap_sg_attrs(dma, mr->sg_head.sgl, mr->nsg, DMA_BIDIRECTIONAL, 0);

drivers/vdpa/mlx5/net/mlx5_vnet.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3395,14 +3395,17 @@ static int mlx5_vdpa_reset_map(struct vdpa_device *vdev, unsigned int asid)
33953395
return err;
33963396
}
33973397

3398-
static struct device *mlx5_get_vq_dma_dev(struct vdpa_device *vdev, u16 idx)
3398+
static union virtio_map mlx5_get_vq_map(struct vdpa_device *vdev, u16 idx)
33993399
{
34003400
struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev);
3401+
union virtio_map map;
34013402

34023403
if (is_ctrl_vq_idx(mvdev, idx))
3403-
return &vdev->dev;
3404+
map.dma_dev = &vdev->dev;
3405+
else
3406+
map.dma_dev = mvdev->vdev.vmap.dma_dev;
34043407

3405-
return mvdev->vdev.dma_dev;
3408+
return map;
34063409
}
34073410

34083411
static void free_irqs(struct mlx5_vdpa_net *ndev)
@@ -3686,7 +3689,7 @@ static const struct vdpa_config_ops mlx5_vdpa_ops = {
36863689
.set_map = mlx5_vdpa_set_map,
36873690
.reset_map = mlx5_vdpa_reset_map,
36883691
.set_group_asid = mlx5_set_group_asid,
3689-
.get_vq_dma_dev = mlx5_get_vq_dma_dev,
3692+
.get_vq_map = mlx5_get_vq_map,
36903693
.free = mlx5_vdpa_free,
36913694
.suspend = mlx5_vdpa_suspend,
36923695
.resume = mlx5_vdpa_resume, /* Op disabled if not supported. */
@@ -3965,7 +3968,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
39653968
}
39663969

39673970
ndev->mvdev.mlx_features = device_features;
3968-
mvdev->vdev.dma_dev = &mdev->pdev->dev;
3971+
mvdev->vdev.vmap.dma_dev = &mdev->pdev->dev;
39693972
err = mlx5_vdpa_alloc_resources(&ndev->mvdev);
39703973
if (err)
39713974
goto err_alloc;

drivers/vdpa/octeon_ep/octep_vdpa_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ static int octep_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
516516
}
517517

518518
oct_vdpa->pdev = pdev;
519-
oct_vdpa->vdpa.dma_dev = &pdev->dev;
519+
oct_vdpa->vdpa.vmap.dma_dev = &pdev->dev;
520520
oct_vdpa->vdpa.mdev = mdev;
521521
oct_vdpa->oct_hw = oct_hw;
522522
vdpa_dev = &oct_vdpa->vdpa;

drivers/vdpa/pds/vdpa_dev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ static int pds_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
643643

644644
pdev = vdpa_aux->padev->vf_pdev;
645645
dma_dev = &pdev->dev;
646-
pdsv->vdpa_dev.dma_dev = dma_dev;
646+
pdsv->vdpa_dev.vmap.dma_dev = dma_dev;
647647

648648
status = pds_vdpa_get_status(&pdsv->vdpa_dev);
649649
if (status == 0xff) {

drivers/vdpa/solidrun/snet_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,8 +1052,8 @@ static int snet_vdpa_probe_vf(struct pci_dev *pdev)
10521052
*/
10531053
snet_reserve_irq_idx(pf_irqs ? pdev_pf : pdev, snet);
10541054

1055-
/*set DMA device*/
1056-
snet->vdpa.dma_dev = &pdev->dev;
1055+
/* set map metadata */
1056+
snet->vdpa.vmap.dma_dev = &pdev->dev;
10571057

10581058
/* Register VDPA device */
10591059
ret = vdpa_register_device(&snet->vdpa, snet->cfg->vq_num);

drivers/vdpa/vdpa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static void vdpa_release_dev(struct device *d)
151151
* Driver should use vdpa_alloc_device() wrapper macro instead of
152152
* using this directly.
153153
*
154-
* Return: Returns an error when parent/config/dma_dev is not set or fail to get
154+
* Return: Returns an error when parent/config/map is not set or fail to get
155155
* ida.
156156
*/
157157
struct vdpa_device *__vdpa_alloc_device(struct device *parent,

drivers/vdpa/vdpa_sim/vdpa_sim.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr,
272272
vringh_set_iotlb(&vdpasim->vqs[i].vring, &vdpasim->iommu[0],
273273
&vdpasim->iommu_lock);
274274

275-
vdpasim->vdpa.dma_dev = dev;
275+
vdpasim->vdpa.vmap.dma_dev = dev;
276276

277277
return vdpasim;
278278

drivers/vdpa/vdpa_user/vduse_dev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2022,7 +2022,7 @@ static int vduse_dev_init_vdpa(struct vduse_dev *dev, const char *name)
20222022
return ret;
20232023
}
20242024
set_dma_ops(&vdev->vdpa.dev, &vduse_dev_dma_ops);
2025-
vdev->vdpa.dma_dev = &vdev->vdpa.dev;
2025+
vdev->vdpa.vmap.dma_dev = &vdev->vdpa.dev;
20262026
vdev->vdpa.mdev = &vduse_mgmt->mgmt_dev;
20272027

20282028
return 0;

0 commit comments

Comments
 (0)