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

Commit d13a15d

Browse files
elic307imstsirkin
authored andcommitted
vdpa/mlx5: Use the correct dma device when registering memory
In cases where the vdpa instance uses a SF (sub function), the DMA device is the parent device. Use a function to retrieve the correct DMA device. Fixes: 1958fc2 ("net/mlx5: SF, Add auxiliary device driver") Signed-off-by: Eli Cohen <[email protected]> Reviewed-by: Parav Pandit <[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 d084d99 commit d13a15d

File tree

1 file changed

+7
-2
lines changed
  • drivers/vdpa/mlx5/core

1 file changed

+7
-2
lines changed

drivers/vdpa/mlx5/core/mr.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ 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+
222227
static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr *mr,
223228
struct vhost_iotlb *iotlb)
224229
{
@@ -234,7 +239,7 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr
234239
u64 pa;
235240
u64 paend;
236241
struct scatterlist *sg;
237-
struct device *dma = mvdev->mdev->device;
242+
struct device *dma = get_dma_device(mvdev);
238243

239244
for (map = vhost_iotlb_itree_first(iotlb, mr->start, mr->end - 1);
240245
map; map = vhost_iotlb_itree_next(map, start, mr->end - 1)) {
@@ -291,7 +296,7 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr
291296

292297
static void unmap_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr *mr)
293298
{
294-
struct device *dma = mvdev->mdev->device;
299+
struct device *dma = get_dma_device(mvdev);
295300

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

0 commit comments

Comments
 (0)