Skip to content

Commit

Permalink
vdpa: Add an opaque pointer for vdpa_config_ops.dma_map()
Browse files Browse the repository at this point in the history
Add an opaque pointer for DMA mapping.

Suggested-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20210831103634.33-9-xieyongji@bytedance.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
Xie Yongji authored and Michael S. Tsirkin committed Sep 6, 2021
1 parent 59dfe4f commit c10fb94
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions drivers/vdpa/vdpa_sim/vdpa_sim.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,14 +555,14 @@ static int vdpasim_set_map(struct vdpa_device *vdpa,
}

static int vdpasim_dma_map(struct vdpa_device *vdpa, u64 iova, u64 size,
u64 pa, u32 perm)
u64 pa, u32 perm, void *opaque)
{
struct vdpasim *vdpasim = vdpa_to_sim(vdpa);
int ret;

spin_lock(&vdpasim->iommu_lock);
ret = vhost_iotlb_add_range(vdpasim->iommu, iova, iova + size - 1, pa,
perm);
ret = vhost_iotlb_add_range_ctx(vdpasim->iommu, iova, iova + size - 1,
pa, perm, opaque);
spin_unlock(&vdpasim->iommu_lock);

return ret;
Expand Down
2 changes: 1 addition & 1 deletion drivers/vhost/vdpa.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ static int vhost_vdpa_map(struct vhost_vdpa *v,
return r;

if (ops->dma_map) {
r = ops->dma_map(vdpa, iova, size, pa, perm);
r = ops->dma_map(vdpa, iova, size, pa, perm, NULL);
} else if (ops->set_map) {
if (!v->in_batch)
r = ops->set_map(vdpa, dev->iotlb);
Expand Down
2 changes: 1 addition & 1 deletion include/linux/vdpa.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ struct vdpa_config_ops {
/* DMA ops */
int (*set_map)(struct vdpa_device *vdev, struct vhost_iotlb *iotlb);
int (*dma_map)(struct vdpa_device *vdev, u64 iova, u64 size,
u64 pa, u32 perm);
u64 pa, u32 perm, void *opaque);
int (*dma_unmap)(struct vdpa_device *vdev, u64 iova, u64 size);

/* Free device resources */
Expand Down

0 comments on commit c10fb94

Please sign in to comment.