summaryrefslogtreecommitdiff
path: root/drivers/vdpa/vdpa_sim
diff options
context:
space:
mode:
authorXie Yongji <xieyongji@bytedance.com>2021-08-09 18:09:23 +0800
committerMichael S. Tsirkin <mst@redhat.com>2021-09-05 16:23:08 -0400
commit0d8c9e7d4b403f10f5c277efefd787244198a00c (patch)
tree1516b93df3fb0fac37843d7367974936d923ce98 /drivers/vdpa/vdpa_sim
parent23b228cb89fdad2140b6b73254ecaf5fb05de5fe (diff)
vdpa_sim: Use iova_shift() for the size passed to alloc_iova()
The size passed to alloc_iova() should be the size of page frames. Now we use byte granularity for the iova domain, so it's safe to pass the size in bytes to alloc_iova(). But it would be better to use iova_shift() for the size to avoid future bugs if we change granularity. Signed-off-by: Xie Yongji <xieyongji@bytedance.com> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Link: https://lore.kernel.org/r/20210809100923.38-1-xieyongji@bytedance.com Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'drivers/vdpa/vdpa_sim')
-rw-r--r--drivers/vdpa/vdpa_sim/vdpa_sim.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
index c621cf7feec0..5b51d0ac8bae 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
@@ -137,7 +137,8 @@ static dma_addr_t vdpasim_map_range(struct vdpasim *vdpasim, phys_addr_t paddr,
int ret;
/* We set the limit_pfn to the maximum (ULONG_MAX - 1) */
- iova = alloc_iova(&vdpasim->iova, size, ULONG_MAX - 1, true);
+ iova = alloc_iova(&vdpasim->iova, size >> iova_shift(&vdpasim->iova),
+ ULONG_MAX - 1, true);
if (!iova)
return DMA_MAPPING_ERROR;