Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vdpa/mlx5: Fix suboptimal range on iotlb iteration

The starting iova address to iterate iotlb map entry within a range
was set to an irrelevant value when passing to the itree_next()
iterator, although luckily it doesn't affect the outcome of finding
out the granule of the smallest iotlb map size. Fix the code to make
it consistent with the following for-loop.

Fixes: 94abbccdf291 ("vdpa/mlx5: Add shared memory registration code")
Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
Message-Id: <20241021134040.975221-3-dtatulea@nvidia.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>

authored by

Si-Wei Liu and committed by
Michael S. Tsirkin
35025963 29ce8b8a

+1 -3
+1 -3
drivers/vdpa/mlx5/core/mr.c
··· 368 368 unsigned long lgcd = 0; 369 369 int log_entity_size; 370 370 unsigned long size; 371 - u64 start = 0; 372 371 int err; 373 372 struct page *pg; 374 373 unsigned int nsg; ··· 378 379 struct device *dma = mvdev->vdev.dma_dev; 379 380 380 381 for (map = vhost_iotlb_itree_first(iotlb, mr->start, mr->end - 1); 381 - map; map = vhost_iotlb_itree_next(map, start, mr->end - 1)) { 382 + map; map = vhost_iotlb_itree_next(map, mr->start, mr->end - 1)) { 382 383 size = maplen(map, mr); 383 384 lgcd = gcd(lgcd, size); 384 - start += size; 385 385 } 386 386 log_entity_size = ilog2(lgcd); 387 387