Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 7d23dcd

Browse files
elic307imstsirkin
authored andcommitted
vdp/mlx5: Fix setting the correct dma_device
Before SF support was introduced, the DMA device was equal to mdev->device which was in essence equal to pdev->dev. With SF introduction this is no longer true. It has already been handled for vhost_vdpa since the reference to the dma device can from within mlx5_vdpa. With virtio_vdpa this broke. To fix this we set the real dma device when initializing the device. In addition, for the sake of consistency, previous references in the code to the dma device are changed to vdev->dma_dev. Fixes: d13a15d ("vdpa/mlx5: Use the correct dma device when registering memory") Signed-off-by: Eli Cohen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]>
1 parent e13cd45 commit 7d23dcd

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

drivers/vdpa/mlx5/core/mr.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,6 @@ static void destroy_indirect_key(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_m
219219
mlx5_vdpa_destroy_mkey(mvdev, &mkey->mkey);
220220
}
221221

222-
static struct device *get_dma_device(struct mlx5_vdpa_dev *mvdev)
223-
{
224-
return &mvdev->mdev->pdev->dev;
225-
}
226-
227222
static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr *mr,
228223
struct vhost_iotlb *iotlb)
229224
{
@@ -239,7 +234,7 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr
239234
u64 pa;
240235
u64 paend;
241236
struct scatterlist *sg;
242-
struct device *dma = get_dma_device(mvdev);
237+
struct device *dma = mvdev->vdev.dma_dev;
243238

244239
for (map = vhost_iotlb_itree_first(iotlb, mr->start, mr->end - 1);
245240
map; map = vhost_iotlb_itree_next(map, start, mr->end - 1)) {
@@ -298,7 +293,7 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr
298293

299294
static void unmap_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr *mr)
300295
{
301-
struct device *dma = get_dma_device(mvdev);
296+
struct device *dma = mvdev->vdev.dma_dev;
302297

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

drivers/vdpa/mlx5/net/mlx5_vnet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2032,7 +2032,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name)
20322032
goto err_mtu;
20332033
}
20342034

2035-
mvdev->vdev.dma_dev = mdev->device;
2035+
mvdev->vdev.dma_dev = &mdev->pdev->dev;
20362036
err = mlx5_vdpa_alloc_resources(&ndev->mvdev);
20372037
if (err)
20382038
goto err_mpfs;

0 commit comments

Comments
 (0)