Skip to content

Commit 7925836

Browse files
jpemartinsjgunthorpe
authored andcommitted
iommufd/iova_bitmap: Check iova_bitmap_done() after set ahead
After iova_bitmap_set_ahead() returns it may be at the end of the range. Move iova_bitmap_set_ahead() earlier to avoid unnecessary attempt in trying to pin the next pages by reusing iova_bitmap_done() check. Fixes: 2780025 ("iommufd/iova_bitmap: Handle recording beyond the mapped pages") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joao Martins <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Tested-by: Matt Ochs <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent dceb530 commit 7925836

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/iommu/iommufd/iova_bitmap.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,6 @@ static int iova_bitmap_advance(struct iova_bitmap *bitmap)
384384
bitmap->mapped_base_index += count;
385385

386386
iova_bitmap_put(bitmap);
387-
if (iova_bitmap_done(bitmap))
388-
return 0;
389387

390388
/* Iterate, set and skip any bits requested for next iteration */
391389
if (bitmap->set_ahead_length) {
@@ -396,6 +394,9 @@ static int iova_bitmap_advance(struct iova_bitmap *bitmap)
396394
return ret;
397395
}
398396

397+
if (iova_bitmap_done(bitmap))
398+
return 0;
399+
399400
/* When advancing the index we pin the next set of bitmap pages */
400401
return iova_bitmap_get(bitmap);
401402
}

0 commit comments

Comments
 (0)