Skip to content

Commit 0d8c9e7

Browse files
YongjiXiemstsirkin
authored andcommitted
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 <[email protected]> Reviewed-by: Stefano Garzarella <[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 23b228c commit 0d8c9e7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/vdpa/vdpa_sim/vdpa_sim.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ static dma_addr_t vdpasim_map_range(struct vdpasim *vdpasim, phys_addr_t paddr,
137137
int ret;
138138

139139
/* We set the limit_pfn to the maximum (ULONG_MAX - 1) */
140-
iova = alloc_iova(&vdpasim->iova, size, ULONG_MAX - 1, true);
140+
iova = alloc_iova(&vdpasim->iova, size >> iova_shift(&vdpasim->iova),
141+
ULONG_MAX - 1, true);
141142
if (!iova)
142143
return DMA_MAPPING_ERROR;
143144

0 commit comments

Comments
 (0)